halcyonalt Posted October 3, 2006 Share Posted October 3, 2006 I have a reccomendation system instead of a rating system, and I'm using PHP and mySQL. The tutorial I found requires commands, and mySQL doesn't support that, so I thought that I could use a form and the update function that dreamweaver offers to add to the reccomendation count row.Each time you press submit, it's supposed to add the value ("1") from a hidden field into the rec count row.All I need to make it do is add one instead of replace what is already in the row. I'm not sure how to do this, as I am quite a newbie when it comes to coding in PHP. I don't want to screw anything up. Here is the code Dreamweaver spewed for my update record function, if you can help me modify it, I'd be much obliged:[code]function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];}if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "recupdate")) { $updateSQL = sprintf("UPDATE Fanfiction SET `Rec Count`=%s WHERE ID=%s", GetSQLValueString($HTTP_POST_VARS['newreccount'], "int"), GetSQLValueString($HTTP_POST_VARS['ID'], "int")); mysql_select_db($database_altpanfics, $altpanfics); $Result1 = mysql_query($updateSQL, $altpanfics) or die(mysql_error()); $updateGoTo = "justRated.php"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo));}$colname_showFic = "1";if (isset($HTTP_GET_VARS['ficShowID'])) { $colname_showFic = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['ficShowID'] : addslashes($HTTP_GET_VARS['ficShowID']);}mysql_select_db($database_altpanfics, $altpanfics);$query_showFic = sprintf("SELECT * FROM Fanfiction WHERE ID = %s", $colname_showFic);$showFic = mysql_query($query_showFic, $altpanfics) or die(mysql_error());$row_showFic = mysql_fetch_assoc($showFic);$totalRows_showFic = mysql_num_rows($showFic);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22895-want-to-tweak-the-update-record-function-to-add-instead-of-replace-dwmx/ Share on other sites More sharing options...
halcyonalt Posted October 6, 2006 Author Share Posted October 6, 2006 Anybody? Please?I really can't figure out how to do this. :( Quote Link to comment https://forums.phpfreaks.com/topic/22895-want-to-tweak-the-update-record-function-to-add-instead-of-replace-dwmx/#findComment-104766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.