Emzi Posted October 3, 2007 Share Posted October 3, 2007 Hi all. I am relatively new to PHP/MySQL so forgive me if my explanation of my problem doesn't make much sense. I have a two tables in my database, one with a list of doctors, and one with a list of patients. I have created a search page on my site which lets users pick a doctor, and it will return with a list of patients that are under that doctor. I have got two links for each record, one called Edit, and one called Delete. Edit works fine but I have no idea what to do with the Delete link. I'm using Dreamweavers tools to help me with this (I know, I know...), and one of the options is Insert > Data Objects > Delete Record. Now all that gives me is a bunch of PHP code in the header, but no actual link, or button or anything for me to implement this. Does anyone know what link I should be putting into my Delete link for it to work? I'm stumped. Thanks. Here's the PHP code it gave me if it's any help: <?php require_once('../Connections/enjoydemo.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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; } } if ((isset($_POST['patient_id'])) && ($_POST['patient_id'] != "")) { $deleteSQL = sprintf("DELETE FROM patients WHERE patient_id=%s", GetSQLValueString($_POST['patient_id'], "int")); mysql_select_db($database_enjoydemo, $enjoydemo); $Result1 = mysql_query($deleteSQL, $enjoydemo) or die(mysql_error()); $deleteGoTo = "delete-success.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } ?> Link to comment https://forums.phpfreaks.com/topic/71674-solved-delete-record-via-link-on-website/ Share on other sites More sharing options...
Emzi Posted October 3, 2007 Author Share Posted October 3, 2007 Doesn't matter, I've sorted it with a little help from my partner Link to comment https://forums.phpfreaks.com/topic/71674-solved-delete-record-via-link-on-website/#findComment-360860 Share on other sites More sharing options...
fenway Posted October 3, 2007 Share Posted October 3, 2007 Doesn't matter, I've sorted it with a little help from my partner Matters to everyone else other than you... how? Link to comment https://forums.phpfreaks.com/topic/71674-solved-delete-record-via-link-on-website/#findComment-360930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.