0

下面是来自目录页面的代码,其中包含必须插入数据库的数据。它有一些问题,我无法将该数据插入到数据库表中,而且我认为我没有正确移植变量。

我的目录页面有这个代码(用于购买照片):

while ($row=mysql_fetch_assoc($result))
 {
echo "<tr><td width=100><img src=".$row['FilePath']." /></td>";
    echo "<td width=100 padding=25>".$row['Title']."</td>"; $hour = time() + 3600; setcookie('titlecookie', $row['Title'], $hour); 
    echo "<td width=100 padding=25>".$row['Cost']."</td>";
echo "<td width=100>".$row['FileSize']."</td>";
echo "<td width=100>".$row['CaptureDate']."</td>";
echo "<td width=100>".$row['Resolution']."</td>";
echo "<td width=100><input type=checkbox name=checked[] value=select />Purchase</td></tr>";
 }
 echo "</table><input type=submit name=submit value=Purchase></form></center>";
}
else
{
  echo "Query not successful";
}

我的购买页面的代码如下所示:

$username = "COOKIE['ID_my_site']";

$title = "COOKIE['titlecookie']";

$Custid = mysql_query("SELECT Custid from Customer Where Username=$username");

$Money = $_POST['Cost'];

$Photoid = mysql_query("SELECT Photoid from Photograph Where Title = $row[Title]");

foreach ($_POST['checked'] as $select) {

if(mysql_query('INSERT INTO Transaction (Money, Custid)
      VALUES ($Money, $Custid)'))
{
  echo "successfully added to Transaction";
}
    else
    {
        echo "Problems adding data to Transaction";
    } 



if(mysql_query("INSERT INTO TransPhoto (Photoid, Transid)
      VALUES ('$Photoid', '$Transid')"))
{
  echo "successfully added to Transphoto";
}
    else
    {
        echo "Problems adding data to Transphoto";
    }

}

你能帮我修复这段代码吗?我对此相对较新,但已经搜索并找不到有效的解决方案。谢谢

4

0 回答 0