Forum Moderators: coopster
$result = mysql_query("SELECT entry_id FROM journal_tags WHERE journal_id = '$owner' && tag = '$tag'");
while ($row = mysql_fetch_array($result)) {
echo ''.$row['entry_id'].' ';
}
So say this query returns 4 numbers.. 111 222 333 444
Now i want to select those numbers from another table, so what i tried (and failed) to do was put those into a variable like so;
while ($row = mysql_fetch_array($result)) {
$entry_id = $row['entry_id'];
}
So now i want to make a mysql query to select those numbers from another table
$result=mysql_query("SELECT * FROM journal_entries WHERE entry_id = '$entry_id' ORDER BY entry_id DESC");
The problem is, it only returns the latest single result, not all 4.
Any idea how i can get this to work? Im kinda stuck..
Change this:
while ($row = mysql_fetch_array($result)) {
$entry_id = $row['entry_id'];
}
to this:
$entry_id = array();
while ($row = mysql_fetch_array($result)) {
$entry_id[] = $row['entry_id'];
}
Then your new query will be:
$ids = implode(",", $entry_id);
$result=mysql_query("SELECT * FROM journal_entries WHERE entry_id IN ($ids) ORDER BY entry_id DESC");
dc