PDA

View Full Version : array in mysql


wolfe
12-28-2007, 12:11 PM
i cant get this array to work


$array = "59,63,64,69,72";

$threadarray = $vbulletin->db->query_read("
SELECT thread.*, icon.title AS icontitle, icon.iconpath
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = thread.iconid)
WHERE
thread.visible = 1 AND thread.forumid IN ('" . implode(",", $array) . "')
ORDER BY dateline DESC
LIMIT 15");


it returns nothing except this error Warning: implode() [function.implode]: Invalid arguments passed

Opserty
12-28-2007, 12:20 PM
$array is not an array, its just a string. You don't need to implode it.


// An Array
$array = array ( 59, 63, 64, 72);
echo implode('-', $array);
// Outputs 59-63-64-72


But in your example you don't need to implode it because the numbers are already seperated by commas. So just change implode(",", $array) to $array.

wolfe
12-28-2007, 03:45 PM
m8 thats not what i needed i need it to only show threads that are in them forumids ?

Lynne
12-28-2007, 03:47 PM
I think he told you what you need to do:
m8 thats not what i needed i need it to only show threads that are in them forumids ?
$array is not an array, its just a string. You don't need to implode it.

So just change implode(",", $array) to $array.

wolfe
12-28-2007, 03:47 PM
nevermind m8 that worked gr8 thx :P