SA-MP Forums Archive
PHP Help mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PHP Help mysql (/showthread.php?tid=595031)



PHP Help mysql - EmiGjoni - 27.11.2015

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


Re: PHP Help mysql - ATGOggy - 27.11.2015

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.


Re: PHP Help mysql - EmiGjoni - 27.11.2015

Still not working


Re: PHP Help mysql - EmiGjoni - 28.11.2015

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