1

我如何更改我的 php 代码,以便它可以回显“如果项目刚刚创建或更新?”

$query_item_create = "INSERT INTO `item` (`category_id`, `id`) VALUES ('$catid', '$id')";
$query_item_update = "UPDATE `item` SET `date`='$date',`info`='$info' WHERE `id`='$id'";
mysql_query($query_item_create);
mysql_query($query_item_update);
4

1 回答 1

2

这里解释得更好: http: //php.net/manual/en/function.mysql-affected-rows.php

$affected = mysql_affected_rows();
if($affected > 0)
   echo "row was updated/inserted";
else
   echo "No rows were ....";
于 2012-05-31T23:29:06.243 回答