• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

Deleting a row in a My SQL table, through pressing a button - using php. How?

Hello all,

I have a  Mysql table in a database called 'favourites' which holds member (student) favourites of other members (teachers). The table consists of 3 columns - autonum (unique identifier) studentid (unique identifier for students in a seperate table) and teacherid (unique identifier for teachers in a teaching table).

I have a page where users can log into their favourites page, and the page displays details of all the users' favourite teacher profiles. Each profile on it has a button called 'remove from favourites'. What I am trying to do is allow the user to press this button and the favourites' autonum id associated with the profile would be deleted.

I have tried the following code which I hope will alllow the logged in user to remove from his/her favourites:

$sql = "DELETE FROM favourites WHERE studentid = %s"    

This line is activated by a button in a form, shown below. My guess was to use an insert behaviour to delete the row. My reasoning behind this was to do with me using the insert behaviour button to insert data. I'm guessing this might not be correct?

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "favourites"))
 {
    $sql = "DELETE FROM favourites WHERE studentid = %s";
    $result = mysql_query($sql);
 }

Anyway, thanks for reading this, and please let me know if you need more info.

Thanks.
<form id="form2" name="form2" method="post" action="">&nbsp;&nbsp;<img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
<input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
<input type="hidden" name="autonum" id="autonum" value="<?php echo $row_m['autonumber'];?>" >
 <input type="hidden" name="MM_insert" value="favourites" />
  
      </form>

Open in new window

0
ayounis
Asked:
ayounis
  • 28
  • 18
  • +1
1 Solution
 
lofCommented:
you need to get the primary key value for the record you want to delete. You probably have it already somewhere on the page and then all you are missing is to pass it to the mysql_query with the query string

$sql = "DELETE FROM favourites WHERE studentid = %s";
$result = mysql_query($sql, $id);
0
 
Ray PaseurCommented:
You need to have a form that submits the identifier to the deletion script via the POST method.  If you use the GET method, and Google searches your page, it will follow the links and your database is toast.  So be careful, and good luck with it, ~Ray
0
 
ayounisAuthor Commented:
lof, Ray, thanks for the replies.

Ray, thanks - I'll be sure to use POST (to avoid Toast).

lof, is this what you meant:  I've changed to:

$sql = "DELETE FROM favourites WHERE studentid = %s";
$result = mysql_query($sql, $autonum); ....... the primary key is autonum (from the 'favourites' table)

>>you need to get the primary key value for the record you want to delete

Is this sufficient?

$colname_favs = "-1";
if (isset($row_favs['autonum'])) {
  $colname_favs = $row_favs['autonum'];
}
mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ayounisAuthor Commented:
code
<?php require_once('../Connections/a.php'); ?>
  
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../Jsorry.htm";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "favourites"))
 {
    $sql = "DELETE FROM favourites WHERE studentid = %s";
    $result = mysql_query($sql,$autonum);
 }

$colname_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_a, $a);
$query_member = sprintf("SELECT autonum, firstname, famname, password, compemail FROM students WHERE compemail = %s", GetSQLValueString($colname_member, "text"));
$member = mysql_query($query_member, $a) or die(mysql_error());
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);

$colname_m = "-1";
if (isset($row_member['autonum'])) {
  $colname_m = $row_member['autonum'];
}
mysql_select_db($database_a, $a);
$query_m = sprintf("SELECT TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s", GetSQLValueString($colname_m, "int"));
$m = mysql_query($query_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
$totalRows_m = mysql_num_rows($m);

$colname_favs = "-1";
if (isset($row_favs['autonum'])) {
  $colname_favs = $row_favs['autonum'];
}
mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);

$maxRows_m = 22;
$pageNum_m = 0;
if (isset($_GET['pageNum_m'])) {
  $pageNum_m = $_GET['pageNum_m'];
}
$startRow_m = $pageNum_m * $maxRows_m;
 

