Jump to content

jj0311

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jj0311's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help.
  2. Ok, so is there a better way to handle someone selecting 'All'? perhaps something like: SELECT * FROM WINE WHERE WINE.NAME = ??? <---(something that will select all records with entered values and Null values)
  3. Thanks for the suggestion
  4. First off thanks for your time. I have 6 variable values being passed from drop-down menus on another page with php to this page. The variable values are then used to set operator values for the where clause as well as used in the where clause of the sql statement. If someone selects 'All' from the drop down PHP passes a variable value for that field of '0' then the the next page evaluates that $variable and makes the sql operator '<>' theoretically selecting all records based on '0' not being a value in and field, if 'All' is not selected then whatever specific field values is selected is passed and the operator variable is '=' and the query works correctly. So the problem I am having is that when a users selects 'All' (<> '0' for a field value the WHERE clause it doesn't return any of the records if they have a null value in that field. Is there a way to get the sql statement to pull all values including nulls? Is there a better way to get All values other than rigging the php and sql up as I have? Here is my PHP and SQL: <?php $Wine_Name = $_POST['Wine_Name']; $Vintage = $_POST['Vintage']; $Vineyard = $_POST['Vineyard']; $Varietal = $_POST['Varietal']; $Appellation = $_POST['Appellation']; $Producer = $_POST['Producer']; ?> <?php IF ($Wine_Name == '0') { $Operator_Wine_Name = '<>'; } Else { $Operator_Wine_Name = '='; } ?> <?php IF ($Vintage == '0') { $Operator_Vintage = '<>'; } Else { $Operator_Vintage = '='; } ?> <?php IF ($Vineyard == '0') { $Operator_Vineyard = '<>'; } Else { $Operator_Vineyard = '='; } ?> <?php IF ($Varietal == '0') { $Operator_Varietal = '<>'; } Else { $Operator_Varietal = '='; } ?> <?php IF ($Appellation == '0') { $Operator_Appellation = '<>'; } Else { $Operator_Appellation = '='; } ?> <?php IF ($Producer == '0') { $Operator_Producer = '<>'; } Else { $Operator_Producer = '='; } ?> "SELECT WINE.WINE_IMAGE_LABEL, WINE.WINE_IMAGE_BOTTLE, WINE.WINE_PROPRIETARY_NAME, WINE.WINE_VINTAGE, WINE.WINE_ALCOHOL_CONTENT, WINE.WINE_PRICE_RANGE, WINE.WINE_UPC, VINEYARD.VINEYARD_DESCRIPTION, VARIETAL_TYPE.VARIETAL_TYPE_DESCRIPTION, TASTING_NOTE.TASTING_NOTE_TEXT, TASTING_NOTE.TASTING_NOTE_DATE, PRODUCER.PRODUCERS_DESCRIPTION, APPELLATION.APPELLATION_DESCRIPTION FROM WINE LEFT JOIN APPELLATION ON WINE.APPELLATION_ID = APPELLATION.APPELLATION_ID LEFT JOIN PRODUCER ON WINE.PRODUCER_ID = PRODUCER.PRODUCER_ID LEFT JOIN VINEYARD ON WINE.VINEYARD_ID = VINEYARD.VINEYARD_ID LEFT JOIN VARIETAL_TYPE ON WINE.VARIETAL_TYPE_ID = VARIETAL_TYPE.VARIETAL_TYPE_ID LEFT JOIN TASTING_NOTE ON WINE.WINE_ID = TASTING_NOTE.WINE_ID LEFT JOIN RATING ON TASTING_NOTE.RATING_ID = RATING.RATING_ID WHERE WINE.WINE_PROPRIETARY_NAME $Operator_Wine_Name '$Wine_Name' AND WINE.WINE_VINTAGE $Operator_Vintage $Vintage AND WINE.VINEYARD_ID $Operator_Vineyard $Vineyard AND WINE.VARIETAL_TYPE_ID $Operator_Varietal $Varietal AND WINE.APPELLATION_ID $Operator_Appellation $Appellation AND WINE.PRODUCER_ID $Operator_Producer $Producer ORDER BY WINE.WINE_ID"
  5. First I want not say I am not really well versed in programming, and appreciate any help. Is it possible to use field values selected from multiple(6) dynamically generated drop down menus on one page to query a database when a button is clicked and then use display the results of the query on another page? If so, what should I do? Also I wanted to allow users to be able to leave fields blank i.e. not select a value from the table for the search...is that possible? Not sure if the code is needed but here is a snipit from the menus and form they are contained in: <form id="search_taste" name="search_taste" method="post" action="tasteNote.php"> <p> <label>Wine <select name="Wine" id="Wine" title="<?php echo $row_rs_Wine['WINE_PROPRIETARY_NAME']; ?>"> <option value="*">All</option> <?php do { ?> <option value="<?php echo $row_rs_Wine['WINE_PROPRIETARY_NAME']?>"><?php echo $row_rs_Wine['WINE_PROPRIETARY_NAME']?></option> <?php } while ($row_rs_Wine = mysql_fetch_assoc($rs_Wine)); $rows = mysql_num_rows($rs_Wine); if($rows > 0) { mysql_data_seek($rs_Wine, 0); $row_rs_Wine = mysql_fetch_assoc($rs_Wine); } ?> </select> </label> </p> <p> <label>Vintage <select name="Vintage" id="Vintage"> <option value="*">All</option> <?php do { ?> <option value="<?php echo $row_rs_Vintage['WINE_VINTAGE']?>"><?php echo $row_rs_Vintage['WINE_VINTAGE']?></option> <?php } while ($row_rs_Vintage = mysql_fetch_assoc($rs_Vintage)); $rows = mysql_num_rows($rs_Vintage); if($rows > 0) { mysql_data_seek($rs_Vintage, 0); $row_rs_Vintage = mysql_fetch_assoc($rs_Vintage); } ?> </select> </label>
×
×
  • 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.