RE: [PHP] Select
| From: | Alfredeen, Johan | Date: | Tue, 14 Aug 2001 15:10:00 +0000 |
| Subject: | RE: [PHP] Select | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-62649@lists.php.net to get a copy of this message | ||
Jeremy,
The reason you are only getting the first value is because you are only
retrieving the first value and assigning it to $data. You need to step
through the result and do something with it. For example,
if ($row = mysql_fetch_array($result)) {
do {
$data1 = $row["mycolumn1"];
$data2 = $row["mycolumn2"];
} while ($row = mysql_fetch_array($result));
// more code
}
Alternatively, you could insert the values into a multidimensional array
inside the loop, so you don't have to hardcode the columns. It's up to you.
Johan Alfredeen
pongworld.com
-----Original Message-----
From: Jeremy Morano [mailto:jeremy@prepresshelp.com]
Sent: Tuesday, August 14, 2001 8:53 AM
To: php-general@lists.php.net
Subject: [PHP] Select
Hi,
I'm having a problem with my Select statement. This is what i'm doing:
$connection = @mysql_connect("l", "c", "c") or die("Couldn't
connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select
database.");
$sql =" SELECT *
FROM table_1
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
$data=mysql_fetch_row($result);
$count=$data[0];
echo $count;
Yet the only result I get is the first value of the first
column.............
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net