检查字段中是否有相同的号码 [英] Check field for identical number
本文介绍了检查字段中是否有相同的号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码:<?php echo $pinDetails->id;?>
这为我提供了唯一的ID,并将其显示在我的页面上.
this gives me a unique ID and displays it on my page.
我正在尝试检查一个表的唯一ID是否也在另一个表中.如果是这样,则显示该表中的其他数据.
I am trying to check whether this unique ID for one table is also in another table. Then if it is, show other data from that table.
<?php
$data = mysql_query("SELECT * FROM repin WHERE new_pin_id>$pinDetails->id")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
Print "".$info['from_pin_id'].",".$info['new_pin_id']."";
}
?>
据我了解,这应该可以正常工作,但是什么也没出现.我的语法有误吗?
To my understanding this should work fine but nothing appears. Do I have the syntax wrong?
还有,有没有更清洁的方法呢?
Also, is there a cleaner way of doing this?
推荐答案
更改查询类似
<?php
$data = mysql_query("SELECT * FROM repin WHERE new_pin_id LIKE ".$pinDetails->id) or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
Print "".$info['from_pin_id'].",".$info['new_pin_id']."";
}
?>
这篇关于检查字段中是否有相同的号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文