Re: getting rows from separate tables stacked in a single array ? (newbie, mysql)

From: Date: Wed, 25 Apr 2001 02:50:41 +0000
Subject: Re: getting rows from separate tables stacked in a single array ? (newbie, mysql)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-50221@lists.php.net to get a copy of this message
Thanks a bunch, SL. I was expecting some heavy manipulation of that sort. Wouldnt have been able to write that code. (yet ! ;-). I will try that tomorow. This afternoon In despair I ended tweaking the db and creating an extra table to link all the desired tables with a time indice, temporarily solving my problem but promising future headaches when I devellop the db admin page. Here is how I dit it: table "all_items" item_id (id of the items in their original tables) date_posted (original item post date) table_name (where the item comes from) spot_id (key to the project) It works with this code: //connecting to the link table to get time-ordered list of relevant items, their origin and their keys $sql4="select DATE_FORMAT(date_posted, '%a %m/%d/%y at %l:%i %p.'), item_id, item_table from spot_items where spot_id = \"$spot_id\" order by date_posted desc"; $result4=MySQL_query($sql4); while($spotitems=MySQL_fetch_array($result4)) { list($items_date_posted, $items_id, $items_table) = $spotitems ; //linking to the real tables to get the real item info $sql5="select * from $items_table where item_id = \"$items_id\""; $result5=MySQL_query($sql5); while($items=MySQL_fetch_array($result5)) { $items_title = $items["title"]; $items_description = $items["description"]; $items_duration = $items["duration"]; } //outputing in fonction of the item origin if ($items_table == "movie") echo "$items_title (Quicktime, duration: $items_duration) $items_date_posted<br>$items_description<br"; if ($items_table == "storyboard") echo "$items_id\ $items_title (Storyboard) $items_date_posted<br> $items_description<br>"; if ($items_table == "picture") echo "$items_title(Picture) $items_date_posted <br>$items_description<br>"; } thanks again, Nicolas.

« previous php.general (#50221) next »