Re: Re: SQL Insert INTO question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<snip>
How about:

$review = $_POST['review'];
$sql = "SELECT * FROM reviews WHERE review_id = '$id'";
$res = mysql_query($sql) or die ("Query failed: " . mysql_error());
if (mysql_num_rows($res) > 0)
{
     $sql_upd = "UPDATE reviews
                           SET review_text = '$review'
                         WHERE review_id = '$id' ";
     $res_upd = mysql_query($sql_upd) or die ("Query failed: " . mysql_error());
 }else{
      $sql_ins = "INSERT INTO reviews (review_id, review_text)
                         VALUES('$id', '$review')";
      $res_ins = mysql_query($sql_ins) or die ("Query failed: " .
mysql_error());
}

--
Graham

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux