substr works, but can't get result from recordset.
I cannot get my result page to display a result from a recordset based on a substring from the previous page. I can display that substring on the results page and when I test the recordset, it gives me a correct result, but it won’t display on the page.
I have two pages: an input page and a results page.
The Input Page has a form with a field “zipcode”.
The results page has a form that displays a substring of zipcode and the result of a recordset.
The recordset (on the results page) is as follows:
$colname_rsZipZones = "-1";
if (isset($_GET['substr($_POST["zipcode"],0,3)'])) {
$colname_rsZipZones = $_GET['substr($_POST["zipcode"],0,3)'];
}
mysql_select_db($database_BirdScreen, $BirdScreen);
$query_rsZipZones = sprintf("SELECT * FROM zipzones WHERE ZIPSTART = %s", GetSQLValueString($colname_rsZipZones, "text"));
$rsZipZones = mysql_query($query_rsZipZones, $BirdScreen) or die(mysql_error());
$row_rsZipZones = mysql_fetch_assoc($rsZipZones);
$totalRows_rsZipZones = mysql_num_rows($rsZipZones);
?>
I tried both a simple echo and also a text field. Both come up blank. (The echo of the substring works fine. It is the result from the recordset that does not display, although the "test" of the recordset works.)
<form name="form1" method="post" action="">
<p>Zip3: <?php echo substr($_POST["zipcode"],0,3); ?></p>
<p>
<input name="textfield" type="text" id="textfield" value="<?php echo $row_rsZipZones['ZONE']; ?>">
</p>
ZipZone: <?php echo $row_rsZipZones['ZONE']; ?>
</form>
What am I doing wrong? You can try the pages at http://www.birdscreen.com/TestSite/TestShipping.php