Jump to content

help with using 'LIMIT' in my query


rsammy

Recommended Posts

i am trying this query in my php file. but,it still displays only one of 7 values in the table...

HELP PLEASE

$querylistdt="SELECT * from oncall order by oncall_id desc limit '5'";
$resultlistdt=mysql_query($querylistdt);
$rowlistdt=mysql_fetch_array($resultlistdt);
$list_date=$rowlistdt["oncall_date"];
$list_time=$rowlistdt["oncall_time"];
$list_oncallid=$rowlistdt["oncall_id"];
$list_oncallorgid=$rowlistdt["oncall_org_id"];
$list_oncallphyid=$rowlistdt["oncall_phy_id"];
Link to comment
https://forums.phpfreaks.com/topic/26747-help-with-using-limit-in-my-query/
Share on other sites

you'll need to loop through the results...
[code]
<?php
$querylistdt="SELECT * from oncall order by oncall_id desc limit '5'";
$resultlistdt=mysql_query($querylistdt);
while ($rowlistdt=mysql_fetch_array($resultlistdt)){
  $list_date=$rowlistdt["oncall_date"];
  $list_time=$rowlistdt["oncall_time"];
  $list_oncallid=$rowlistdt["oncall_id"];
  $list_oncallorgid=$rowlistdt["oncall_org_id"];
  $list_oncallphyid=$rowlistdt["oncall_phy_id"];
  // more loop logic
}
?>
[/code]

more info in the forums "common problems, check here first":
http://www.phpfreaks.com/forums/index.php/topic,95441.0.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.