Jump to content

[SOLVED] Newbie - Parse error with "if (isset($_POST['min']) && isset($_POST['max'])"


Recommended Posts

For those of you who were with me on my last question, I'm making a form where one of the results is created by a range of dates. I have 2 drop down boxes that are populated with "date" data from the table and they pass it onto the results page using the "Post" method. My host is Godaddy / Linux and my table is MySQL ver 4.1

 

I can populate my drop boxes using multiple queries - for some reason the code other forum members have been giving me to populate those boxes using a single query isn't working...

 

When I click the submit button, I get "Parse error: parse error, unexpected ' .././..track_date_results.php on line 5

 

*********************************************************************************************

 

Here's the code from the search page;

$query = 'SELECT date FROM GC_Tracker';  
$result = mysql_query($query) or die(mysql_error());
$select_options = array();
if ($result && mysql_num_rows($result)) while ($row = mysql_fetch_row($result)) $select_options[] = "\t<option value=\"$row[0]\">$row[0]</option>\n";
?> 
Select<form method="POST" action="track_date_results.php">  
<select size="1" name="min">
<?php echo implode('',$select_options); ?>
</select>
<select size="1" name="max">
<?php echo implode('',$select_options); ?>
</select>
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2">  
</form>

 

and this is the code on the results page;

if (isset($_POST['min']) && isset($_POST['max']) { // where min and max are the names of the two form fields.
    $sql = "SELECT * FROM GC_Tracker WHERE date >= '{$_POST['min']}' && date <= '{$_POST['max']}'";
    if ($result = mysql_query($sql)) {
      if (mysql_num_rows($result)) {
        $i = 0;
        echo "<TABLE BORDER=\"1\">\n";
        echo "<TR bgcolor=\"lightblue\"><TD>Company</TD><TD>Phone</TD><TD>City</TD></TR>\n";
        while ($row = mysql_fetch_array($result)) {
          if ($i % 2) {
            echo "<TR bgcolor=\"yellow\">\n";
          } else {
            echo "<TR bgcolor=\"white\">\n";
          }
          echo "<TD>".$row['customer']."</TD><TD>".$row['phone']."</TD><TD>".$row['city']."</TD>\n";
          echo "</TR>\n";
          $i++;
        }
        echo "</TABLE>\n";
      } else {
        echo "No results found";
      }
    } else {
      echo "Query failed<br />" . $sql . "<br />" . mysql_error();
    }
  } else {
    echo "form not submitted";
  }

?>

 

Your help is greatly appreciated as I'm almost done! Thanks in advance ~Rich

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.