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

Java API in PHP?
I have an application that we use internally here at the office.

The software company provide

Embed Video Problem
Hey, thanks for looking!

File to be embedded:

Code: <playlist version="1&q

storing video files into mysql in php
hi

i have my video files in my folder ,
i have to store the path of the videos into db an

Menu restriction
How can I restrict the individual menu that would appear when a user logs in so that all users are c

email CODING Problem
Email coding problem.

I need to send a section of the info to $tf and the same as a Cc to $em

Displaying pictures
i have worked my way through storing images in directory and storing the location in mySQL db.Now i

PHP Code To Change Font Color in Table Cell
I would appreciate help with the following snippet of my php code. I am just trying to change the f

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

A WBS element with the name XXX already exists in version FREI_VERSION
Hi.
When I am trying to insert WBS element in a project, error occurs:

"A WBS eleme

Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" '

Code: [Select]preg_

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