Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Istraukimas is mysql su IF'U

Parašė Kelmas· 2010 Spa. 30 20:10:34
#3

Šitas kodas mano manymu 10x geresnis.

0.1v

<?php
$search_list = array("cdeifjtun", "it", "cdeifjun");
$search_values = array("cdeifjtun" => "VIP + ADMIN", "it" => "VIP", "cdeifjun" => "ADMIN");
 
foreach ($search_list as $search) {
	$data = dbquery("SELECT `username` FROM `amx_amxadmins` WHERE `username` = '".$ip."' AND `access` LIKE '$search' LIMIT 1");
	if (dbrows($data)) {
		echo "Tu turi ".$search_values[$search];
	}
}
?>


0.2v

<?php
$search_values = array("cdeifjtun" => "VIP + ADMIN", "it" => "VIP", "cdeifjun" => "ADMIN");
 
$result = dbquery("SELECT `access` FROM `amx_amxadmins` WHERE `username` = '".$ip."' AND (`access` LIKE 'cdeifjtun' OR `access` LIKE 'it' OR `access` LIKE 'cdeifjun') LIMIT 1");
if (dbrows($result)) {
	$data = dbarray($result);
	echo "Tu turi ".$search_values[$data['access']];
}
?>


Rašiau iš galvos tai gali būti klaidų. Bet tavo kodas tai pasityčiojimas.

Redagavo Kelmas· 2010 Spa. 30 20:10:22