this code I post
Suppose you have ONLY one Record for each ID-number
'id' is a so called UNIQUE KEY
If so, I think this will work very well, but have NOT tested it ....
There might be some little detail I have overlooked
when quickly writing this php code.
🙂
halojoy
<?php
//SQL login here
// We only SELECT id + name,
// Only PULL from DB what we need from each result row
// This way we put as little work, stress, on DB as possible
// Makes a bit faster script
$sql="SELECT id, name FROM $tbl_name ORDER BY id ASC";
$result = mysql_query($sql);
$hits = array(); // To collect any hit
while($row = mysql_fetch_array($result)){
//Equal to: $hits[id] = $row
$hits[$row['id']] = $row; // each row id+name
}
mysql_close();
// We now have CLOSED MySQL and can use the DATA array $hits
// LOOP 1-100
for( $i=1; $i<=100; $i++ ){
echo $i . '. ';
if( isset( $hits[$i] ) ){
//echo $hits[$i]['id'] not needed
echo $hits[$i]['name'];
}
else
{
echo 'available!';
}
echo "<br />\n";
}
exit();
?>