Re: ->>coding help

From: Date: Sun, 24 Jun 2001 14:45:17 +0000
Subject: Re: ->>coding help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-55023@lists.php.net to get a copy of this message
Jason, your scripts works prefectly in creating a table. But, It only ouputs the first query from the databse. Others are not shown. ""Jason Lotito"" <jason@lehighweb.com> wrote in message news:000f01c0fc67$abfe3a90$72003bd0@genric... > This should work... > > <?php > > $connection = mysql_connect("***","****","****"); > if ($connection==false) > { > echo mysql_errno().":".mysql_error().""; > exit; > } > > $end = $list + 16; > > $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list, $end"; > $result = mysql_db_query ("celebzone", $query); > > $num = mysql_num_rows($result); > > $j=0; > $i=0; > echo "<table border=0>\n"; > > for ($j = 0; $j < $num; $j++) > { > echo '<tr>\n'; > for ($i = 0; $i <= 1; $i++) > { > @$result = mysql_fetch_array($result); > @$id = $result[id]; > @$title = $result[title]; > > echo "<td>\n"; > echo "$title"; > echo "</td>\n"; > } > echo "</tr>\n"; > } > > echo "</table>"; > echo "<br><br>\n"; > > > ?> > > Jason Lotito > www.NewbieNetwork.net > PHP Newsletter: http://www.newbienetwork.net/ciao.php > PHP, MySQL, PostgreSQL Tutorials, Code Snippets, and so much more > > > > -----Original Message----- > > From: McShen [mailto:webmaster@celeritieszones.com] > > Sent: Saturday, June 23, 2001 11:22 PM > > To: php-general@lists.php.net > > Subject: [PHP] ->>coding help > > > > > > Hi > > > > I have a script which queries mySQL and outputs 32 links at > > once. Here is my scipt > > ---- > > <?php > > > > $connection = mysql_connect("***","****","****"); > > if ($connection==false) > > { > > echo mysql_errno().":".mysql_error().""; > > exit; > > } > > > > $end = $list + 16; > > > > $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $list, > > $end"; $result = mysql_db_query ("celebzone", $query); > > > > $num = mysql_num_rows($result); > > > > $j=0; > > $i=0; > > echo "<table border=0>\n"; > > echo "<tr>\n"; > > while ($j!=$num) > > { > > @$r = mysql_fetch_array($result); > > @$id = $r[id]; > > @$title = $r[title]; > > > > echo "<td>\n"; > > echo "$title"; > > echo "</td>\n"; > > // new row in table every other link > > $i++; > > if (($i % 2) < 1) > > { > > echo "</tr>\n<tr>\n"; > > } > > > > $j++; > > } > > echo "</table>"; > > > > echo "<br><br>\n"; > > > > > > ?> > > ----------------------- > > And here is the link to see it in action > > http://www.celebritieszones.com/ln.php?list=0 > > > > If you check > > my HTML source, at the end, right before </table>, you will > > see an extra <tr>. I know the cause of this. It's because of this > > ------- > > " > > $i++; > > if (($i % 2) < 1) > > { > > echo "</tr>\n<tr>\n"; > > } > > " > > ----- > > > > I don't know how to fix the problem. Please help me re-write > > the script a bit so that it doesn't add the extra <tr>. > > > > Thanks in advance. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#55023) next »