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?

203 Like 16 Dislike
Previous php-forum Next php-forum
Other php-forum

urldecode question
How would I format this line of code properly?

<?php echo urldecode($_GET['Title']); ?

Help with email validation please...
Hi,
Please could you help.
I have a register.php login page where users register, the detail

Compare user input to flat file data
Help...Am a complete newbie to programming so my code is prolly quite long. Am trying to verify a us

Need help to identify this error please
:confused:Can anyone help me tell what this error message means? Maybe tell me where to look to fix

Different actions for different parts of a string
<?php
function dosomething($string, $else = '') {
if (empty($else))
$string

do while conditions
i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that th

use an array from 1 class in a second class
I have a class that adds data to an array

Then I have a second class and I need to check if t

echo $rows help
Hi all,

Hopefully something simple that I don't know!

I have this:

Code: [Selec

str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa

How do I get the row number from from an sql table query
Hi all

I have a table that I query and it returns a number of rows.
mysql_num_rows($query)

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