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?

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.