PHP Help mysql
#1

Hello ive got a lil problem with php in mysql script and i need this forum help


$result = mysql_query("SELECT * FROM `banlog` WHERE name='$name' LIMIT 5");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$banned = $row['banned'];
if($banned == 0) $banned = 'No';
if($banned == 1) $banned = 'Yes';
}


Problem is that if 1 user is banned it shows for all others and i want to add $name into "if" and if banned = 0 the result will be No
Im not good in english and dont know how to write it good so please understand me
Reply
#2

Try this:
pawn Код:
$result = mysql_query("SELECT * FROM `banlog` WHERE name='$name' LIMIT 5");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$banned = array();
$banned['$name'] = $row['banned'];
if($banned['$name'] == 0) $banned['$name'] = 'No';
if($banned['$name'] == 1) $banned['$name'] = 'Yes';
}
If $banned ia a global variable, then you need to add this $banned = array(); where you created it.


I don't know anything about neither mysql nor php. Anyway, try the code.
Reply
#3

Still not working
Reply
#4

I removed this " WHERE name='$name' " and in php when i see in Banned category
it shows array because of $banned = array();
Any help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)