|
Posted by Petr Vileta on 09/10/06 14:58
"Steve" <racquetballer@hotmail.com> wrote in
news:Xrqdne41wuUQA57YnZ2dnUVZ_qCdnZ2d@comcast.com...
[...]
> I then use mysql_result() to get the category name from the first row
> (since it will be the same in all rows). The problem I'm having is that
> when I use mysql_result(), the data from the last row in the result set is
> not displayed, even though the HTML for that row is written out, and the
> "No parts found for this category" message is written to the page (see
> below).
>
>
> for ($i = 0;$i < $num_results2; $i++)
> {
> $row2 = mysql_fetch_array($result2);
>
try this
$query = "SELECT parts.category, parts.part_number,parts.years,
parts.description, parts.price, parts.graphic, categories.description AS
Category";
FROM parts INNER JOIN categories on parts.category = categories.code
WHERE parts.category = '$parts_choice'";
$result2 = mysql_query($query) or die("mysql_error());
$rows2 = mysql_num_rows($query);
if ($rows2==0)
{
echo "No parts found for this category.";
}
else
{
while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC))
{
echo "<tr>\n<td>", $row2["part_number"], "</td>\n",
"<td>", $row2["years"], "</td>\n",
"<td>", $row2["description"], "</td>\n",
"<td>\$", $row2["price"], "</td>\n"
}
}
?>
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
[Back to original message]
|