0

hey,
i have problem with paging,i need to use two tables to fetch data.
i am submitting my developed code. i hope some body will help me.

mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("dummy1") or die(mysql_error());



$START=$_GET['start'];
if(!$START)
{
    $START=0;
}

$data = mysql_query("SELECT * FROM scrapmsg ORDER BY date DESC") or die(mysql_error());
$total = mysql_num_rows($data);
$LIMIT = 4;
$NEXT=$START+$LIMIT;
$PREV=$START-$LIMIT;
//This is your query again, the same one... the only difference is we add $max into it
$data_p = mysql_query("SELECT scrapmsg.ucode,scrapmsg.myomsg, acountseting.usercode, acountseting.fnm, acountseting.imgpath ". "FROM scrapmsg, acountseting "."WHERE scrapmsg.rcode = acountseting.usercode ORDER BY scrapmsg.rcode DESC  LIMIT $START,$LIMIT") or die(mysql_error());

//$query = "SELECT scrapmsg.ucode,scrapmsg.myomsg, acountseting.usercode, acountseting.fnm, acountseting.imgpath ". "FROM scrapmsg, acountseting "."WHERE scrapmsg.rcode = acountseting.usercode ORDER BY scrapmsg.rcode DESC";
while($info = mysql_fetch_array( $data_p ))
{
  
  if($info['usercode'] == $current_img)
  {
  	print $info['ucode'] . " to " . $info['rcode'];
  	print $info['myomsg'];
  	print "<br>";
  }
}
2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by diafol
0

hey ardav,

this script is not printing data on the page.
this is the problem.
i don't know why is not working i had check this script for fetching data in simple form.data is coming on the page but in paging it's not coming.

So please help me if you have any solution for this problem.

Thanks

0

well it's my mistake, i forgot to declare all variables.
when i was posting this problem.
$total is a variable to count no. of data stored in "scrapmsg" table and $current_img is containing the value of usercode that used for if condition.
if "scrapmsg's usercode" equals with $current_img them it goes in the if condition and print required data.

Thanks

0
$START=$_GET['start'];
if(!$START)
{
    $START=0;
}

to

$LIMIT = 4;
//get total num recs as $TOTAL...
$PAGES = ceil($TOTAL/$LIMIT);
if(isset($_GET['start']){
    $START=intval($_GET['start');
    if($START > $PAGES)$START = $PAGES;
    if($START < 0)$START = 0;
}else{
    $START = 0;
}
$OFFSET = $START * $LIMIT;

//then in your sql ... LIMIT $OFFSET,$LIMIT...

Off top of my head - sorry can't test at the moment.

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.