I tried this code, and it still just keeps 'a loopin'... What is wierd is that I have some if the code I tried in my site on other pages, and it functions without a problem...any thoughts?
Thanks for the help. -Keith Posehn "Owen Prime" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > With the line: > > while (list($link, $title, $content) = mysql_fetch_array($result)) { > > The php docs don't actually say what the list() function returns, but since > your getting an infinite loop i would say that it probably evaluates to > true no matter whats on the right hand side of the assignment. I would > suggest that you use: > > while ($tmp = mysql_fetch_array($result)) { > list($link, $title, $content) = $tmp; > > Cheers, > > Owen Prime > http://www.noggin.com.au > > > Keith Posehn wrote: > > > Ok, here is the question: > > > > I have a sql query, nothing special. It has 3 variables. I have created > > the php code to display the variables in context with the html code. I > > need it to loop a select number of times, most likely twice, and therefore > > display the first two rows of the query. > > > > In other words, querying the database for a set of rows, it needs to > > display the first two of the rows on the page. > > > > Here is the code I have tried so far, which has either looped continuosly > > or displayed the top row twice (edited for security): > > > > <?php > > > > > > $sql = "SELECT * FROM [database] ORDER BY [collumn] LIMIT 2"; > > $result = mysql_query($sql) or die("problem with $sql"); > > // list($title) = mysql_fetch_array($result); > > ?> > > > > <td width=48% align=left valign=top> > > > > <h3>What's New?</h3> > > > > <?php > > > > /* It tried this: */ while(list($link, $title, $content) = > > mysql_fetch_array($result)){ > > > > /* And this: */ while($row = mysql_fetch_array($result) and > > (($count++)<2)){ > > > > // The first kept looping infinitely, the second displayed the top row > > twice. Grr... >_< > > > > ?> > > > > <h4> > > <a href="<?php echo mysql_result($result,0,"link"); ?>"><?php echo > > mysql_result($result,0,"title"); ?></a> > > </h4> > > <p> > > <?php echo mysql_result($result,0,"content"); ?> > > </p> > > > > <?php > > } > > ?> > > > > </td> > > > > Thanks for any help you can provide. > > > > -Keith Posehn > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php