hey guys, i'm just transferring all my code to fucntions(instead of writing 6 pages that do close to the same damn thing 🙂 ) i wrote an add_remark() function that adds remarks to the comments_calls table(comments for the current calls). i also have a call history table which is where all the deleted calls go, and a comments_calls2 table for all the deleted comments for the deleted calls. now with that said: how can i make my add_remark function be able to determine whether the user is adding a comment to a current call or a deleted call?(i also have current tasks and task history, but that can come later 🙂 ) im guessing i'd have to pass the page name, then determine what table to send it to based on that right? is there a better way. anyways, i'm looking for pointers here guys. question anything that looks funny. Thanks!
function add_remark($call_id, $remark, $importance = "0")
{
global $SID1;
$link_id = db_connect($default_dbname);
$check_query = mysql_query("SELECT CID FROM current_calls WHERE CID='$call_id'", $link_id) or die(mysql_error());
$check_num_rows = mysql_num_rows($check_query);
if ($check_num_rows > 0)
{
$unique_id = $_SESSION['comment_key'];
$unique_id = substr($unique_id, 0, 30);
$SESSION_ID = session_id();
$SESSION_ID = substr($SESSION_ID, 0, 30);
$query = mysql_query("SELECT CCID FROM comments_calls WHERE sess_id='$SESSION_ID' AND unique_id='$unique_id'", $link_id) or die(mysql_error());
$total = mysql_num_rows($query);
if ($total == 0)
{
do
{
$ccid = md5 (uniqid (rand()));
$results = mysql_query("SELECT CCID FROM comments_calls WHERE CCID='$ccid'", $link_id);
$results2 = mysql_query("SELECT CCID FROM comments_calls2 WHERE CCID='$ccid'", $link_id);
if(!$results)
{
echo "Query $query failed.";
echo mysql_error();
}
if(!$results2)
{
echo "Query $query failed.";
echo mysql_error();
}
$num_rows = mysql_num_rows($results);
$num_rows2 = mysql_num_rows($results2);
$num_rows = $num_rows + $num_rows2;
} while ($num_rows == 1);
$remark = htmlspecialchars($remark);
$comment_query = mysql_query("INSERT INTO comments_calls VALUES('$ccid', '$call_id', '$SID1', '$remark', '0', '$SESSION_ID', '$unique_id', NOW() + 0, '$importance')", $link_id) or die(mysql_error());
unset($_SESSION['comment_key']);
return TRUE;
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}