ryanteck Posted January 18, 2011 Share Posted January 18, 2011 Im trying to get a code to find an id by name and then find a value by id this kinda works can you help? <?php $con = mysql_connect("localhost","root","password"; if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ryanteck", $con); $result = mysql_query("SELECT * FROM forum_members WHERE member_name='ryan'"); while($row = mysql_fetch_array($result)) { echo $row['member_name'] . "s Id is " . $row['id_member']; echo "<br />"; $result2 = mysql_query("SELECT * FROM forum_themes WHERE id_member= $id && variable= 'cust_uberis'"); while($row = mysql_fetch_array($result2)) or die (mysql_error()); { echo $id . "Uber Island Is " . $row['value']; echo "<br />"; } } ?> Link to comment https://forums.phpfreaks.com/topic/224812-php-mysql-help-needed/ Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 Can we help with what, exactly? Link to comment https://forums.phpfreaks.com/topic/224812-php-mysql-help-needed/#findComment-1161333 Share on other sites More sharing options...
Rifts Posted January 18, 2011 Share Posted January 18, 2011 this $result2 = mysql_query("SELECT * FROM forum_themes WHERE id_member= $id && variable= 'cust_uberis'"); should be $result2 = mysql_query("SELECT * FROM forum_themes WHERE id_member= $id AND variable= 'cust_uberis'"); Link to comment https://forums.phpfreaks.com/topic/224812-php-mysql-help-needed/#findComment-1161337 Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 Changing && to AND won't matter at all. Link to comment https://forums.phpfreaks.com/topic/224812-php-mysql-help-needed/#findComment-1161349 Share on other sites More sharing options...
Coolkat Posted January 18, 2011 Share Posted January 18, 2011 in your code you are using the variable $id in your query but you never defined it.. I assume you want to use $row['id_member']'s value in your second query so you will need to put after the query, $id = $row['id_member'] Link to comment https://forums.phpfreaks.com/topic/224812-php-mysql-help-needed/#findComment-1161417 Share on other sites More sharing options...
ryanteck Posted January 18, 2011 Author Share Posted January 18, 2011 Sorry about not writing a full post, i had to go half way through. Me and my friend are making a linking system to link his php game with my smf forum. what i need it to do is first find the user id off the name ( first part ) which works. we then need it to use that id to find the value after searching for that id and variable. thanks ryan Link to comment https://forums.phpfreaks.com/topic/224812-php-mysql-help-needed/#findComment-1161451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.