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

Writing Windows Device Drivers with C
Yes: one of the nice features of C is void*. You can put anything there and get anything out. Very

Dump with added_funcion cl_salv_table
Hi there, I'm having some troubles adding a self defined function to an ALV in fullscreen. The thing

url- go to webpage
i have an input text field and submit button.

how do i make the url entered into the textfiel

SuperCali PHP Event Calendar
does anyone have any experience with the SuperCali PHP Event Calendar? I could use some assistance

Effort Estimation Template for Steady State Support
Hi Everyone,

Is there any SAP provided template/format for system change and enhancements

Issue Parsing XML into table
Hello all,

Im a bit new to php and new to phpfreaks. But thanks in advance for the help!
<

Check Digits and extracting digits
I think I can figure out the code for this but I am having a very hard time getting past the first s

Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is

Alternate messaging
I have 4 strings in MySQL db1

$string1 : Hello
$string2 : Hi
$string3 : Great
$strin

Splitting Attributes
SQL> SELECT I_NAME, substr(I_NAME,1,instr(I_NAME,'O')) "First part",

substr(I_NAME, IN

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