Reply to Re: Using mysql_result() Deletes Row From Result

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация