Hi
I can successfully parse data from a form in one page to a table in another page, but I'm having problems displaying the data in the same page as the search form.
Below I have set up a simple one field search and table in the same page. I am not sure where I am going wrong though in order to display the data in my table field which is taken from a dataset record.
Any help would be extremely appreciated. Many thanks

p.s. I have also tried the $_SERVER [PHP_SELF] function in the action"" of the form, but also nothing happens :0)

<?php require_once('Connections/iwalletc_localhost.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;
}
}

mysql_select_db($database_iwalletc_localhost, $iwalletc_localhost);
$query_re_search = "SELECT * FROM property_details";
$re_search = mysql_query($query_re_search, $iwalletc_localhost) or die(mysql_error());
$row_re_search = mysql_fetch_assoc($re_search);
$totalRows_re_search = mysql_num_rows($re_search);

$query_rs_search = "SELECT property_details.prop_saletype FROM property_details WHERE property_details.prop_saletype = '$_POST[prop_saletype]'";
$rs_search = mysql_query($query_rs_search, $iwalletc_localhost) or die(mysql_error());
$row_rs_search = mysql_fetch_assoc($rs_search);
$totalRows_rs_search = mysql_num_rows($rs_search);
?>
<!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>
<table width="400" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>Sale Type</td>
    <td><form action="test_selfform.php" method="post" name="form1" target="_self" id="form1">
      <label for="prop_saletype"></label>
      <select name="prop_saletype" id="prop_saletype">
        <option value="House">House</option>
        <option value="Cluster">Cluster</option>
        <option value="Condo">Condo</option>
        <option value="New Developments">New Developments</option>
      </select>
   </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="search" id="search" value="Submit" />
    </form></td>
  </tr>
</table>

<p>&nbsp;</p>
<table width="400" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td>Contents of Sale Type</td>
    <td><?php echo $row_re_search['prop_saletype']; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($re_search);
?>

Do you have to make your code so complex?

From the code, I see that the output of the page would be whatever is in the prop_saletype field of the first row of your property_details table.

Please let me know what output you intend to see and I should be able to help you out.

Also is the GetSQLValueString required now? I know its good to use it to create more secured code. But its better to put that in the later part of the development process when you know you initial program works well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.