php-db | 2001041

Re: [PHP-DB] substring_index Part 2 From: Paul Burney (burney <email protected>)
Date: 04/12/01

on 4/12/01 9:53 AM, Mike Baerwolf (mike <email protected>) 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 <email protected>>
<http://www.gseis.ucla.edu/>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>