delete and update of user records

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

delete and update of user records

Post by timoteo »

Hi, I know your all great and know all here. I have a double problem with 2 related issues on my page.
I have a repeating record set displayed on the page and next to each record a tick box to select the record based on entry id to link to a delete button (all records ticked to be deleted); and a link to an update page to select the relevant record to update on another page using a session variable 'entryid' to select. ...it's not working :(
any ideas?? I have no session 'entryid' echoed out - now that's a problem to start with.
here is the header:

Code: Select all

<?php
ini_set('session.bug_compact_warn', 0);
ini_set('session.bug_compact_42', 0);
// set session entryid
$entry = $_POST['entryid'];

mysql_select_db($database_recommendingpeople, $recommendingpeople);

$query = "SELECT * FROM recommendations WHERE entryid= '$entry';";
$result = mysql_query($query, $recommendingpeople) or die(mysql_error());
$row = mysql_fetch_assoc($result);

if (!$result) {
echo "Got nothing";
} else {

$_SESSION['entryid'] = $row['entry'];


}

?>
<?php
$_SESSION['MM_Username'];
$_SESSION['userid'];
$_SESSION['entryid'];
echo $_SESSION['entryid'];
?>
<?php

$maxRows_rsrecommendations = 10;
$pageNum_rsrecommendations = 0;
if (isset($_GET['pageNum_rsrecommendations'])) {
  $pageNum_rsrecommendations = $_GET['pageNum_rsrecommendations'];
}
$startRow_rsrecommendations = $pageNum_rsrecommendations * $maxRows_rsrecommendations;

$colname_rsrecommendations = "1";
if (isset($_SESSION['userid'])) {
  $colname_rsrecommendations = (get_magic_quotes_gpc()) ? $_SESSION['userid'] : addslashes($_SESSION['userid']);
}
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query_rsrecommendations = sprintf("SELECT * FROM recommendations WHERE userid = %s", $colname_rsrecommendations);
$query_limit_rsrecommendations = sprintf("%s LIMIT %d, %d", $query_rsrecommendations, $startRow_rsrecommendations, $maxRows_rsrecommendations);
$rsrecommendations = mysql_query($query_limit_rsrecommendations, $recommendingpeople) or die(mysql_error());
$row_rsrecommendations = mysql_fetch_assoc($rsrecommendations);

if (isset($_GET['totalRows_rsrecommendations'])) {
  $totalRows_rsrecommendations = $_GET['totalRows_rsrecommendations'];
} else {
  $all_rsrecommendations = mysql_query($query_rsrecommendations);
  $totalRows_rsrecommendations = mysql_num_rows($all_rsrecommendations);
}
$totalPages_rsrecommendations = ceil($totalRows_rsrecommendations/$maxRows_rsrecommendations)-1;
?>
and the table:

Code: Select all

  <form action="" method="post" name="myrecommendations" id="myrecommendations">
      <div align="center">
        <table width="94%"  border="10" bgcolor="#FFFFFF" id="recommendations">
  <tr class="style8">
    <td>&nbsp;</td>
    <td width="30%">Business:</td>
    <td colspan="2">Address:</td>
    <td colspan="2">e-mail, telephone </td>
  </tr>
  <?php do { ?>
  <tr>
    <td><input type="checkbox" name="checkbox" value="<?php echo $row_rsrecommendations['entryid']; ?>">
      <input name="hiddenField" type="hidden" value="<?php echo $row_rsrecommendations['entryid']; ?>"></td>
    <td><?php echo $row_rsrecommendations['businessname']; ?></td>
    <td><?php echo $row_rsrecommendations['townborough']; ?>,</td>
    <td><?php echo $row_rsrecommendations['city']; ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><a href="recommendationsupdate.php" title="recommendationsupdate" accesskey="u" value =  $_SESSION['entryid']>update</a> </td>
    <td><?php echo $row_rsrecommendations['firstname']; ?>,<?php echo $row_rsrecommendations['lastname']; ?></td>
    <td><?php echo $row_rsrecommendations['county']; ?>,</td>
    <td><?php echo $row_rsrecommendations['state']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['email']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><?php echo $row_rsrecommendations['businesscategory']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['country']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['tel']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
  </tr>
  <?php } while ($row_rsrecommendations = mysql_fetch_assoc($rsrecommendations)); ?>
 <tr>
 <td colspan="5" align="center" bgcolor="#FFFFFF"><div align="left">
   <input name="delete" type="submit" id="delete" value="Delete">
     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="150" height="30" align="right">
         <param name="movie" value="button8.swf">
         <param name="quality" value="high">
         <param name="bgcolor" value="#FFFFFF">
         <embed src="button8.swf" width="150" height="30" align="right" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#FFFFFF"></embed>
     </object>
 </div></td>
 </tr>
<?
// Check if delete button active, start this 
 mysql_select_db($database_recommendingpeople, $recommendingpeople);
 if($delete){
 for($i=0;$i<$count;$i++){
 $del_entryid = $checkbox[$i];
 $sql = "DELETE * FROM recommendations WHERE entryid ='$del_entryid'";
 $result = mysql_query($sql);
 }

// if successful redirect to delete_multiple.php 
 if($result){
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=myrecommendations.php\">";
 }
 }
 mysql_close();
 ?>
</table>
How do I select the relevant entry to delete or update? Am I going the right way about this??
thanks in advance. You guys are great
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: delete and update of user records

Post by social_experiment »

To delete multiple records you should use an array. You will have to update (no pun) your form code slightly

Code: Select all

<input type="checkbox" name="checkbox[]" value="<?php echo $row_rsrecommendations['entryid']; ?>">
Now $_POST['checkbox'] is an array that will contain all the values if a checkbox is ticked. To run through them you can do something like this

Code: Select all

<?php
 foreach ($_POST['checkbox'] as $value) {
   $query = "DELETE * FROM table WHERE yourField = '". mysql_real_escape_string($value) ."' ";
   $deleteSql = mysql_query($query);
 }
 // if you want to see how many rows where affected 
 $rowsDeleted = mysql_affected_rows();
 echo $rowsDeleted;
?>
Update your record is slightly easier, i don't know what existing code you have so i will assume none (no offence :) ) and give an example

Code: Select all

<?php
 // first, you may have to modify this line of code as there is 
 // no value attribute for the <a> tag
 <a href="recommendationsupdate.php?id=<?php echo $_SESSION['entryid']; ?>" title="recommendationsupdate" accesskey="u" >update</a>
?>
On your update page you get the information from the url (or query string) by using $_GET

Code: Select all

<?php
 $id = $_GET['id'];
 // check this value to make sure it is the type you require

 $query = "UPDATE table SET field1 = 'value1' WHERE specificField = '$id'";
 $updateSql = mysql_query($query);
?>
Hth
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

Hi, thanks.
I tried your suggestions for the delete function but got an error:

Parse error: syntax error, unexpected T_AS in /home/biomagn1/public_html/recommendingpeople.com/myrecommendations.php on line 304

here is my code line 275 - 323 (the errors never seem to be on the indicated line here!)

Code: Select all

<?php do { ?>//this is line 275
  <tr>
    <td><input type="checkbox" name="checkbox[]" value="<?php echo $row_rsrecommendations['entryid']; ?>">
      <input name="hiddenField" type="hidden" value="<?php echo $row_rsrecommendations['entryid']; ?>"></td>
    <td><?php echo $row_rsrecommendations['businessname']; ?></td>
    <td><?php echo $row_rsrecommendations['townborough']; ?>,</td>
    <td><?php echo $row_rsrecommendations['city']; ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><a href="recommendationsupdate.php" title="recommendationsupdate" accesskey="u" value =  $_SESSION['entryid']>update</a> </td>
    <td><?php echo $row_rsrecommendations['firstname']; ?>,<?php echo $row_rsrecommendations['lastname']; ?></td>
    <td><?php echo $row_rsrecommendations['county']; ?>,</td>
    <td><?php echo $row_rsrecommendations['state']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['email']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><?php echo $row_rsrecommendations['businesscategory']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['country']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['tel']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
  </tr>
  <?php } while ($row_rsrecommendations = mysql_fetch_assoc($rsrecommendations)); ?>
 <tr>//this is line 304
 <td colspan="5" align="center" bgcolor="#FFFFFF"><div align="left">
   <input name="delete" type="submit" id="delete" value="Delete">
     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="150" height="30" align="right">
         <param name="movie" value="button8.swf">
         <param name="quality" value="high">
         <param name="bgcolor" value="#FFFFFF">
         <embed src="button8.swf" width="150" height="30" align="right" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#FFFFFF"></embed>
     </object>
 </div></td>
 </tr>
<?php
  foreach ($_POST['checkbox'] as $value) {
    $query = "DELETE * FROM recommendations WHERE entryid = '". mysql_real_escape_string($value) ."' ";
    $deleteSql = mysql_query($query);
  }
  // if you want to see how many rows where affected 
  $rowsDeleted = mysql_affected_rows();
  echo $rowsDeleted;
