Hi can anyone help me, I need to fetch more than 1 row at the same time. I've used print_r(mysql_f etch_array($res ult)); but I only get 1 row is there away of of getting more then 1 row.
kind regards
Zawadi
Hi can anyone help me, I need to fetch more than 1 row at the same time. I've used print_r(mysql_f etch_array($res ult)); but I only get 1 row is there away of of getting more then 1 row.
kind regards
Zawadi
Hi,
Try something like this:
[CODE=php]
while ($row = mysql_fetch_arr ay($result, MYSQL_BOTH))
{
if ($row)
{
echo $row;
}
}
[/CODE]
This should print each row in the result of the query. If this only ever returns 1 row of data then perhaps that's all that was returned? Check the SQL
Try something like this:
[CODE=php]
while ($row = mysql_fetch_arr ay($result, MYSQL_BOTH))
{
if ($row)
{
echo $row;
}
}
[/CODE]
This should print each row in the result of the query. If this only ever returns 1 row of data then perhaps that's all that was returned? Check the SQL
Cheers
nathj
Thanks this really did help, but the output is Array Array Array. How do i get the data from the arrays.
Thanks for your reply
zar
Thanks but I must be doing something wrong all I'm getting is the column data in a string and what i need is all the rows i'm calling set in an array. I know i have 3 rows of data and I need them to look like this, but all 3 rows.
Array
(
[0] => 1
[id] => 1
[1] => test
[name] => test
[2] => 86
[subtotal] => 86
[3] => t541
[identnum] => t541
[4] => 1
[itemqut] => 1
[5] => Vinyl camera case
[itemproduct] => Vinyl camera case
[6] => None
[itemsize] => None
[7] => 57.00
[itemprice] => 57.00
)
but I'm only getting 1 row,
if you can help I would be very greatful
kind regards
Zar
this line tells database which rows to look at the one with same username $glog is a var of the user name sent by the user.
$query = "SELECT * FROM theOrder WHERE name ='$glog'";
this is the query
$result = mysql_query($qu ery);
the number of rows from the query
$numR = mysql_num_rows( $result);
the array data this is good but it only gives me the 1st row, and like i said there are 3 row using the same user name and i need all 3 rows set out in a array
print_r(mysql_f etch_array($res ult));
One final point, if I may. Check out the article on building a data abstraction layer. It'll really help with this sort of stuff and it will properly modularise all your code for you making it easier to maintain and re-use.
Cheers
nathj
Last edited by nathj; Jul 24 '07, 06:03 AM.
Reason: removing quote
Comment