我有一个Sql表,我需要搜索members
列,以查看是否有任何值与之前获得的值相同(例如:76561198119598543),如果是,那么我想要获取存储在同一行的name
下的值......
下面的链接是表格的示例以及如何设置成员列的示例。 http://nbdcommunity.com/staffimages/example.png
我不是一个博士学位的人,并且已经尝试了我能找到的所有东西......
$gangsql = 'SELECT members, name, owner FROM 'gangs' WHERE owner LIKE "$playerid%"';
(playerid是我想要比较的值)
答案 0 :(得分:0)
列成员中的值看起来不是数字,而是字符串。假设情况如此,您可以尝试:
throw new InvalidArgumentException('Cannot end a section without first starting one.');
这将返回" name"的值对于"成员"的所有行列包含您检查的号码。
答案 1 :(得分:0)
以下是我对您的问题的理解:
它就像一个搜索框。如果要查看的数据匹配,则显示它?
示例:
PHP文件
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
if (indexPath.row < myComments!.count) {
if let messageText = myComments![indexPath.row].text {
let size = CGSizeMake(self.view.frame.width / 2, 100)
let options = NSStringDrawingOptions.UsesFontLeading.union(.UsesLineFragmentOrigin)
let estimatedFrame = NSString(string: messageText).boundingRectWithSize(size, options: options, attributes: [NSFontAttributeName: UIFont.systemFontOfSize(14)], context: nil)
return CGSizeMake(view.frame.width, estimatedFrame.height + 50)
}
}
return CGSizeMake(view.frame.width, 100)
}
HTML HERE
<?php
//Connection here
if isset($_POST["member"]){
$get_data = $_POST["member"];
//Display matched Data
$sql = mysql_query("SELECT * FROM table_name WHERE member = '$get_data' ");
while($row = mysql_fetch_array($sql)){
//Declare variables
$this_name = $row["name"];
//Display Variable
echo
'The name you are looking for is this person; on this case it\'s a number <u>'.$this_name.'</u>';
}
//END WHILE LOOP
}else{
//No match
echo '
<script>
alert("Data has no match. Please try again");
window.location= "php_page_name.php";
</script>
';
}
?>
希望这会有所帮助。祝你好运!
答案 2 :(得分:0)
$lastValue = "76561198119598543";
$c = new mysqli($server, $user, $password) or die("cant connect");
if($res = $c->query("SELECT name FROM table WHERE members='$lastValue'")){
if($res->num_rows > 0){
$resAssoc = $res->fetch_assoc();
$name = $resAssoc["name"];
}
} else {
die($c->error);
}
$c->close();