$query_limit_m = sprintf("%s LIMIT %d, %d", $query_m, $startRow_m, $maxRows_m);
$m = mysql_query($query_limit_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
 
if (isset($_GET['totalRows_m'])) {
  $totalRows_m = $_GET['totalRows_m'];
} else {
  $all_m = mysql_query($query_m);
  $totalRows_m = mysql_num_rows($all_m);
}
$totalPages_m = ceil( ( $totalRows_m + $maxRows_m -1) / $maxRows_m);
 
$queryString_m = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_m") == false && 
        stristr($param, "totalRows_m") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_m = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_m = sprintf("&totalRows_m=%d%s", $totalRows_m, $queryString_m); 


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Open in new window

0
 
ayounisAuthor Commented:
Hello all,

I think my problem is that I don't know how to call this command line:

 $sql = "DELETE FROM favourites WHERE studentid = %s";
    $result = mysql_query($sql,$autonum);

I want to call if after a button is pressed but I'm not too sure how to. I currently have:

<form id="form2" name="form2" method="post" action="  ">
        &nbsp;&nbsp;<img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
        <input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
 </form>

But don't think that's the correct code.

I'll move this up to 190 (sorry, only have 40 points left)

Thanks
0
 
Jason C. LevineNo oneCommented:
Hi ayounis,

Ray's comments are exactly correct, but there is a Dreamweaver way to do this.

First, you need to put the TEACHER id in the form as a hidden field, not the Student ID.  If you pass the student ID to the delete query, any click will delete all rows for that student, not merely the teacher whose button was clicked.  If your intention is to clear all selections for the student, then use the Student ID.

So the form will look something like this:

<form id="form2" name="form2" method="post" action="deleteme.php">
   <img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
   <input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
   <input type="hidden" name="deleteteacher" value="<?php echo $row_favs['teacherid']; ?>" />
 </form>

Notice that I have set the action to a new page, called deleteme.php.  You can set the delete behavior on the same page if you wish, but for tutoring/testing purposes it may be easier to have it on its own page.

Anyway, this form should be placed inside of the repeating region for the favorites list so it generates a new instance for each teacher in the favourites table.  Submitting the form will take the user to the deleteme.php page and on that page, all you need to do is apply the built-in Delete Record behavior and set it to delete on the favourites table, first checking to see if Form Variable "deleteteacher" is defined, and set the Primary Key Column to teacherid (I know it's not the Primary Key, but DW actually doesn't care...the language in the Wizard is wrong) and the set the Primary Key Value (again, we know it's not the real PK) to filtering on teacherid equal to Form Variable "deleteteacher"

The just set the redirect to go back to the favourites page.  Your code on deleteme.php should look like this:
<?php require_once('../Connections/a.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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['deleteteacher'])) && ($_POST['deleteteacher'] != "") && (isset($_POST['deleteteacher']))) {
  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s",
                       GetSQLValueString($_POST['deleteteacher'], "int"));

  mysql_select_db($database_a, $a);
  $Result1 = mysql_query($deleteSQL, $a) or die(mysql_error());

  $deleteGoTo = "originalpage.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
?>

Open in new window

0
 
ayounisAuthor Commented:
Hi jason1178,

Thanks for that. It makes sense to me. I've followed your instructions but what seems to happen is that on pressing the icon, it goes to deleteme.php but does not automtically redirect back to myfavs2.php (I set it to redirect in the wizard and this is represented in the code:
$deleteGoTo = "Myfavs2.php";

Also, when I then navigate to myfavs2.php (by typing in the URL) the teacher profile is still there.

I tried this using the wizard and then using your code directly (renaming the redirect location) but on both times the result was the same.

I noticed the dreamweaver (CS3) code didn't produce the line:
if (PHP_VERSION < 6) {

Thanks for the help.
<?php require_once('../../Connections/a.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($_GET['deleteteacher'])) && ($_GET['deleteteacher'] != "") && (isset($_POST['deleteteacher']))) {
  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s",
                       GetSQLValueString($_GET['deleteteacher'], "int"));

  mysql_select_db($database_a, $a);
  $Result1 = mysql_query($deleteSQL, $a) or die(mysql_error());

  $deleteGoTo = "Myfavs2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

Open in new window

0
 
Jason C. LevineNo oneCommented:
Okay, two things.

One, I was half-right about the variables to pass.  You need both the student ID and the teacher ID passed to deleteme.php because otherwise the script will delete all of one student's preferences or every instance of one teacher from all students.  Neither is what you want.  So the form needs to look like this:

<form id="form2" name="form2" method="post" action="deleteme.php">
   <img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
   <input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
   <input type="hidden" name="deleteteacher" value="<?php echo $row_favs['teacherid']; ?>" />
  <input type="hidden" name="deletestudent" value="<?php echo $row_favs['studentid']; ?>" />
 </form>

Two, your code above is looking for $_GET variables which is why nothing is working, including the redirect:

if ((isset($_GET['deleteteacher'])) && ($_GET['deleteteacher'] != "") && (isset($_POST['deleteteacher']))) {

Change the form on Myfavs2.php as I indicate above and change the if statement above to:

if ((isset($_POST['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "") {

  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s", GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));

That code should delete the single teacher selected from the single student's favorites list.
0
 
ayounisAuthor Commented:
Thanks,

I'm getting:

Parse error: syntax error, unexpected '{' in /home/cjpqapym/public_html/orangutanjapan/MemberProfiles/deleteme.php on line 32

Line 31 to line 34 below.

Playing around with it now...



if ((isset($_POST['deleteteacher'])) && ($_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "") {
  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s",
                       GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));

Open in new window

0
 
ayounisAuthor Commented:
Changed that to (added extra ')'  ):

if ((isset($_POST['deleteteacher']) && $_POST['deleteteacher']!="") && (isset($_POST['deletestudent']) && $_POST['deletestudent']!="")) {

  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s", GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));


Error gone but it seems to stay at deleteme.php still.....
0
 
Jason C. LevineNo oneCommented:
I must have goofed the parentheses.  Try:

if (isset($_POST['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "") {

0
 
ayounisAuthor Commented:
It's not liking that:

Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/cjpqapym/public_html/orangutanjapan/MemberProfiles/deleteme.php on line 31
<?php require_once('../../Connections/a.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['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "") {

  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s", GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));

  mysql_select_db($database_a, $a);
  $Result1 = mysql_query($deleteSQL, $a) or die(mysql_error());

  $deleteGoTo = "Myfavs2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ....

Open in new window

0
 
Jason C. LevineNo oneCommented:
if ((isset($_POST['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "")) {
0
 
Jason C. LevineNo oneCommented:
IOW, the way you had it :)
0
 
ayounisAuthor Commented:
Gah - I think I've tried that before; the error looks familiar:

Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/cjpqapym/public_html/orangutanjapan/MemberProfiles/deleteme.php on line 31
0
 
ayounisAuthor Commented:
I'll put the whole code below in case I'm missing something obvious. Quite likely...
<?php require_once('../../Connections/a.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['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "")) {

  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s", GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));

  mysql_select_db($database_a, $a);
  $Result1 = mysql_query($deleteSQL, $a) or die(mysql_error());

  $deleteGoTo = "Myfavs2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

Open in new window

0
 
Jason C. LevineNo oneCommented:
Let's simplify it.

if (isset($_POST['deleteteacher']) && isset($_POST['deletestudent'])) {

0
 
ayounisAuthor Commented:
Okay the code below seems to do something and refresh but the profile from which the delete button was clicked remains...

if (isset($_POST['deleteteacher']) && isset($_POST['deletestudent'])) {

$deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s", GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));
0
 
ayounisAuthor Commented:
I've went back to the original code you posted for this and replaced the line in question with the code on 26288733. Now no error message but it just stays on deleteme.php

I tried using the simplified line again, but what seems to happen is the same as above, with the profile not deletin (but refreshing, or at least doing something....)

0
 
Jason C. LevineNo oneCommented:
Okay, can I see your form code from MyFavs too?  Need to make sure we are picking up all of the hidden fields properly.
0
 
ayounisAuthor Commented:
Erm....I just spotted this (code below) in there. Do I need that still. I can't see why?

I quickly removed it and tested, but it didn't seem to help...


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "favourites"))
 {
    $sql = "DELETE FROM favourites WHERE studentid = %s";
    $result = mysql_query($sql,$autonum);
 }
<?php require_once('../Connections/a.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../Jsorry.htm";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "favourites"))
 {
    $sql = "DELETE FROM favourites WHERE studentid = %s";
    $result = mysql_query($sql,$autonum);
 }

$colname_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_a, $a);
$query_member = sprintf("SELECT autonum, firstname, famname, password, compemail FROM students WHERE compemail = %s", GetSQLValueString($colname_member, "text"));
$member = mysql_query($query_member, $a) or die(mysql_error());
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);

$colname_m = "-1";
if (isset($row_member['autonum'])) {
  $colname_m = $row_member['autonum'];
}
mysql_select_db($database_a, $a);
$query_m = sprintf("SELECT TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s", GetSQLValueString($colname_m, "int"));
$m = mysql_query($query_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
$totalRows_m = mysql_num_rows($m);

$colname_favs = "-1";
if (isset($row_favs['autonum'])) {
  $colname_favs = $row_favs['autonum'];
}
mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);

$maxRows_m = 22;
$pageNum_m = 0;
if (isset($_GET['pageNum_m'])) {
  $pageNum_m = $_GET['pageNum_m'];
}
$startRow_m = $pageNum_m * $maxRows_m;
 

$query_limit_m = sprintf("%s LIMIT %d, %d", $query_m, $startRow_m, $maxRows_m);
$m = mysql_query($query_limit_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
 
if (isset($_GET['totalRows_m'])) {
  $totalRows_m = $_GET['totalRows_m'];
} else {
  $all_m = mysql_query($query_m);
  $totalRows_m = mysql_num_rows($all_m);
}
$totalPages_m = ceil( ( $totalRows_m + $maxRows_m -1) / $maxRows_m);
 
$queryString_m = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_m") == false && 
        stristr($param, "totalRows_m") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_m = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_m = sprintf("&totalRows_m=%d%s", $totalRows_m, $queryString_m); 


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Open in new window

0
 
ayounisAuthor Commented:
Okay, I think I was looking at the wrong page there....
<?php require_once('../Connections/a.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../Jsorry.htm";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


$colname_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_a, $a);
$query_member = sprintf("SELECT autonum, firstname, famname, password, compemail FROM students WHERE compemail = %s", GetSQLValueString($colname_member, "text"));
$member = mysql_query($query_member, $a) or die(mysql_error());
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);

$colname_m = "-1";
if (isset($row_member['autonum'])) {
  $colname_m = $row_member['autonum'];
}
mysql_select_db($database_a, $a);
$query_m = sprintf("SELECT TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s", GetSQLValueString($colname_m, "int"));
$m = mysql_query($query_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
$totalRows_m = mysql_num_rows($m);

$colname_favs = "-1";
if (isset($row_favs['autonum'])) {
  $colname_favs = $row_favs['autonum'];
}
mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);

$maxRows_m = 22;
$pageNum_m = 0;
if (isset($_GET['pageNum_m'])) {
  $pageNum_m = $_GET['pageNum_m'];
}
$startRow_m = $pageNum_m * $maxRows_m;
 

$query_limit_m = sprintf("%s LIMIT %d, %d", $query_m, $startRow_m, $maxRows_m);
$m = mysql_query($query_limit_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
 
if (isset($_GET['totalRows_m'])) {
  $totalRows_m = $_GET['totalRows_m'];
} else {
  $all_m = mysql_query($query_m);
  $totalRows_m = mysql_num_rows($all_m);
}
$totalPages_m = ceil( ( $totalRows_m + $maxRows_m -1) / $maxRows_m);
 
$queryString_m = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_m") == false && 
        stristr($param, "totalRows_m") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_m = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_m = sprintf("&totalRows_m=%d%s", $totalRows_m, $queryString_m); 


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<style type="text/css">
	* {
		margin:0;
		padding:0;
	}
 
	#container {
	width: 940px;
	border:1px solid #FF6600;
	background-color: #FFFFFF;
	height: 3500px;
	margin-top: 0;
	margin-right: auto;
	margin-bottom: 0;
	margin-left: auto;
	font-family: Arial, Helvetica, sans-serif;
	}
	
	#header {
	height:120px;
	background-color:#FF6600;
	background-image: url(../2010BannerVersion_members.gif);
	}
	
	#header2 {
	height:8px;
	background-color:#FFFFFF;
	padding:10px;
	}
	
	#sidebar {
	background-color:#FFFFFF;
	width:160px;
	border: 1px solid #FF6600;
	float:left;
	margin:8px;
	height: 400px;
	padding: 0px;
	}
	
	#newheader {
	border: 1px solid #FF6600;
	height:100px;
	width:721px;
	float:right;
	padding-top: 10px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
	margin-top: 8px;
	margin-right: 26px;
	margin-bottom: 8px;
	margin-left: 1px;
	}
	
	#content {
	border: 0px solid #FF9900;
	width:760px;
	float:right;
	margin-top: 5px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 0px;
	padding-top: 5px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
	background-color: #FFFFFF;
	}
	
	#profilebox {
	color: #000000;
	background-color: #FFFFFF;
	border: 1px solid #FF9900;
	height: 250px;
	width: 350px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 375px;
	padding: 0px;
	position: absolute;
	bottom: 2919px;
	left: 32px;
}
	
	.profileboxtest {
	border: 1px solid #FF9900;
	height: 250px;
	width: 350px;
	left: 191px;
	top: 435px;
	position: absolute;
}
.boxtext {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bolder;
	line-height: 20px;
	clear: both;
	margin-bottom: 100px;
	padding-bottom: 100px;
	margin-top: 2px;
	padding-top: 2px;
	height: 68px;
	position: absolute;
	width: 175px;
}

.imageclass {
	border: 1px solid #FF6600;
	margin-top: 7px;
	margin-left: 10px;
}
 
.profilebox{
	border: 1px solid #FF9900;
	height: 250px;
	width: 350px;
	float: left;
	margin-top: 14px;
	margin-right: 10px;
	margin-bottom: 14px;
	margin-left: 10px;
}
 
.profileheader {
	background-color: #FFD08A;
	height: 50px;
	border-bottom-style: dotted;
	border-bottom-color: #FF6600;
	border-bottom-width: 1px;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	color: #FFFFFF;
	font-weight: bold;
	vertical-align: text-top;
}
.smallheader {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #FF3300;
	margin: 0px;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 5px;
	float: none;
}
.largeheader {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: bold;
	padding-left: 5px;
}
.profileimage {
	border: 1px solid #FF6600;
	padding: 1px;
	margin-top: 10px;
	margin-left: 10px;
}

.flag {
	float: right;
	height: 33px;
	width: 46px;
	border-top-color: #FFD08A;
	border-right-color: #FFD08A;
	border-bottom-color: #FFD08A;
	border-left-color: #FFD08A;
	bottom: 34px;
	position: relative;
	right: 3px;
	clear: both;
}

#apDiv4 {
	left:787px;
	top:140px;
	width:200px;
	height:60px;
	z-index:1;
	float: right;
	border: 1px solid #CCCCCC;
	background-color: #FFFFFF;
	background-image: url(../newsearch/searchagain.jpg);
	margin-right: 10px;
}

#apDiv3 {
	left:310px;
	top:30px;
	width:46px;
	height:33px;
	z-index:1;
	float: right;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	padding: 0px;
	margin-right: 5px;
	margin-top: 3px;
}
.logouttext {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	float: right;
	margin-right: 15px;
	clip: rect(auto,auto,auto,auto);
}

#apDiv2 {
	left:236px;
	top:149px;
	width:450px;
	height:50px;
	z-index:1;
	float: left;
	background-color: #FFFFFF;
	padding-right: 5px;
	padding-left: 5px;
}

#apDiv1 {
	float:right;
	left:229px;
	top:215px;
	width:721px;
	height:24px;
	z-index:1;
	background-color: #FFD08A;
	display: table-row-group;
	margin-top: 14px;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	border-top-color: #FF6600;
	border-right-color: #FF6600;
	border-bottom-color: #FF6600;
	border-left-color: #FF6600;
}


.icons {
}
body {
	background-image: url(../newsearch/background.gif);
	background-repeat: repeat-x;
}

#footersearch {
	width: 733px;
	height: 30px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-bottom-style: solid;
	border-right-color: #CCCCCC;
	border-bottom-color: #FF9900;
	border-left-color: #CCCCCC;
	margin-left: 5px;
	padding: 0px;
	margin-top: 20px;
	color: #FF6600;
	background-color: #FFD08A;
	background-position: center center;
	vertical-align: middle;
	text-align: center;
	line-height: 10px;
	margin-right: 5px;
}
.footersearch {
	font-size: 12px;
	color: #FF6600;
	clip: rect(auto,auto,auto,auto);
	background-position: center center;
	line-height: 10px;


.style1 {font-family: "MS Gothic"}
.style2 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 36px;
	color: #000000;
}

.style4 {font-size: 12px; color: #000000; clip: rect(auto,auto,auto,auto); background-position: center center; line-height: 10px; }
.style6 {
	font-size: 12px;
	font-weight: bold;
	color: #000000;
}
.style10 {font-weight: bold}
#apDiv4 {
	left:787px;
	top:140px;
	width:150px;
	height:29px;
	z-index:1;
	float: right;
	border: 1px groove #FFCC00;
}
.style11 {color: #000000}
.style12 {color: #FF6600}
.flagposition {
	margin-top: 2px;
	margin-right: 2px;
	padding-top: 2px;
	padding-right: 2px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
<!--
.style14 {color: #666666}
.style15 {color: #FF0000}
.sidemenu {	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #333333;
	border-bottom-width: 1px;
	border-bottom-style: dotted;
	border-bottom-color: #FFD08A;
	line-height: 20px;
	padding-left: 10px;
}
a:link {
	color: #333333;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #333333;
}
a:hover {
	text-decoration: none;
	color: #333333;
}
a:active {
	text-decoration: none;
	color: #333333;
}
-->
</style>
</head>
 
<body>





<div id="container">
<div id="header">
     <h1 class="style2">&nbsp;</h1>
</div>

<div id="header2">
     <h1 class="logouttext"><a href="<?php echo $logoutAction ?>">LOGOUT <strong><?php echo $row_member['firstname']; ?></strong></a></h1>
</div>
	
<div id="sidebar">
  <table width="159" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="159" class="sidemenu">Members Home</td>
    </tr>
    <tr>
      <td class="sidemenu">&nbsp;</td>
    </tr>
    <tr>
      <td class="sidemenu">Basic Search</td>
    </tr>
    <tr>
      <td class="sidemenu">Detailed Search</td>
    </tr>
    <tr>
      <td class="sidemenu">My Favourites</td>
    </tr>
    <tr>
      <td class="sidemenu">Multimedia</td>
    </tr>
    <tr>
      <td class="sidemenu">Customer Feedback</td>
    </tr>
    <tr>
      <td class="sidemenu">SiteMap</td>
    </tr>
    <tr>
      <td class="sidemenu">Video Profiles</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
</div>
 
<div id="newheader">
<div id="apDiv4"></div>
<div id="apDiv2"><span class="footersearch"><span class="style11"><strong>WELCOME <?php echo $row_member['firstname']; ?>..</strong>.We found these teachers who match your search criteria.Click on the teacher's photo to view their profile..</span></span><span class="style6">.</span><br />
  <br />
  <form id="form1" name="form1" method="post" action="">
    <label><span class="smallheader">List teachers by<strong>...</strong></span>
    <select name="listby" class="style4" id="listby">
      <option value="Original">Original order</option>
      <option value="Date">Date added</option>
      <option value="Price">Price (cheapest first)</option>
      <option value="Teaching Experience">Teaching Experience</option>
      </select>
      </label>
    <span class="smallheader">photos only</span> 
    <label>
    <input type="checkbox" name="photos" id="photos" />
    </label>
  </form>
  </div>
  <div class="footersearch" id="apDiv1">
    <table border="0">
      <tr>
        <td width="71"><div align="center">
            <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, 0, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OFirst.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
        </div></td>
        <td width="76"><div align="center">
            <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, max(0, $pageNum_m - 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OPrevious.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
        </div></td>
        <td width="440" align="right" valign="middle">&nbsp;
            Teacher <em><?php echo ($startRow_m + 1) ?></em> to <em><?php echo min($startRow_m + $maxRows_m, $totalRows_m) ?></em> of <span class="style10"><?php echo $totalRows_m ?></span> </td>
        <td width="57"><div align="center">
            <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, min($totalPages_m, $pageNum_m + 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/ONext.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
        </div></td>
        <td width="67"><div align="center">
            <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, $totalPages_m, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OLast.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
        </div></td>
      </tr>
    </table>
  </div>
  </div>
 
<div id="content">
  <?php do { ?>
  <div class="profilebox">
  <div class="profileheader"><div id="apDiv3">
    <div align="left"><img src="http://www.orangutanjapan.com/newsearch/flags/<?php echo $row_m['nationality'] ?>flag.gif" alt="teacher's nationality" width="46" height="33" class="flagposition" /></div>
  </div>
  <span class="largeheader"></span><?php echo $row_m['firstname']; ?><br />
    <span class="smallheader">Profile added / updated:
    <span class="style12"><?php echo $row_m['date']; ?></span></span>    </div>
  <a href="../newsearch/details10test.php?pageNum_m=<?php echo $_GET['pageNum_m']; ?>&amp;language=<?php echo $_GET['language'] ?>&amp;prefecture=<?php echo $_GET['prefecture'] ?>&amp;recordID=<?php echo $row_m['autonumber']; ?>&amp;"><img src="http://orangutanenglish.com/upload/<?php echo $row_m['photoid']; ?>" width="136" height="116" class="imageclass" /></a><span class="boxtext">&nbsp;<span class="style14">&nbsp;Nationality:</span>&nbsp; <?php echo $row_m['nationality']; ?><br />
  <span class="AccordionPanelTabHover">&nbsp;&nbsp;<span class="style14">Language:</span></span> &nbsp;&nbsp;<?php echo $row_m['language']; ?><br />
  &nbsp;<span class="style14">&nbsp;Teach Ex: </span>&nbsp;&nbsp;&nbsp;<?php echo $row_m['teachingexperience']; ?><br />
  <span class="style14">&nbsp;&nbsp;Prefecture:</span> <?php echo $row_m['prefecture']; ?><br />
  <span class="style15">&nbsp;&nbsp;<br />
  &nbsp;&nbsp;<? $img1=($row_m['vid'])? "<img src=\"videoimage.gif\" alt=\"This teacher has video in their profile\" width=\"41\" height=\"20\" />" : "";  echo $img1; ?></span><br />
  </span>
  <p align="left">&nbsp;
    &nbsp;&nbsp;&nbsp;</p>
  <table width="334" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="132" height="33"><form id="form2" name="form2" method="post" action="deleteme.php">
<img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
<input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
<input type="hidden" name="deleteteacher" value="<?php echo $row_favs['teacherid']; ?>" />
<input type="hidden" name="deletestudent" value="<?php echo $row_favs['studentid']; ?>" />
 </form>    
      </td>
      
      <td width="202"><div align="right">
        <?php
$DbImg = $row_m['expconfirm'] ;
if ($DbImg =="expconfirm") {  
    $altText = "Exp confirmation";
}
else {
   $altText = "No Exp confirmation";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /><?php
$DbImg = $row_m['teflconfirm'] ;
if ($DbImg =="teflconfirm") {  
    $altText = "Tefl confirmation";
}
else {
   $altText = "No Tefl confirmation";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /><?php
$DbImg = $row_m['degreeconfirm'] ;
if ($DbImg =="degreeconfirm") {  
    $altText = "Degree confirmation";
}
else {
   $altText = "No Degree confirmation";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /> </div></td>
    </tr>
  </table>
  <p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
  </div>
 
    
  	<?php } while ($row_m = mysql_fetch_assoc($m)); ?>
  	<br style="clear:both;" />
  <div class="footersearch" id="footersearch">
      <div align="center">
  <table border="0">
    <tr>
      <td width="71"><div align="center">
        <?php if ($pageNum_m > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, 0, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OFirst.gif" border="0" class="footersearch" /></a>
          <?php } // Show if not first page ?>
        </div></td>
        
        
        <td width="76"><div align="center">
          <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, max(0, $pageNum_m - 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OPrevious.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
          </div></td>
        <td width="440" align="center" valign="middle">&nbsp;          <div align="center">Teacher <em><?php echo ($startRow_m + 1) ?></em> to <em><?php echo min($startRow_m + $maxRows_m, $totalRows_m) ?></em> of <span class="style10"><?php echo $totalRows_m ?></span> </div></td>
        <td width="57" align="center" valign="middle"><div align="center">
          <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, min($totalPages_m, $pageNum_m + 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/ONext.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
          </div></td>
          
          
        <td width="67"><div align="center">
          <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, $totalPages_m, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OLast.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
          </div></td>
          
          
      </tr>
  </table>
  <br />
        <br />
      </div>
  	</div>
  </div>
  <div id="sidebox"></div>
</div>

</body>
 
</html>
<?php
mysql_free_result($member);

mysql_free_result($m);

mysql_free_result($favs);
?>

Open in new window

0
 
ayounisAuthor Commented:
mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);

I need to select teacherid FROM the table as well don't I?

I'll try this and post back....
0
 
ayounisAuthor Commented:
I guess not....

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/cjpqapym/public_html/orangutanjapan/MemberProfiles/Myfavs2.php on line 133
0
 
Jason C. LevineNo oneCommented:
>> I need to select teacherid FROM the table as well don't I?

Yes, you do.  Both teacherID and studentID must be present in the recordset for the echo to the form to work.  If not, the deletion won't fire.

You're getting that error because the parameters are wrong:

$colname_favs = "-1";
if (isset($row_favs['autonum'])) {
  $colname_favs = $row_favs['autonum'];
}
mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs)

So you are attempting to filter the recordset favs using data from the recordset favs.  How is it supposed to filter on itself?  It's a circular query...won't work.

Should be:

$colname_favs = "-1";
if (isset($row_member['autonum'])) {
  $colname_favs = $row_member['autonum'];
}






0
 
ayounisAuthor Commented:

Okay, we're getting there. I've added a few more points because this is not really as simple  a post as I first thought (it never is) it might be. What seems to be happening now is that a teacher profile is being deleted from the favourites table, however it's not the one associated with the teacher profile of which the remove button is pressed, rather it's just the teacher at the top of the favourites list.

So I'm guessing this is because the teacherid isn't getting passed throught properly somehow?

I tried with the full code:

if ((isset($_POST['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "")) {
  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s",
                       GetSQLValueString($_POST['deleteteacher'], "int"));

And the simplified line:

if (isset($_POST['deleteteacher']) && isset($_POST['deletestudent'])) {
etc.
0
 
Jason C. LevineNo oneCommented:
>> I'm guessing this is because the teacherid isn't getting passed throught properly somehow?

Yes.  When you reverted to the older code, you got rid of the WHERE statement.  You have:

  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s",

You need:

$deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s",
                       GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));
0
 
ayounisAuthor Commented:
Eeek, I think it's post code time again.

Current code below - It's still deleting from the top of the list :(......

Quick cup of tea,  methinks....
<?php require_once('../Connections/a.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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['deleteteacher']) && $_POST['deleteteacher'] != "") && (isset($_POST['deletestudent']) && $_POST['deletestudent'] != "")) {
  $deleteSQL = sprintf("DELETE FROM favourites WHERE teacherid=%s AND studentid=%s",
                       GetSQLValueString($_POST['deleteteacher'], "int"), GetSQLValueString($_POST['deletestudent'], "int"));

  mysql_select_db($database_a, $a);
  $Result1 = mysql_query($deleteSQL, $a) or die(mysql_error());

  $deleteGoTo = "Myfavs2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
?>

Open in new window

0
 
Jason C. LevineNo oneCommented:
Okay, now need to see the code from the favorites page to make sure you are passing the values properly.
0
 
ayounisAuthor Commented:
Here it s
<?php require_once('../Connections/a.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../Jsorry.htm";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


$colname_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_a, $a);
$query_member = sprintf("SELECT autonum, firstname, famname, password, compemail FROM students WHERE compemail = %s", GetSQLValueString($colname_member, "text"));
$member = mysql_query($query_member, $a) or die(mysql_error());
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);

$colname_m = "-1";
if (isset($row_member['autonum'])) {
  $colname_m = $row_member['autonum'];
}
mysql_select_db($database_a, $a);
$query_m = sprintf("SELECT TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s", GetSQLValueString($colname_m, "int"));
$m = mysql_query($query_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
$totalRows_m = mysql_num_rows($m);

$colname_favs = "-1";
if (isset($row_member['autonum'])) {
  $colname_favs = $row_member['autonum'];
}

mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, teacherid, studentid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);

$maxRows_m = 22;
$pageNum_m = 0;
if (isset($_GET['pageNum_m'])) {
  $pageNum_m = $_GET['pageNum_m'];
}
$startRow_m = $pageNum_m * $maxRows_m;
 

$query_limit_m = sprintf("%s LIMIT %d, %d", $query_m, $startRow_m, $maxRows_m);
$m = mysql_query($query_limit_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
 
if (isset($_GET['totalRows_m'])) {
  $totalRows_m = $_GET['totalRows_m'];
} else {
  $all_m = mysql_query($query_m);
  $totalRows_m = mysql_num_rows($all_m);
}
$totalPages_m = ceil( ( $totalRows_m + $maxRows_m -1) / $maxRows_m);
 
$queryString_m = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_m") == false && 
        stristr($param, "totalRows_m") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_m = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_m = sprintf("&totalRows_m=%d%s", $totalRows_m, $queryString_m); 


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<style type="text/css">
	* {
		margin:0;
		padding:0;
	}
 
	#container {
	width: 940px;
	border:1px solid #FF6600;
	background-color: #FFFFFF;
	height: 3500px;
	margin-top: 0;
	margin-right: auto;
	margin-bottom: 0;
	margin-left: auto;
	font-family: Arial, Helvetica, sans-serif;
	}
	
	#header {
	height:120px;
	background-color:#FF6600;
	background-image: url(../2010BannerVersion_members.gif);
	}
	
	#header2 {
	height:8px;
	background-color:#FFFFFF;
	padding:10px;
	}
	
	#sidebar {
	background-color:#FFFFFF;
	width:160px;
	border: 1px solid #FF6600;
	float:left;
	margin:8px;
	height: 400px;
	padding: 0px;
	}
	
	#newheader {
	border: 1px solid #FF6600;
	height:100px;
	width:721px;
	float:right;
	padding-top: 10px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
	margin-top: 8px;
	margin-right: 26px;
	margin-bottom: 8px;
	margin-left: 1px;
	}
	
	#content {
	border: 0px solid #FF9900;
	width:760px;
	float:right;
	margin-top: 5px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 0px;
	padding-top: 5px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
	background-color: #FFFFFF;
	}
	
	#profilebox {
	color: #000000;
	background-color: #FFFFFF;
	border: 1px solid #FF9900;
	height: 250px;
	width: 350px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	margin-left: 375px;
	padding: 0px;
	position: absolute;
	bottom: 2919px;
	left: 32px;
}
	
	.profileboxtest {
	border: 1px solid #FF9900;
	height: 250px;
	width: 350px;
	left: 191px;
	top: 435px;
	position: absolute;
}
.boxtext {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bolder;
	line-height: 20px;
	clear: both;
	margin-bottom: 100px;
	padding-bottom: 100px;
	margin-top: 2px;
	padding-top: 2px;
	height: 68px;
	position: absolute;
	width: 175px;
}

.imageclass {
	border: 1px solid #FF6600;
	margin-top: 7px;
	margin-left: 10px;
}
 
.profilebox{
	border: 1px solid #FF9900;
	height: 250px;
	width: 350px;
	float: left;
	margin-top: 14px;
	margin-right: 10px;
	margin-bottom: 14px;
	margin-left: 10px;
}
 
.profileheader {
	background-color: #FFD08A;
	height: 50px;
	border-bottom-style: dotted;
	border-bottom-color: #FF6600;
	border-bottom-width: 1px;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	color: #FFFFFF;
	font-weight: bold;
	vertical-align: text-top;
}
.smallheader {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #FF3300;
	margin: 0px;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 5px;
	float: none;
}
.largeheader {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: bold;
	padding-left: 5px;
}
.profileimage {
	border: 1px solid #FF6600;
	padding: 1px;
	margin-top: 10px;
	margin-left: 10px;
}

.flag {
	float: right;
	height: 33px;
	width: 46px;
	border-top-color: #FFD08A;
	border-right-color: #FFD08A;
	border-bottom-color: #FFD08A;
	border-left-color: #FFD08A;
	bottom: 34px;
	position: relative;
	right: 3px;
	clear: both;
}

#apDiv4 {
	left:787px;
	top:140px;
	width:200px;
	height:60px;
	z-index:1;
	float: right;
	border: 1px solid #CCCCCC;
	background-color: #FFFFFF;
	background-image: url(../newsearch/searchagain.jpg);
	margin-right: 10px;
}

#apDiv3 {
	left:310px;
	top:30px;
	width:46px;
	height:33px;
	z-index:1;
	float: right;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	padding: 0px;
	margin-right: 5px;
	margin-top: 3px;
}
.logouttext {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	float: right;
	margin-right: 15px;
	clip: rect(auto,auto,auto,auto);
}

#apDiv2 {
	left:236px;
	top:149px;
	width:450px;
	height:50px;
	z-index:1;
	float: left;
	background-color: #FFFFFF;
	padding-right: 5px;
	padding-left: 5px;
}

#apDiv1 {
	float:right;
	left:229px;
	top:215px;
	width:721px;
	height:24px;
	z-index:1;
	background-color: #FFD08A;
	display: table-row-group;
	margin-top: 14px;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	border-top-color: #FF6600;
	border-right-color: #FF6600;
	border-bottom-color: #FF6600;
	border-left-color: #FF6600;
}


.icons {
}
body {
	background-image: url(../newsearch/background.gif);
	background-repeat: repeat-x;
}

#footersearch {
	width: 733px;
	height: 30px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-bottom-style: solid;
	border-right-color: #CCCCCC;
	border-bottom-color: #FF9900;
	border-left-color: #CCCCCC;
	margin-left: 5px;
	padding: 0px;
	margin-top: 20px;
	color: #FF6600;
	background-color: #FFD08A;
	background-position: center center;
	vertical-align: middle;
	text-align: center;
	line-height: 10px;
	margin-right: 5px;
}
.footersearch {
	font-size: 12px;
	color: #FF6600;
	clip: rect(auto,auto,auto,auto);
	background-position: center center;
	line-height: 10px;


.style1 {font-family: "MS Gothic"}
.style2 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 36px;
	color: #000000;
}

.style4 {font-size: 12px; color: #000000; clip: rect(auto,auto,auto,auto); background-position: center center; line-height: 10px; }
.style6 {
	font-size: 12px;
	font-weight: bold;
	color: #000000;
}
.style10 {font-weight: bold}
#apDiv4 {
	left:787px;
	top:140px;
	width:150px;
	height:29px;
	z-index:1;
	float: right;
	border: 1px groove #FFCC00;
}
.style11 {color: #000000}
.style12 {color: #FF6600}
.flagposition {
	margin-top: 2px;
	margin-right: 2px;
	padding-top: 2px;
	padding-right: 2px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
<!--
.style14 {color: #666666}
.style15 {color: #FF0000}
.sidemenu {	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	color: #333333;
	border-bottom-width: 1px;
	border-bottom-style: dotted;
	border-bottom-color: #FFD08A;
	line-height: 20px;
	padding-left: 10px;
}
a:link {
	color: #333333;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #333333;
}
a:hover {
	text-decoration: none;
	color: #333333;
}
a:active {
	text-decoration: none;
	color: #333333;
}
-->
</style>
</head>
 
<body>





<div id="container">
<div id="header">
     <h1 class="style2">&nbsp;</h1>
</div>

<div id="header2">
     <h1 class="logouttext"><a href="<?php echo $logoutAction ?>">LOGOUT <strong><?php echo $row_member['firstname']; ?></strong></a></h1>
</div>
	
<div id="sidebar">
  <table width="159" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="159" class="sidemenu">Members Home</td>
    </tr>
    <tr>
      <td class="sidemenu">&nbsp;</td>
    </tr>
    <tr>
      <td class="sidemenu">Basic Search</td>
    </tr>
    <tr>
      <td class="sidemenu">Detailed Search</td>
    </tr>
    <tr>
      <td class="sidemenu">My Favourites</td>
    </tr>
    <tr>
      <td class="sidemenu">Multimedia</td>
    </tr>
    <tr>
      <td class="sidemenu">Customer Feedback</td>
    </tr>
    <tr>
      <td class="sidemenu">SiteMap</td>
    </tr>
    <tr>
      <td class="sidemenu">Video Profiles</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
</div>
 
<div id="newheader">
<div id="apDiv4"></div>
<div id="apDiv2"><span class="footersearch"><span class="style11"><strong>WELCOME <?php echo $row_member['firstname']; ?>..</strong>.We found these teachers who match your search criteria.Click on the teacher's photo to view their profile..</span></span><span class="style6">.</span><br />
  <br />
  <form id="form1" name="form1" method="post" action="">
    <label><span class="smallheader">List teachers by<strong>...</strong></span>
    <select name="listby" class="style4" id="listby">
      <option value="Original">Original order</option>
      <option value="Date">Date added</option>
      <option value="Price">Price (cheapest first)</option>
      <option value="Teaching Experience">Teaching Experience</option>
      </select>
      </label>
    <span class="smallheader">photos only</span> 
    <label>
    <input type="checkbox" name="photos" id="photos" />
    </label>
  </form>
  </div>
  <div class="footersearch" id="apDiv1">
    <table border="0">
      <tr>
        <td width="71"><div align="center">
            <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, 0, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OFirst.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
        </div></td>
        <td width="76"><div align="center">
            <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, max(0, $pageNum_m - 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OPrevious.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
        </div></td>
        <td width="440" align="right" valign="middle">&nbsp;
            Teacher <em><?php echo ($startRow_m + 1) ?></em> to <em><?php echo min($startRow_m + $maxRows_m, $totalRows_m) ?></em> of <span class="style10"><?php echo $totalRows_m ?></span> </td>
        <td width="57"><div align="center">
            <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, min($totalPages_m, $pageNum_m + 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/ONext.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
        </div></td>
        <td width="67"><div align="center">
            <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, $totalPages_m, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OLast.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
        </div></td>
      </tr>
    </table>
  </div>
  </div>
 
<div id="content">
  <?php do { ?>
  <div class="profilebox">
  <div class="profileheader"><div id="apDiv3">
    <div align="left"><img src="http://www.orangutanjapan.com/newsearch/flags/<?php echo $row_m['nationality'] ?>flag.gif" alt="teacher's nationality" width="46" height="33" class="flagposition" /></div>
  </div>
  <span class="largeheader"></span><?php echo $row_m['firstname']; ?><br />
    <span class="smallheader">Profile added / updated:
    <span class="style12"><?php echo $row_m['date']; ?></span></span>    </div>
  <a href="../newsearch/details10test.php?pageNum_m=<?php echo $_GET['pageNum_m']; ?>&amp;language=<?php echo $_GET['language'] ?>&amp;prefecture=<?php echo $_GET['prefecture'] ?>&amp;recordID=<?php echo $row_m['autonumber']; ?>&amp;"><img src="http://orangutanenglish.com/upload/<?php echo $row_m['photoid']; ?>" width="136" height="116" class="imageclass" /></a><span class="boxtext">&nbsp;<span class="style14">&nbsp;Nationality:</span>&nbsp; <?php echo $row_m['nationality']; ?><br />
  <span class="AccordionPanelTabHover">&nbsp;&nbsp;<span class="style14">Language:</span></span> &nbsp;&nbsp;<?php echo $row_m['language']; ?><br />
  &nbsp;<span class="style14">&nbsp;Teach Ex: </span>&nbsp;&nbsp;&nbsp;<?php echo $row_m['teachingexperience']; ?><br />
  <span class="style14">&nbsp;&nbsp;Prefecture:</span> <?php echo $row_m['prefecture']; ?><br />
  <span class="style15">&nbsp;&nbsp;<br />
  &nbsp;&nbsp;<? $img1=($row_m['vid'])? "<img src=\"videoimage.gif\" alt=\"This teacher has video in their profile\" width=\"41\" height=\"20\" />" : "";  echo $img1; ?></span><br />
  </span>
  <p align="left">&nbsp;
    &nbsp;&nbsp;&nbsp;</p>
  <table width="334" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="132" height="33"><form id="form2" name="form2" method="post" action="deleteme.php">
<img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
<input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
<input type="hidden" name="deleteteacher" value="<?php echo $row_favs['teacherid']; ?>" />
<input type="hidden" name="deletestudent" value="<?php echo $row_favs['studentid']; ?>" />
 </form>    
      </td>
      
      <td width="202"><div align="right">
        <?php
$DbImg = $row_m['expconfirm'] ;
if ($DbImg =="expconfirm") {  
    $altText = "Exp confirmation";
}
else {
   $altText = "No Exp confirmation";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /><?php
$DbImg = $row_m['teflconfirm'] ;
if ($DbImg =="teflconfirm") {  
    $altText = "Tefl confirmation";
}
else {
   $altText = "No Tefl confirmation";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /><?php
$DbImg = $row_m['degreeconfirm'] ;
if ($DbImg =="degreeconfirm") {  
    $altText = "Degree confirmation";
}
else {
   $altText = "No Degree confirmation";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /> </div></td>
    </tr>
  </table>
  <p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
  </div>
 
    
  	<?php } while ($row_m = mysql_fetch_assoc($m)); ?>
  	<br style="clear:both;" />
  <div class="footersearch" id="footersearch">
      <div align="center">
  <table border="0">
    <tr>
      <td width="71"><div align="center">
        <?php if ($pageNum_m > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, 0, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OFirst.gif" border="0" class="footersearch" /></a>
          <?php } // Show if not first page ?>
        </div></td>
        
        
        <td width="76"><div align="center">
          <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, max(0, $pageNum_m - 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OPrevious.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
          </div></td>
        <td width="440" align="center" valign="middle">&nbsp;          <div align="center">Teacher <em><?php echo ($startRow_m + 1) ?></em> to <em><?php echo min($startRow_m + $maxRows_m, $totalRows_m) ?></em> of <span class="style10"><?php echo $totalRows_m ?></span> </div></td>
        <td width="57" align="center" valign="middle"><div align="center">
          <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, min($totalPages_m, $pageNum_m + 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/ONext.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
          </div></td>
          
          
        <td width="67"><div align="center">
          <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, $totalPages_m, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OLast.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
          </div></td>
          
          
      </tr>
  </table>
  <br />
        <br />
      </div>
  	</div>
  </div>
  <div id="sidebox"></div>
</div>

</body>
 
</html>
<?php
mysql_free_result($member);

mysql_free_result($m);

mysql_free_result($favs);
?>

Open in new window

0
 
ayounisAuthor Commented:
Just raising this to 500 due to it's long and winding road....
0
 
Jason C. LevineNo oneCommented:
Business has jumped up and bit me in the ass. Will respond in a day or two.
0
 
ayounisAuthor Commented:
Okay, no probs.

Many thanks.
0
 
Jason C. LevineNo oneCommented:
>> Current code below - It's still deleting from the top of the list

I just noticed something.  The form that points to deleteme.php is in the middle of a loop for recordset $m

That means that only the first value of recordset favorites is appearing in the form.  Can you log in to this page and verify that by viewing source?
0
 
ayounisAuthor Commented:
Hi Jason1178,

No, when I log into Myfavs2.php, it shows all the favourites.

This may be what you expect but I also noticed that if I click  'add to favourites' button for the same teacher say 3 times, then the same profile will be listed 3 times on the favourites page. However, if I click remove from my favourites on one of the mini profile in the favourites (i.e. if she's top of the list), then all three entries are removed.

0
 
Jason C. LevineNo oneCommented:
>> No, when I log into Myfavs2.php, it shows all the favourites.

I meant to look at the source code of the generated page to see if the studentID and teacherID is replicating properly.  I don't think it is which is why only the first favorite of the user is deleted no matter which button is actually clicked.  When you put code from one recordset (called "A" for ease) into the repeating region of a different recordset ("B"), the values from A will not advance as the values from B advance.  You would need to implement a more complex data structure.

Alternately, can you give me the ability to login with a test account and I can look for myself.


>> I also noticed that if I click  'add to favourites' button for the same teacher say 3 times, then the same profile
>> will be listed 3 times on the favourites page.

Yup.  We did not implement a logic check on the favorities page that checks to see if the data is already in the system for that user and if so, disable the submit button.

>> However, if I click remove from my favourites on one of the mini profile in the favourites (i.e. if she's top of the
>> list), then all three entries are removed.

Yes, because the studentID and teacherID both match for all three entries.  If you want, we can switch the delete behavior to use the Primary Key of the Favorites table and then one and only one record will delete.  Simply change the form code to remove:

<input type="hidden" name="deleteteacher" value="<?php echo $row_favs['teacherid']; ?>" />
<input type="hidden" name="deletestudent" value="<?php echo $row_favs['studentid']; ?>" />

and put this in its place:

<input type="hidden" name="deletefavorite" value="<?php echo $row_favs['autonum']; ?>" />

On deleteme.php:

if (isset($_POST['deletefavorite']) && $_POST['deletefavorite'] != "") {
  $deleteSQL = sprintf("DELETE FROM favourites WHERE autonum=%s",
                       GetSQLValueString($_POST['deletefavorite'], "int"));
0
 
ayounisAuthor Commented:
Hi Jason,

If you go to:
http://www.orangutanjapan.com/NEWindex.php

And log in with:
password: jason
email: test@test.com

From this members area, you can click on 'myfavourites' at the top right of the screen. I've set you up with some favourites.

As for the other points, I think the way I'd like it done, is through the implementation of logic which disables the submit button, however, this is another question to be raised seperately, not something for this post.

Thanks
0
 
ayounisAuthor Commented:
Hi Jason1178,

I was thinking I'd award you the points for this question and re-open it again as a different, smaller question - (just asking how to remove the profile selected, not the profile at the top of the list).

Hopefully, we'll get this sorted - I think we must be at least 90% there!

Thanks again, and please look out for the next posting of this revised question.

 
0
 
ayounisAuthor Commented:
Question to be continued in another post.
0
 
Jason C. LevineNo oneCommented:
Ayounis,

up to you. I'm willing to keep going here because I think we've identified the problem (incorrect data structures in the repeating regions). I'm sorry my pace has slowed but some real life issues are eating into my ee time.
0
 
ayounisAuthor Commented:
Hi jason1178

Okay, if you're happy to keep going then so am I. You know the history of this better than any other expert, so you're best placed to solve it I reckon.

No probs regards the slowing pace - real life doesn't stop for EE posts...

Cheers.
0
 
Jason C. LevineNo oneCommented:
Okay, so my suspicion is correct.  If you login with the test account and go to the Myfavs2 page and view source, you will see the following:

1. Jeanette:

<input type="hidden" name="deleteteacher" value="7083" />
<input type="hidden" name="deletestudent" value="5117" />

2. HEO

<input type="hidden" name="deleteteacher" value="7083" />
<input type="hidden" name="deletestudent" value="5117" />


3. Marion

<input type="hidden" name="deleteteacher" value="7083" />
<input type="hidden" name="deletestudent" value="5117" />

So no matter which record is chosen only the first record from the list is deleted because THAT recordset is not repeating.  As mentioned above, you cannot stick values from a second recordset into the repeating region from the first recordset and expect them to automatically link up and change.  The code as written is functioning as expected.  At least we know the deletion page is working properly :)

You have a couple of choices here.  The first (and probably easiest) is to modify the recordset that IS repeating to add the Student and Teacher ID's and then output those to the query.  The second option is to use a more advanced data structure called a "Nested Repeat Region" to control the looping of both recordsets.
0
 
ayounisAuthor Commented:
Let's go for the simpler option.

So you mean modify record set m to incorporate some of the following from recordset favs below...

mysql_select_db($database_a, $a);
$query_favs = sprintf("SELECT autonum, studentid, teacherid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_favs, "int"));
$favs = mysql_query($query_favs, $a) or die(mysql_error());
$row_favs = mysql_fetch_assoc($favs);
$totalRows_favs = mysql_num_rows($favs);


I'll assume this is what you mean and play around with it a bit...

thanks
0
 
ayounisAuthor Commented:
Clumbsily perhaps, I just removed the favs recordset and tried to incorporate it into the recrdset m with an AND statement (see code below).

Unsurprisingly an error was thrown up:

Warning: sprintf() [function.sprintf]: Too few arguments in /home/cjpqapym/public_html/orangutanjapan/MemberProfiles/Myfavs2.php on line 127
Query was empty
mysql_select_db($database_a, $a);
$query_m = sprintf("SELECT TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s AND favourites.autonum, favourites.studentid, favourites.teacherid FROM favourites WHERE studentid = %s", GetSQLValueString($colname_m, "int"));
$m = mysql_query($query_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
$totalRows_m = mysql_num_rows($m);
mysql_select_db($database_a, $a);

Open in new window

0
 
Jason C. LevineNo oneCommented:
That is what I meant but you guessed wrong. I'm on the mobile now will help with the query later.
0
 
Jason C. LevineNo oneCommented:
Okay, consider recordset m:

$query_m = sprintf("SELECT TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s", GetSQLValueString($colname_m, "int"));

So you already have TestTable JOINed to favourites.  This means columns from both tables are available for selection.  There is no need to add any more conditions, just add columns to the SELECT phrase:

$query_m = sprintf("SELECT favourites.teacherid, favourites.studentid, TestTable.photoid, TestTable.date, TestTable.photo, TestTable.imagelocation, TestTable.vid, TestTable.firstname, TestTable.nationality, TestTable.language, TestTable.prefecture, TestTable.private_price, TestTable.teachingexperience, TestTable.teflconfirm, TestTable.expconfirm, TestTable.degreeconfirm FROM TestTable INNER JOIN favourites ON TestTable.autonumber=favourites.teacherid WHERE favourites.studentid = %s", GetSQLValueString($colname_m, "int"));

and then change the deletion form to:

<input type="hidden" name="deleteteacher" value="<?php echo $row_m['teacherid']; ?>" />
<input type="hidden" name="deletestudent" value="<?php echo $row_m['studentid']; ?>" />
0
 
ayounisAuthor Commented:
Fantastic - works perfectly!!

Again, many thanks for your perseverance with this one (as with the others) - and I appreciate your efforts to try to explain how to do the things php wise. I'm really happy with the way all the functionality with the website seems to be coming together.

Have a great week.
0
 
Jason C. LevineNo oneCommented:
Phew.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 28
  • 18
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now