[nycphp-talk] Printing from arrays.
ian forsyth
ian at plusfour.org
Wed Sep 11 14:03:19 EDT 2002
Matthew Zimmerman wrote:
>Hello,
>
>Sorry if this is a RTFM question, but this list has been such a great
>resource I wanted to start here.
>
>Just a question about printing from an array using PHP/MySQL
>
in trouble shooting arrays try print_r($row); you will be able to see
the keys, and data of the array..
>2. I have a query that says
>
>$query= "SELECT images.id, format.id, format.name
>FROM images, format
>WHERE images.id=$id"; /* $id is a passed from a from*/
>
>
You could try aliases the field in the sql statement, meaning select
fieldname as aliasname.
select images.id as imageid, format.id, format.name
from images, formate
where images.id = $id"; /* look into $_POST['id'] or $_GET['id'] but
that is beside the point */
>3. Then I assign the results to an array using
>
>$result= mysql_query($query);
>
>while ($row=mysql_fetch_array($result)
>
> {
> extract($row);
>
echo $imageid . ", " . $id . ", " . $name;
> }
>
the key to the array is the field name. never the tablename.fieldname
unless of course you alias the field that way.. .
regards,
Ian
>
>
>
>--- Unsubscribe at http://nyphp.org/list ---
>
>
>
>
>
>
More information about the talk
mailing list