Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-09-2008, 02:43 PM   #1
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Rep: Reputation: 16
PHP: storing all data form a db row in variables with the same name as the db column

its maybe a bit unclear.

What i want to do is getting all the data out of a db row, and storing this data in a variable with the name of the db column. To explain it:
\\ This is what i use right now
$sql = "SELECT * FROM pages";
$query = mysql_query($sql);
while ($output = mysql_fetch_array($query) {
  $pageName = $output["pageName"];
  $pageTitle = $output["pageTitle"]
But what i want is that it automaticly assigns the data of $output["pageName"] (and pageTitle) to a variable with the name of the column in the database.
I think i have to do someting with a foreach, but i'm not sure.

Hope this was clear.
Old 07-09-2008, 07:57 PM   #2
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 31
You could just use extract().
Old 07-10-2008, 05:13 AM   #3
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Original Poster
Rep: Reputation: 16
yes it works, thanks!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the second column and first row data from a file??? loplayers Linux - Newbie 3 11-05-2007 07:35 PM
Transposing a column into a row mayyash Linux - General 1 09-30-2005 02:23 AM
PHP:Unable to post variables from html form to mysql database vikram_cvk Linux - Software 1 09-29-2004 03:01 PM
willing to pay $$$ PHP / Javascript multiple paged form; carrying over variables micro_sucks General 1 12-26-2003 09:37 AM
Problems with php 4.2.1 form-data and hidden variables coea77 Programming 1 10-10-2002 03:24 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration