Reply to for loop problems

Your name:

Reply:


Posted by robertcode on 10/08/06 00:32

Hey all, I'm pretty new to php so please keep that in mind when you
razz me. ;)

Anyway, I'm trying to make it so that 3 columns of links will show up
on a page so

link1 link2 link3
link4 link5 link6
link7 link8 link9

etc.

I've got this code for it, but I get an error message if the number of
links in the database isn't an integer divided by three. So if it's not
3,6,9,12, etc. I get

Warning: mysql_result(): Unable to jump to row 4 on MySQL result index
3 in mydirectory/loop.php on line 14

I'd like it to stop if there is a number not divisible by 3, but I'm
guessing it just keeps going.

here's the code.

for ($i = 0; $i < mysql_num_rows($result);)
{
echo '<table align="center" cellpadding="0" cellspacing="0"
width="90%"> <tr>';
for ($a = 0; $a < 3; $a++)
{
$articlename = mysql_result($result, $i, "articlename");
$articletitle = mysql_result($result, $i, "articletitle");
$i++;
echo '<td width="33%" align="center" valign="top"> <p><a
href="/articles/' . $articlename . '/articles.php">' . $articletitle
..'</a></p> </td>';
}
echo '</tr></table><br>';
}

Thanks for your time.

[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

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