Daniello Posted June 27, 2009 Share Posted June 27, 2009 Hey guys. I'm kind of new to php, and I'm still at the whole "newbie" stage, however that's obviously not why I create this thread. I'm trying to pull multiple results out of out of my MySQL table. Now, to give you an impression of how the table is structured, I'll try to illustrate it. I have 6 rows that i need to pull information out of [id] [admin] [user] [kick] [ban] [jail] The [id][admin] and [user] works out just as supposed, the part that I'm stuck with is the [kick] [ban] [jail]. For example [kick] = 0 [ban] = 0 [jail] = 1 Would mean php should select [jail], which it does, however for some reason it keeps repeaing the first echoed result of the kick,ban,jail if statement. <? $query = 'SELECT id,ban,kick,jail,admin,user FROM `adminlog` WHERE user = "'.mysql_real_escape_string($_SESSION['Name']).'" ORDER BY id'; $query2 = mysql_query('SELECT * FROM `adminlog` WHERE user = "'.mysql_real_escape_string($_SESSION['Name']).'" LIMIT 1'); $result = mysql_query("$query") or die("Table Content Request Failed: " . mysql_error()); if($test->kick == 1) { $status = "Ban"; } elseif($test->ban == 1) { $status = "Kick"; } elseif($test->jail == 1) { $status = "Jailed"; } if(mysql_num_rows($result) == 0) { ?> <i>Archive of kicks/bans/jails is empty</i> <? return false; } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo 'Action made by: '.$row['admin'].'<br />'.$status.'<br /><br /> '; } ?> as you can see, if i have two results in the table, it would print it out twice. Now, lets say that the two results are supposed to be Admin1 Jail Admin2 Ban php's output is Admin1 Jail Admin2 Jail So it is repeating the jail part, even though the jail is not matching the second result. I'm honestly stuck in this, and would appreciate a little help very much. (keep in mind functions and so on who is not stated, is stated in a previous header include). / Daniello. Quote Link to comment https://forums.phpfreaks.com/topic/163879-pulling-multiple-results-from-mysql/ Share on other sites More sharing options...
Daniel0 Posted June 27, 2009 Share Posted June 27, 2009 Where is $query2 used? Where is $test defined? Where is $status defined? Quote Link to comment https://forums.phpfreaks.com/topic/163879-pulling-multiple-results-from-mysql/#findComment-864666 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.