?>

any ideas?
the update I'm working on. I was trying to send it as a session but that is not going to work - I can't create multiple session variables with the same name to up date various records. I just wanted something more secure than URL variables - otherwise users could update a record that was not theirs by manipulating the URL. Am I correct?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: delete and update of user records

Post by social_experiment »

timoteo wrote:the update I'm working on. I was trying to send it as a session but that is not going to work - I can't create multiple session variables with the same name to up date various records. I just wanted something more secure than URL variables - otherwise users could update a record that was not theirs by manipulating the URL. Am I correct?
I've downloaded your code and will have a look at in the am :) As per your question, yes, if you don't do proper checks users can probably do things that they are not supposed to (with values from the url).
timoteo wrote:I can't create multiple session variables with the same name to up date various records.
Im not sure what you mean here
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

well the results page may display say 10 records with 10 diferent ids. There fore if a user selects one and I convert it to a session id all is well. However if they select a second record to update I need to unset the first 'entryid' session before setting the second - is that right? How can I get round that.
Thanks I really appreciate your help on the issue
cheers
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: delete and update of user records

Post by John Cartwright »

timoteo wrote:well the results page may display say 10 records with 10 diferent ids. There fore if a user selects one and I convert it to a session id all is well. However if they select a second record to update I need to unset the first 'entryid' session before setting the second - is that right? How can I get round that.
Thanks I really appreciate your help on the issue
cheers
I'm having trouble understanding you. You can simply overwrite values without unsetting them.
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

got you, so a I can overwrite the value of a session variable from one page to another - thankyou
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

I found the error forT_AS here:

Code: Select all

<?php
  foreach ($_POST['checkbox'] as $value) {
    $query = "DELETE * FROM recommendations WHERE entryid = '". mysql_real_escape_string($value) ."' ";
    $deleteSql = mysql_query($query);
  }
any one know why??
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: delete and update of user records

Post by social_experiment »

Are you calling this page on itself or does it go to another page because your code doesn't have a <form> tag to indicate this?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

the delete was going on itself - opening the same page
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

I can't seem to get round

