我对编码和 php 非常陌生,所以我意识到这可能不是实现我目标的理想编码方式。我的目标是允许每天提交一个表格。我设置了一个等于数字的变量。然后它应该查询表以查看是否有一行包含数字和会话的用户。如果已经存在具有该编号的行,我不希望将任何新信息提交到表中。如果该行不存在,我希望将 User 和 Number 放入表中。
$nd = '5';
$nd = $td;
$connect = mysql_connect("a","a","a") or die ("Problem Connecting to Database");
mysql_select_db("a") or die ("Can't find database");
$query1 = mysql_query("SELECT * From p1 WHERE td='$td'");
$numrows1 = mysql_num_rows($query1);
if($numrows1 !=9999)
{
while($rows1 = mysql_fetch_assoc($query1))
{
$dbtd = $rows1['td'];
}
if ($dbtd==$td)
{
echo "You have already submitted Today.";
}
else
{
$connect = mysql_connect("a","a","a") or die ("Problem Connecting to Database");
mysql_select_db("a") or die ("Can't find database");
$query = mysql_query("INSERT INTO p1 VALUES('$name','$nd')");
die("Submission Complete <a href = 'a'>Go Home</a>");
}
}