clanstyles Posted July 4, 2007 Share Posted July 4, 2007 I have a problem I want to do $result = mysql_query("SELECT rank FROM `ranks` WHERE id=$rankid"); I have the Rank but its in an array how do I get it out without doing while($r = mysql_fetch_array(result)) Thanks Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/ Share on other sites More sharing options...
teng84 Posted July 4, 2007 Share Posted July 4, 2007 $result = mysql_query("SELECT rank FROM `ranks` WHERE id IN (".implode(',',$rankid)."))"; something like that Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289268 Share on other sites More sharing options...
clanstyles Posted July 4, 2007 Author Share Posted July 4, 2007 that doesn't work. Implode has a bad arg. Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289320 Share on other sites More sharing options...
clanstyles Posted July 4, 2007 Author Share Posted July 4, 2007 Heres what I have right now: CREATE TABLE `ranks` ( `id` int(11) NOT NULL auto_increment, `rank` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; And inside a user account table there is a field called rank. It has to support multiple "ranks". How can I retrieve it the best? Thank You Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289323 Share on other sites More sharing options...
clanstyles Posted July 4, 2007 Author Share Posted July 4, 2007 Warning: implode() [function.implode]: Bad arguments. in xxxxxxxxxxxxxxxxxxx/page.login.php on line 37 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 Theres the error Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289325 Share on other sites More sharing options...
john010117 Posted July 4, 2007 Share Posted July 4, 2007 Try this: $result = mysql_query("SELECT rank FROM `ranks` WHERE id IN (" . implode (',',$rankid) . ")"); Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289326 Share on other sites More sharing options...
clanstyles Posted July 4, 2007 Author Share Posted July 4, 2007 Warning: implode() [function.implode]: Bad arguments. in /xxxxxxxxxxxxxxxxxxxxxxxxxxxx/page.login.php on line 37 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 stil Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289335 Share on other sites More sharing options...
john010117 Posted July 4, 2007 Share Posted July 4, 2007 $query = "SELECT rank FROM `ranks` WHERE id IN(" . implode(',', $rankid) . ")"; $result = mysql_query($query) OR DIE (mysql_error()); Putting it in variables is sometimes easier. Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289336 Share on other sites More sharing options...
clanstyles Posted July 4, 2007 Author Share Posted July 4, 2007 nope still Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289367 Share on other sites More sharing options...
clanstyles Posted July 4, 2007 Author Share Posted July 4, 2007 bump Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-289717 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 bump plz Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-290103 Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 dot this first print_r($rankid); then paste here the output Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-290107 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 It does print out the correct rank. Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-290133 Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 if theres a result any paste it here and will make solution if none check it first that cause a big prob that only you can solve Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-290135 Share on other sites More sharing options...
AndyB Posted July 5, 2007 Share Posted July 5, 2007 I have the Rank but its in an array ... It would help my comprehension of your problem if you explained that with a couple of simple examples of the data that is in your table. It might even help toward a solution as I get the feeling this thread is careering around chasing shadows at the moment. Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-290153 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 Sorry ill give you all of it hold up: CREATE TABLE `ranks` ( `id` int(11) NOT NULL auto_increment, `rank` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; These are the ranks. In the member fields there is a place for "rank" it is going to be the number in ranks. so if 1 = Guest in ranks then if you have 1 rank in youra ccount i need it to print out tha tyou are a guest. Link to comment https://forums.phpfreaks.com/topic/58340-mysql-query-question/#findComment-290163 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.