Quote:
Originally Posted by lazyseller
Code:
while ($data = $vbulletin->db->fetch_array($dataresult))
{
// process it here
$wow1 = $data[0];
$wow2 = $data[1];
echo "<PRE>";
print_r($data);
echo "</PRE>";
print_r($wow1);
print_r($wow2);
}
Ok i have no idea what im doing wrong. I printed the array out to see how its displayed but i do not see the (array #) such as [0], [1]
So im totally lost.
|
Well, you're printing the data inside the while loop... See, while you're inside that while loop, you only have the scope of the single row. That is to say, the only field that you selected was field7, so every row will only have 1 value. Therefore your print_r statement doesn't see anything but 1 value - and since it's not an array (or rather, since it gets translated to a single variable by some under-the-cover stuff in PHP) there is no index.
Do this instead.
PHP Code:
$dataresult = $vbulletin->db->query_read("
SELECT field7
FROM " . TABLE_PREFIX . "thread
ORDER BY field7 DESC LIMIT 5
");
$queriedfields = array();
while ($data = $vbulletin->db->fetch_array($dataresult))
{
// process it here
array_push( $queriedfields, $data[field7] );
}
print_r( $queriedfields );