Re: substring_index Part 2

From: Date: Thu, 12 Apr 2001 16:14:09 +0000
Subject: Re: substring_index Part 2
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8522@lists.php.net to get a copy of this message
on 4/12/01 9:53 AM, Mike Baerwolf (mike@wkla.com) wrote: > $result = mysql_query("SELECT substring_index(body, \".\" ,2) FROM > news",$db) or die ("Invalid Query"); > if ($myrow = mysql_fetch_array($result)) { > > do { > > printf("%s\n<br>", $myrow["headline"]); > printf("%s\n", $myrow["body"]); > > > } while ($myrow = mysql_fetch_array($result)); Maybe it's because the if statement doesn't have an ending }. Of course, it could have been snipped for brevity. I assume that somewhere in the code you have the connection made and the database selected. Can you try this? <?php if (mysql_num_rows($result) > 0) { while ($myrow = mysql_fetch_array($result)) printf("%s\n<br>", $myrow['headline']); printf("%s\n", $myrow['body']); } } else { echo 'No results found!'; } ?> The above is untested but I think it will work. :) Hope that helps, Paul Burney ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Paul Burney Webmaster and Open Source Developer Educational Technology Unit Graduate School of Education and Information Studies University of California, Los Angeles (310) 825-8365 <webmaster@gseis.ucla.edu> <http://www.gseis.ucla.edu/> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

« previous php.db (#8522) next »