我有广告表,并且该表中有包含 Int 值的 Id 列 这是保存成员(member)需要浏览的广告的表格 成员(member)每 24 小时只能浏览每个广告 ,当成员(member)点击浏览广告按钮时,他将按Id浏览广告DESC顺序
将为成员(member)展示的链接广告示例
我的网站 com/surfing.php?area=ad&id=8
如果我将 ID 值从 url 链接(而不是从表中)手动更改为任何数字示例,则会出现问题:5478965324
我的网站 com/surfing.php?area=ad&id=5478965324
这个数字不在 ID 列中 但 url 有效,并将其视为 Id
$id=$_GET[id];
if ($id == '') {header("location: surfing.php"); exit;}
if ($id != '0') {$ad_info=mysql_fetch_array(mysql_query("SELECT * FROM ads where id=$id"));}
if ($id == '0') {$collect=mysql_fetch_array(mysql_query("SELECT * FROM config"));$ad_info[link]=$collect['url'];}
if ($id == '0') {$frame1="surfing.php?area=msg&msg=1";} else {$frame1="surfing.php?area=top&&id=$id";}
if ($id == '0') {$ad_temp="<frame src='$frame1' noresize=noresize>";}
最佳答案
$id = $_GET['id'];
$results = mysqli_query($con, "SELECT * FROM table WHERE id = '{$id}'");
现在检查是否存在:
if ( mysqli_num_rows($result) < 1 )
{
// handle error here..
}
关于php - 从表中调用 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25231862/