Simpler method of getting variables from mysql


Posted on 16th Feb 2014 07:03 pm by admin

Hi Guys,

I'm trying to streamline my CMS's code and as I was writing a new page it occured to me that there might be an easier way to get variables from a mysql query and that if anyone knew how to do it, it would be you guys.

Here is the code I use now:

Code: // Pulls the data from the database
$dblookup = "SELECT moduleID, menu_name, stylesheet_name, display_name, has_menu, access_control, installed, compatible, active FROM core_modules WHERE moduleID=" . $_GET['ID'];
$data = mysql_query($dblookup) or die('Failed to return data: ' . mysql_error());
/* sorts the data into variables and puts them in an array ready to be called when needed */
list($moduleID, $menu_name, $stylesheet_name, $display_name, $has_menu, $access_control, $installed, $compatible, $active) = mysql_fetch_array($data, MYSQL_NUM);
}
Is there a way I can just do SELECT * FROM and then have it automatically extract the data into variables based on the column name?

No comments posted yet

Your Answer:

Login to answer
203 Like 16 Dislike
Previous forums Next forums
Other forums

need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen

IP Based Cron Jobs
I run cronjobs on my website. After one of my visitors got curious and tinkered around he realized h

reading partial code from external site
Hi,

I am trying to write a script for my website to get an article from an external website.

a very simple php header question (sorry!)
Firstly...I do apologise if this annoys anyone....a header error

I'm do not know php &

COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i

SELECT * FROM users WHERE Users are not in Blocked
How do I select all users from users table where there users_id is not stored in the block table

SCO Unix
I know this might not be the place to ask, but, can anyone tell me if SCO Unix comes with PHP built

Count on multidimensional array
Hi, i got an array as below:

Array
(
=> Array
(

Help: problem with Headers to download PDF file
Hi,

I'm trying to implement a script where when a user clicks a link he gets a PDF file to op

Securing a user input - need some confirmation
Hello All,

I am in the process of recoding a large proportion of an e-commerce site, one of t

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash