Basically, I need a way of getting around a problem I recently found out...
When I don't have a sequential row ID pattern (1,2,3,4), which comes up like (2,5,6), the script will return absolutely nothing.
This is my current PHP code:
[PHP]<?php
$sql_queries[1] = "SELECT id FROM `news`";
$sql_query = mysql_query( $sql_queries[1] ) or die();
$sql_num_rows = mysql_num_rows( $sql_query ) or die();
for ( $i = $sql_num_rows; $i > 0; $i-- )
{
$sql_queries[2] = "SELECT type,date,headl ine FROM `news` WHERE id = '".$i."'";
$sql_query2 = mysql_query( $sql_queries[2] ) or die();
$sql_array = mysql_fetch_arr ay( $sql_query2 ) or die();
echo "<tr>\n";
echo "<td>".$sql_arr ay['date']."</td>\n";
echo "<td>".$sql_arr ay['headline']."</td>\n";
echo "<td>".$sql_arr ay['type']."</td>\n";
echo "<td align=\"center\ "><a href=\"index.ph p?page=news&act =edit&id=".$i." \"><img src=\"images/form_edit.png\" alt=\"Edit\"></a></td>\n";
echo "<td align=\"center\ "><a href=\"index.ph p?submit=true&p age=news&act=li st&id=".$i."\"> <img src=\"images/form_delete.png \" alt=\"Delete\"> </a></td>\n";
echo "</tr>\n";
}
?>[/PHP]
So I basically need a workaround for listing a table that will show all "news" rows, even if the IDs weren't in a specific sequence (eg; I deleted a few articles, added and modified some, etc).
When I don't have a sequential row ID pattern (1,2,3,4), which comes up like (2,5,6), the script will return absolutely nothing.
This is my current PHP code:
[PHP]<?php
$sql_queries[1] = "SELECT id FROM `news`";
$sql_query = mysql_query( $sql_queries[1] ) or die();
$sql_num_rows = mysql_num_rows( $sql_query ) or die();
for ( $i = $sql_num_rows; $i > 0; $i-- )
{
$sql_queries[2] = "SELECT type,date,headl ine FROM `news` WHERE id = '".$i."'";
$sql_query2 = mysql_query( $sql_queries[2] ) or die();
$sql_array = mysql_fetch_arr ay( $sql_query2 ) or die();
echo "<tr>\n";
echo "<td>".$sql_arr ay['date']."</td>\n";
echo "<td>".$sql_arr ay['headline']."</td>\n";
echo "<td>".$sql_arr ay['type']."</td>\n";
echo "<td align=\"center\ "><a href=\"index.ph p?page=news&act =edit&id=".$i." \"><img src=\"images/form_edit.png\" alt=\"Edit\"></a></td>\n";
echo "<td align=\"center\ "><a href=\"index.ph p?submit=true&p age=news&act=li st&id=".$i."\"> <img src=\"images/form_delete.png \" alt=\"Delete\"> </a></td>\n";
echo "</tr>\n";
}
?>[/PHP]
So I basically need a workaround for listing a table that will show all "news" rows, even if the IDs weren't in a specific sequence (eg; I deleted a few articles, added and modified some, etc).
Comment