Code: Select all

 foreach ($_POST['checkbox'] as $value) {
any ideas?
Here is the complete code which I stripped to the necessary again to understand the bare bones:

Code: Select all

<?php require_once('Connections/recommendingpeople.php'); ?>
<?php

// set session userid
$username =  $_SESSION['MM_Username'];

mysql_select_db($database_recommendingpeople, $recommendingpeople);

$query = "SELECT * FROM username WHERE username='$username';";
$result = mysql_query($query, $recommendingpeople) or die(mysql_error());
$row = mysql_fetch_assoc($result);

if (!$result) {
echo "Got nothing";
} else {

$_SESSION['userid'] = $row['userid'];


}

?>
<?php
ini_set('session.bug_compact_warn', 0);
ini_set('session.bug_compact_42', 0);
// set session entryid
$entry = $_POST['entryid'];

mysql_select_db($database_recommendingpeople, $recommendingpeople);

$query = "SELECT * FROM recommendations WHERE entryid= '$entry';";
$result = mysql_query($query, $recommendingpeople) or die(mysql_error());
$row = mysql_fetch_assoc($result);

if (!$result) {
echo "Got nothing";
} else {

$_SESSION['entryid'] = $row['entryid'];


}

?>
<?php
$_SESSION['MM_Username'];
$_SESSION['userid'];
$_SESSION['entryid'];
echo $_SESSION['entryid'];
?>
<?php

$maxRows_rsrecommendations = 10;
$pageNum_rsrecommendations = 0;
if (isset($_GET['pageNum_rsrecommendations'])) {
  $pageNum_rsrecommendations = $_GET['pageNum_rsrecommendations'];
}
$startRow_rsrecommendations = $pageNum_rsrecommendations * $maxRows_rsrecommendations;

$colname_rsrecommendations = "1";
if (isset($_SESSION['userid'])) {
  $colname_rsrecommendations = (get_magic_quotes_gpc()) ? $_SESSION['userid'] : addslashes($_SESSION['userid']);
}
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query_rsrecommendations = sprintf("SELECT * FROM recommendations WHERE userid = %s", $colname_rsrecommendations);
$query_limit_rsrecommendations = sprintf("%s LIMIT %d, %d", $query_rsrecommendations, $startRow_rsrecommendations, $maxRows_rsrecommendations);
$rsrecommendations = mysql_query($query_limit_rsrecommendations, $recommendingpeople) or die(mysql_error());
$row_rsrecommendations = mysql_fetch_assoc($rsrecommendations);

if (isset($_GET['totalRows_rsrecommendations'])) {
  $totalRows_rsrecommendations = $_GET['totalRows_rsrecommendations'];
} else {
  $all_rsrecommendations = mysql_query($query_rsrecommendations);
  $totalRows_rsrecommendations = mysql_num_rows($all_rsrecommendations);
}
$totalPages_rsrecommendations = ceil($totalRows_rsrecommendations/$maxRows_rsrecommendations)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
</head>

</head>

<body>

<form action="" method="post" name="myrecommendations" target="_self" id="myrecommendations">
      <div align="center">
        <table width="94%"  border="10" bgcolor="#FFFFFF" id="recommendations">
  <tr class="style8">
    <td>&nbsp;</td>
    <td width="30%">Business:</td>
    <td colspan="2">Address:</td>
    <td colspan="2">e-mail, telephone </td>
  </tr>
  <?php do { ?>
  <tr>
    <td><input type="checkbox" name="checkbox[]" value="<?php echo $row_rsrecommendations['entryid']; ?>">
	<?php
  foreach ($_POST['checkbox'] as $value) {
    $query = "DELETE * FROM recommendations WHERE entryid = '". mysql_real_escape_string($value) ."' ";
    $deleteSql = mysql_query($query);
  }
  // if you want to see how many rows where affected 
  $rowsDeleted = mysql_affected_rows();
  echo $rowsDeleted;
?>
      <input name="hiddenField" type="hidden" value="<?php echo $row_rsrecommendations['entryid']; ?>"></td>
    <td><?php echo $row_rsrecommendations['businessname']; ?></td>
    <td><?php echo $row_rsrecommendations['townborough']; ?>,</td>
    <td><?php echo $row_rsrecommendations['city']; ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><a href="recommendationsupdate.php" title="recommendationsupdate" accesskey="u" value =  $_SESSION['entryid']>update</a> </td>
    <td><?php echo $row_rsrecommendations['firstname']; ?>,<?php echo $row_rsrecommendations['lastname']; ?></td>
    <td><?php echo $row_rsrecommendations['county']; ?>,</td>
    <td><?php echo $row_rsrecommendations['state']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['email']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><?php echo $row_rsrecommendations['businesscategory']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['country']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['tel']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
  </tr>
  <?php } while ($row_rsrecommendations = mysql_fetch_assoc($rsrecommendations)); ?>
 <tr>
 <td colspan="5" align="center" bgcolor="#FFFFFF"><div align="left">
   <input name="delete" type="submit" id="delete" value="Delete">
 </div></td>
 </tr>


</table>
        <p>
          <input name="hiddenField3" type="hidden" value="<?php echo $row_rsrecommendations['userid']; ?>">
        </p>
      </div>
    </form>
	</body>
</html>
This code should do 2 things
1) select and delete a record and return results on reload of same page
2) select results and through a session variable 'entryid' send a particular record to another page for update.
...however it doesn't :cry:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: delete and update of user records

Post by John Cartwright »

What happens when you change it to this?

Code: Select all

$query = "DELETE * FROM recommendations WHERE entryid = '". mysql_real_escape_string($value) ."' ";

echo $query .'<br>';

$deleteSql = mysql_query($query) or die(mysql_error());
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

this

Code: Select all

  $query = "DELETE * FROM recommendations WHERE entryid = '". mysql_real_escape_string($value) ."' ";
gives me error

something wrong with the variable - unexpected T_VARIABLE on this line
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: delete and update of user records

Post by John Cartwright »

There is no parse error on that line. Probably the line before it.
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: delete and update of user records

Post by timoteo »

I have no advance here. My main problem is selecting the entry id of my database. In the table I have 5 sets of results for example. I want to be able to select with a checkbox each set and delete it with return on the same page and with a button or link open each set in turn for updating on another page or pop up . Is this possible from the same form. My update page works fine however it sends either the first (if no variable sent) or the last entry from my db table.(if variable sent from my sending form). The suggested delete codes I have not been able to work at all. I just get errors, however also to do I think with my problem with my 'entryid' variable which is included in each entry as a hidden field called 'entryid'.
Here is my complete code for this testing page. Any ideas please welcome. thanks for the help. everyday I am learning more with the help of people like you.

Code: Select all

<?php require_once('Connections/recommendingpeople.php'); ?>
<?php

mysql_select_db($database_recommendingpeople, $recommendingpeople);
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 = "index.php";
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

// set session userid
$username =  $_SESSION['MM_Username'];

mysql_select_db($database_recommendingpeople, $recommendingpeople);

