01-25-2008, 10:48 AM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
You will want to use the explode function to seperate the commas. I can't explain exactly how it works, because I don't know.
But the SQL later would look like:
PHP Code:
$aActors = array(); foreach($aIds as $iId) { $sql = "SELECT * FROM `actors` WHERE `id` = '".$iId."' LIMIT 1"; $query = mysql_query($sql);
if($query) { $aActors[] = mysql_fetch_array($query); } else { echo 'Could not fetch data for actor id: ' .$iId; } }
foreach($aActors as $aActor => $aInfo) { echo $aInfo['First Name']; }
That would fetch all the data of the actors in the array of numbers.
That's where explode comes in, which I'm sure that someone else can explain.
Then it places all the data in a multi-dimensional array.
Code:
$array = array(
'0' => array('id' => 3, 'first name' => 'Jessica', 'last name' => 'Alba'),
'1' => array('id' => 4, 'first name' => 'Arnold', 'last name' => 'Schwarzenegger')
);
And then we foreach that array, and echo out the names :)
|
|
|
|