slannesh Posted July 5, 2012 Share Posted July 5, 2012 Hi I want to put an sql result in a variable. Basically I have a 'select user_id from table where user_id = 'x'' and I want to throw user_id into $uid. The purpose of this is to tie in another record with that user id. Which mysql functions should I be looking at? Am I going about this the wrong way? Thanks Link to comment https://forums.phpfreaks.com/topic/265263-question-with-variables-and-php/ Share on other sites More sharing options...
ManiacDan Posted July 5, 2012 Share Posted July 5, 2012 1) The manual page for mysql_query shows you exactly how to do this 2) If you're using the results of one table to query another, you'd be better off writing a JOIN query. Link to comment https://forums.phpfreaks.com/topic/265263-question-with-variables-and-php/#findComment-1359397 Share on other sites More sharing options...
slannesh Posted July 5, 2012 Author Share Posted July 5, 2012 Ah OK thanks for the reply. Ill take a look at it. Link to comment https://forums.phpfreaks.com/topic/265263-question-with-variables-and-php/#findComment-1359406 Share on other sites More sharing options...
Barand Posted July 5, 2012 Share Posted July 5, 2012 select user_id from table where user_id = 'x' Are you seriously using a query to get the user_id value Link to comment https://forums.phpfreaks.com/topic/265263-question-with-variables-and-php/#findComment-1359408 Share on other sites More sharing options...
ManiacDan Posted July 6, 2012 Share Posted July 6, 2012 Err...barand has a great point. You already have the user_id. Don't query at all. Link to comment https://forums.phpfreaks.com/topic/265263-question-with-variables-and-php/#findComment-1359670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.