Jump to content

Loop through data


vj5
 Share

Recommended Posts

I want to loop through the data and display 25 records. Here is my code:

$CNT1=0;$QRY1="Select * from `tblconfirm` where `brokerid` = '".$lu."' ORDER BY `caseID` DESC LIMIT 25";$result = mysql_query($QRY1);$CNT1= mysql_num_rows($result);echo "$QRY1<br>";if ($CNT1 != 0) {   $idx=0;   while ($idx < $CNT1) {	  	  // EXTRACT DATA FROM THE DATABASE   	  $sdate = mysql_result($result, $idx, "sub-date");	  $bor = mysql_result($result, $idx, "brokerid");	  $car = mysql_result($result, $idx, "carrier");	  $gnum = mysql_result($result, $idx, "group_number");	  $gnam = mysql_result($result, $idx, "group_name");	  $type = mysql_result($result, $idx, "type");	  $sgroup = mysql_result($result, $idx, "subgroup");	  $cid = mysql_result($result, $idx, "caseID");	  $rep = mysql_result($result, $idx, "rep");	  $actiontxt = mysql_result($result, $idx, "action-text");	  $status = mysql_result($result, $idx, "status");	  $idx++;   }}//SHOW RESULT TO THE SCREENecho "<div id=bor-int-box>";echo "$sdate:";echo "$bor";echo "($cid)";echo "</div>";

Can someone please tell how to display 25 records at a time. I am able to see only one, the top most.

Link to comment
Share on other sites

you are looping through data, save the results to variables and echo them outside the loop. the variables will contain ONLY values from the last record, that's why you get only last record.print the results inside while loop.

$CNT1=0;$QRY1="Select * from `tblconfirm` where `brokerid` = '".$lu."' ORDER BY `caseID` DESC LIMIT 25";$result = mysql_query($QRY1);$CNT1= mysql_num_rows($result);echo "$QRY1<br>";if ($CNT1 != 0) {   $idx=0;   while ($idx < $CNT1) {      	// EXTRACT DATA FROM THE DATABASE  	$sdate = mysql_result($result, $idx, "sub-date");	$bor = mysql_result($result, $idx, "brokerid");	$car = mysql_result($result, $idx, "carrier");	$gnum = mysql_result($result, $idx, "group_number");	$gnam = mysql_result($result, $idx, "group_name");	$type = mysql_result($result, $idx, "type");	$sgroup = mysql_result($result, $idx, "subgroup");	$cid = mysql_result($result, $idx, "caseID");	$rep = mysql_result($result, $idx, "rep");	$actiontxt = mysql_result($result, $idx, "action-text");	$status = mysql_result($result, $idx, "status");	$idx++;	//SHOW RESULT TO THE SCREEN	echo "<div id=bor-int-box>";	echo "$sdate:";	echo "$bor";	echo "($cid)";	echo "</div>";   }}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...