hisham
IS-IT--Management
- Nov 6, 2000
- 194
I have in mysql database 2 tables: category and items
I used the following code to display the first row of the “name” field from category table:
$query = "SELECT * FROM category";
$result = mysql_query($query);
$id = mysql_result($result,0,"name"
$idd = mysql_result($result,0,"id"
?>
<table>
<td>
echo "<p align=\"center\"><a href=\"details.php?sid=$idd\">$id</a>";
?>
</td></table>
but I tried to modify the code to display only 2 rows “ the number of rows is 18 ” in the same page by using the following code, but still display the first row which is the same result “as the above”:
$query = "SELECT * FROM category";
$result = mysql_query($query);
$id = mysql_result($result,$i,"name"
$idd = mysql_result($result,$i,"id"
?>
<table>
<td>
<? if ($i=0) {
echo "<p align=\"center\"><a href=\"articles.php?sid=$idd\">$id</a>";
}
?>
</td></table>
// here some html
<table>
<td>
<? if ($i=1) {
echo "<p align=\"center\"><a href=\"articles.php?sid=$idd\">$id</a>";
}
?>
</td></table>
I used the following code to display the first row of the “name” field from category table:
$query = "SELECT * FROM category";
$result = mysql_query($query);
$id = mysql_result($result,0,"name"
$idd = mysql_result($result,0,"id"
?>
<table>
<td>
echo "<p align=\"center\"><a href=\"details.php?sid=$idd\">$id</a>";
?>
</td></table>
but I tried to modify the code to display only 2 rows “ the number of rows is 18 ” in the same page by using the following code, but still display the first row which is the same result “as the above”:
$query = "SELECT * FROM category";
$result = mysql_query($query);
$id = mysql_result($result,$i,"name"
$idd = mysql_result($result,$i,"id"
?>
<table>
<td>
<? if ($i=0) {
echo "<p align=\"center\"><a href=\"articles.php?sid=$idd\">$id</a>";
}
?>
</td></table>
// here some html
<table>
<td>
<? if ($i=1) {
echo "<p align=\"center\"><a href=\"articles.php?sid=$idd\">$id</a>";
}
?>
</td></table>