Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
ny
- Forum Newbie
- Posts: 2
- Joined: Thu Aug 04, 2005 12:56 pm
Post
by ny »
Hi,
I have got a mysql table which cols are changing (bad i know...)
i want to select all cols and add them to an array
aka
$dbquery['col'] => value
any way to do this?
-
anjanesh
- DevNet Resident
- Posts: 1679
- Joined: Sat Dec 06, 2003 9:52 pm
- Location: Mumbai, India
Post
by anjanesh »
You want to get all the field (column) names of the table or all rows of a particular field (column) ?
-
ny
- Forum Newbie
- Posts: 2
- Joined: Thu Aug 04, 2005 12:56 pm
Post
by ny »
i want an named (indexed?) array...
i want to get values of the array via $array['colname'] = $calvalue
Sorry, but my englis his terrible hope you understand

-
anjanesh
- DevNet Resident
- Posts: 1679
- Joined: Sat Dec 06, 2003 9:52 pm
- Location: Mumbai, India
Post
by anjanesh »
Code: Select all
$arr = array();
$Sql = "SELECT `field1` FROM `table1`";
$Res = mysql_query($Sql);
while ($Row = mysql_fetch_assoc($Res))
{
$arr[] = $Row['field1'];
}