Jump to content

[SOLVED] Setting MySQL table values to PHP variables


doogles

Recommended Posts

Pretty simple question. I think this is more related to PHP than mysql so I posted it here. I just want to select values from mysql and be able to save them to my own PHP variables.

 

The catch is that I don't know what the values will be because they are based on user input, so I can't use a WHERE clause. Any help would be great.

 

The table's name is the only thing known about it. Also, I know there are 3 columns: 'title', 'points_earned', and 'points_possible' and that the table is not empty. All of that is verified. I just need to save the values that are in it to its respective values.

 

Any help is appreciated.

 

I was thinking a few if clauses would work...

if(mysql_num_rows(mysql_query(SELECT * FROM $class)) = 1) {
//I don't know what to do to save the values to php variables
}

 

maybe I need an auto_increment integer to work with?

 

 

 

Did you mean to fetch data from db and store in php variables.

 

Than try this:

 

This is just example:

$sql="select * from table";
$result=mysql_query($sql);
$row=mysql_fetch_object($result);
$name=$row->name;

 

Hope this will help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.