Doh, I shoulda thought of that, a temp table is the best way to do it.
Altho, I don't see why you have a spot_id as a key for that table.  Your are
probably never going to access that table via that arbitrary number.  If
anything, you should make item_id the key.  The id on your other tables
should also be keys.

SL.

----- Original Message -----
From: "Nicolas Mermet" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 24, 2001 8:50 PM
Subject: Re: [PHP] getting rows from separate tables stacked in a single
array ? (newbie, mysql)


>
> 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.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to