|
|
|
ขอสอบถามเรื่อง Array หน่อยครับ ให้ return "true", "false" |
|
|
|
|
|
|
|
Code (PHP)
<?php
include ('paging.inc.php');
$request = trim(strtolower($_REQUEST['username']));
$sql = "select username FROM member ORDER BY 'member_id'";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
$result[] = $row;
}
// $a = array('asdf', 'Peter', 'Peter2', 'George'); เช็คได้
$a = array($result);
print_r($a);
$valid = 'true';
foreach($a as $user) {
if( strtolower($user) == strtolower($request))
{
$valid = 'false';
}
}
echo $valid;
?>
|
|
|
|
|
Date :
2012-10-23 19:37:53 |
By :
dekkuza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้ครับ ยังเป็น true เหมือนเดิม
|
|
|
|
|
Date :
2012-10-25 14:34:34 |
By :
choke1417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ ใช้โค๊ดชุดนี้
Code (PHP)
<?php
include ('paging.inc.php');
$sql = "SELECT * FROM member WHERE username = '".trim($_REQUEST['username'])."' ";
$query = mysql_query($sql);
$users = mysql_fetch_array($query);
if($users)
{
$valid = 'false';
}else{
$valid = 'true';
}
echo $valid;
?>
|
|
|
|
|
Date :
2012-10-26 09:26:26 |
By :
choke1417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|