I have a php page, in which I would like users to be able to 'renew' a product by clicking on a button 'renew'
There are no form fields to post though, as information is just shown to the user via a recordset.
So basically they see their product information and are asked to click 'confirm' to renew that product.

What I would like to happen is that only one field add_date gets updated with today's date NOW() and for a second column 'renew_count' for example to get incremented by the next number. This would be just for info purposes to tell us how many times they are renewing.

I really need help on the following:
1. Setting the prop_id to be what it is as it comes through from the recordID on a previous page - so that the correct add_date field will update.
Something like:

$prop_id = $query_rs_viewprop ('DEV_property_details.prop_id=%s')

- but I know this doens't work.
2. Creating and updating a renew_count field?

This is what I have so far:
The query:

$colname_rs_viewprop = "-1";
if (isset($_GET['recordID'])) {
  $colname_rs_viewprop = $_GET['recordID'];
mysql_select_db($database_dreamsin_localhost, $dreamsin_localhost);
$query_rs_viewprop = sprintf("SELECT * FROM DEV_property_details WHERE add_date < DATE_ADD(current_date, INTERVAL -45 DAY) AND DEV_property_details.prop_id=%s", GetSQLValueString($colname_rs_viewprop, "int"));
$rs_viewprop = mysql_query($query_rs_viewprop, $dreamsin_localhost) or die(mysql_error());
$row_rs_viewprop = mysql_fetch_assoc($rs_viewprop);
$totalRows_rs_viewprop = mysql_num_rows($rs_viewprop);

The information and button they see:

<div class="propadd1"> <?php echo $row_rs_viewprop['prop_cat']; ?>, , <?php echo $row_rs_viewprop['prop_saletype']; ?></div>
                        <div class="propadd1"></div>
                        <div class="proplistprice"></div>
                        <div class="readmore">
                          <form id="form1" name="form1" method="post" action="renew_expire_record.php">
                            <input name="submit" type="submit" class="maintextnopad" id="submit" value="Confirm Renewal" />

My Update Query (minus the incremented renew_count field as I dont' know how to do this)

<?php require_once('Connections/dreamsin_localhost.php'); 

// Connect to the database
  $dbc = mysqli_connect("localhost", "xxxxxxxxx", "xxxxxxxxx", "xxxxxxxxxx");
  if (isset($_POST['submit'])) {
	  $query = "UPDATE DEV_user_registration SET
	  add_date = 'NOW()'
	  WHERE prop_id = '$prop_id' LIMIT 1";

Any help would be really appreciated...
Many thanks as always

5 Years
Discussion Span
Last Post by jmichae3

UPDATE DEV_USER_registration
SET add_date=NOW()
WHERE prop_id='$prop_id'

zap the single quotes on anything that is a function!

what do you think is going to happen in the case where isset($_GET) becomes false? I can tell you this variable that is otherwise assigned will not be set. so when you call your user-defined function GetSQLValueString($colname_rs_viewprop, "int") you will find that unless your function handles this specific problem, the function may act in an untoward fashion.

either you need to fix your function, or make sure your variable is ALWAYS set to something valid.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.