doogles Posted June 7, 2007 Share Posted June 7, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/54526-solved-setting-mysql-table-values-to-php-variables/ Share on other sites More sharing options...
mmarif4u Posted June 7, 2007 Share Posted June 7, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/54526-solved-setting-mysql-table-values-to-php-variables/#findComment-269722 Share on other sites More sharing options...
doogles Posted June 7, 2007 Author Share Posted June 7, 2007 hmm...well, I tried that and then echo $name, and nothing showed Quote Link to comment https://forums.phpfreaks.com/topic/54526-solved-setting-mysql-table-values-to-php-variables/#findComment-269732 Share on other sites More sharing options...
mmarif4u Posted June 7, 2007 Share Posted June 7, 2007 Can u show ur code. Quote Link to comment https://forums.phpfreaks.com/topic/54526-solved-setting-mysql-table-values-to-php-variables/#findComment-269733 Share on other sites More sharing options...
doogles Posted June 7, 2007 Author Share Posted June 7, 2007 I just added an auto_increment column so I can use a WHERE clause now Thanks for the help. It works now Quote Link to comment https://forums.phpfreaks.com/topic/54526-solved-setting-mysql-table-values-to-php-variables/#findComment-269735 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.