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 PHP help... have all the elements... just need help putting them together :
Hey Guys,

I was wondering if someone could help me. I am doing a website for a client which

MII Trends - add data onto chart object
Hello,

Can anyone please provide some thoughts on my current requirement:
its pretty

Simultaneous select/update/insert
Hi

How would I need to go about when 2 users update a single row simultaneous? And how would

ASP.NET Validation Event Cycle
Hi,
I have asp button as follow:

rand() function
just a general question guys a girls, is the rand() function 100% random or is it based on time?

Big O & time complexity ???
can you help me how to calculate the Big O & time complexity for any algorithm and c++ program pleas

Loop Through Date Range
Hi guys,
I have date range as parameter like 01/JAN/2009 TO 16/JAN/2009 now i want to loop thro

UTL File problem
Hi
I have a file in certain path with the following permissions (The file is a dummy file witho

mail() says sent but no email received
My code is quite simple:

Code: <?php
$to = "Ty44ler@yahoo.com";
$subje

split values
I have values that are returned to me in this format:

name=>test,age=>49

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