Jump to content

Making a list


leodirk

Recommended Posts

Ok well basically I have a table that lists a ton of items in it which have a name, and ID and some other things. I am trying to get it to repeat the whole list of them ordered by the ID, but because not every number for the ID is used I want to display "Empty" or something for each time there is not an item with that ID. I know it is most likely some pretty easy script but I have been off lately with my PHP scripting x.x.. Thanks.

Link to comment
https://forums.phpfreaks.com/topic/101778-making-a-list/
Share on other sites

<?php
SQL login here


$sql1="SELECT * FROM $tbl_name ORDER BY id DSC";
$sql2="SELECT * FROM $tbl_name ORDER BY id ASC";
$result1=mysql_query($sql1); 
$result2=mysql_query($sql2);
$highest=mysql_fetch_field($result1);

$id=mysql_fetch_field($result2);
for(i=0;i<=$highest->id;i++){
     
     if($id->id > i){//print empty row}
     else{
          //print the user data
          $id=mysql_fetch_field($result2); 
     }
           
}


mysql_close();
?>

Link to comment
https://forums.phpfreaks.com/topic/101778-making-a-list/#findComment-520761
Share on other sites

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.