$query = "SELECT * FROM username WHERE username='$username';";
$result = mysql_query($query, $recommendingpeople) or die(mysql_error());
$row = mysql_fetch_assoc($result);

if (!$result) {
echo "Got nothing";
} else {

$_SESSION['userid'] = $row['userid'];


}

?>
<?php

// set session entryid
$entryid = $_POST['entryid'];


$_SESSION['entryid'] = $entryid;




?>
<?php
$_SESSION['MM_Username'];
$_SESSION['userid'];
$_SESSION['entryid'];
echo $_SESSION['entryid'];
echo $_SESSION['MM_Username'];
?>
<?php

$maxRows_rsrecommendations = 10;
$pageNum_rsrecommendations = 0;
if (isset($_GET['pageNum_rsrecommendations'])) {
  $pageNum_rsrecommendations = $_GET['pageNum_rsrecommendations'];
}
$startRow_rsrecommendations = $pageNum_rsrecommendations * $maxRows_rsrecommendations;

$colname_rsrecommendations = "1";
if (isset($_SESSION['userid'])) {
  $colname_rsrecommendations = (get_magic_quotes_gpc()) ? $_SESSION['userid'] : addslashes($_SESSION['userid']);
}
mysql_select_db($database_recommendingpeople, $recommendingpeople);
$query_rsrecommendations = sprintf("SELECT * FROM recommendations WHERE userid = %s", $colname_rsrecommendations);
$query_limit_rsrecommendations = sprintf("%s LIMIT %d, %d", $query_rsrecommendations, $startRow_rsrecommendations, $maxRows_rsrecommendations);
$rsrecommendations = mysql_query($query_limit_rsrecommendations, $recommendingpeople) or die(mysql_error());
$row_rsrecommendations = mysql_fetch_assoc($rsrecommendations);

if (isset($_GET['totalRows_rsrecommendations'])) {
  $totalRows_rsrecommendations = $_GET['totalRows_rsrecommendations'];
} else {
  $all_rsrecommendations = mysql_query($query_rsrecommendations);
  $totalRows_rsrecommendations = mysql_num_rows($all_rsrecommendations);
}
$totalPages_rsrecommendations = ceil($totalRows_rsrecommendations/$maxRows_rsrecommendations)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
</head>

</head>

<body>


<form action="recommendationsupdate.php" method="post" name="myrecommendations" target="_blank" id="myrecommendations">
      <div align="center">
        <table width="94%"  border="10" bgcolor="#FFFFFF" id="recommendations">
  <tr class="style8">
    <td>&nbsp;</td>
    <td width="30%">Business:</td>
    <td colspan="2">Address:</td>
    <td colspan="2">e-mail, telephone </td>
  </tr>
  <?php do { ?>
  <tr>
   <td><input type="checkbox" name="checkbox[]" value="<?php echo $row_rsrecommendations['entryid']; ?>">

   
	
      <input name="entryid" type="hidden" id="entryid" value="<?php echo $row_rsrecommendations['entryid']; ?>"></td>
    <td><?php echo $row_rsrecommendations['businessname']; ?></td>
    <td><?php echo $row_rsrecommendations['townborough']; ?>,</td>
    <td><?php echo $row_rsrecommendations['city']; ?></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><a href="recommendationsupdate.php" title="recommendationsupdate.php" accesskey="u" value =  $_SESSION['entryid']>update</a> </td>
    <td><?php echo $row_rsrecommendations['firstname']; ?>,<?php echo $row_rsrecommendations['lastname']; ?></td>
    <td><?php echo $row_rsrecommendations['county']; ?>,</td>
    <td><?php echo $row_rsrecommendations['state']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['email']; ?></td>
  </tr>
  <tr>
    <td><input name="submit" type="submit" id="submit" value="update"></td>
    <td><?php echo $row_rsrecommendations['businesscategory']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['country']; ?></td>
    <td colspan="2"><?php echo $row_rsrecommendations['tel']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
    <td colspan="2"><div align="center">------------------</div></td>
  </tr>
  <?php } while ($row_rsrecommendations = mysql_fetch_assoc($rsrecommendations)); ?>
 <tr>
 <td colspan="5" align="center" bgcolor="#FFFFFF"><div align="left">
   <input name="delete" type="submit" id="delete" value="Delete">
 </div></td>
 </tr>


</table>
        <p>
          <input name="hiddenField3" type="hidden" value="<?php echo $row_rsrecommendations['userid']; ?>">
        </p>
      </div>
</form>
</body>
</html>
Post Reply