[Phpwm] nuSoap question

Ray Masa raymasa at hotmail.com
Thu Oct 5 11:50:37 BST 2006


Ah, so what’s the difference between the two while loop statements (sorry, I 
am a newbie..:) ).  And what would be a better SQL statement to display all 
the records?

Thanks,

Ray



> > <?php
> > function getStockQuote($id) {
> >
> >     mysql_connect('host','username','password');
> >     mysql_select_db('db');
> >     $query = "SELECT * FROM table "
> >            . "WHERE id = '$id' ";
> >     $result = mysql_query($query);
> >
> >     while ($row = mysql_fetch_assoc($result)){
> >     return $row['stock'];
> >     }
> > }
>
>Thats not going to work. Its starting a loop then dropping straight out of
>it with a return, it doesnt go anywhere else.
>It should be 'return array' as well.
>Plus if it didn't get a result and returned with no data wouldn't that
>effectively unset() your variable when it returned with nothing?

> > Code:
> >
> >    mysql_connect('host','username','password');
> >     mysql_select_db('db');
> >     $query = "SELECT * FROM table "
> >            . "WHERE id = '$id' ";
> >     $result = mysql_query($query);
> >
> >     while ($row = mysql_fetch_assoc($result)){
> >     echo $row['stock'];
> >     }
> >
>
>That works because the While loop gets a chance to finish, i.e. its parsed
>the entire array.
>
>
>Phil
>
>
>_______________________________________________
>Phpwm mailing list
>Phpwm at mailman.lug.org.uk
>https://mailman.lug.org.uk/mailman/listinfo/phpwm





More information about the Phpwm mailing list