Hi Oscar! Basically, when someone uses your web form to select features, they are assigning values to variables which you can use in your script to handle the processing. For instance, say your web form has something like this in it:
<select name="cell_feature_1">
<option selected>choose a cell feature</option>
<option value="feature_a">feature a</option>
<option value="feature_b"> feature b</option>
<option value="feature_c"> feature c</option>
<option value="feature_d"> feature d</option>
<option value="feature_e"> feature e</option>
<option value="feature_f"> feature f</option>
</select>
<INPUT type="checkbox" name="cell_feature_08" value="true">cell feature 8<BR>
<INPUT type="checkbox" name="cell_feature_09" value="true">cell feature 9<BR>
<INPUT type="checkbox" name="cell_feature_10" value="true">cell feature 10<BR>
<INPUT type="checkbox" name="cell_feature_11" value="true">cell feature 11<BR>
<INPUT type="checkbox" name="cell_feature_12" value="true">cell feature 12
In this case, you can use, in your script to handle the processing, the value of the $cell_feature_1, $cell_feature_08, $cell_feature_09, and so on variables. The values of the former variable will be feature_a, feature_b, or whatever; the value of the latter variables will be true if they are checked and null if they are not checked. Use these variables to basically select all the phone names in your “producten” table that have the cell features specified by the variables. Assign this set of phones to a variable, an array, say $possibilities. Doing this would look something like this:
/assign the variables below with the values for your database/
$Host = "";
$User = "";
$Password = "";
$DBName = "";
$TableName = "";
/this part connects to the databse/
$Link = mysql_connect($Host, $User, $Password);
/below, phone_names and cell_feature_1 are the names of columns in your table—-you are selecting the names of the phones in the rows of the phone_names column where the cell_feature_1 column is the same as the $cell_feature_1 variable—note that here you are not making the request but only setting the value of the $Query variable/
$Query = "SELECT phone_names FROM $TableName WHERE cell_feature_1 = '$cell_feature_1' AND cell_feature_8 = '$cell_feature_8' AND cell_feature_9 = '$cell_feature_9' AND… ";
/here, you make the request and assign the results (cell phone names to the $possibilities variable/
$possibilities = mysql_db_query ($DBName, $Query, $Link);
/this part ends the connection to your database/
mysql_close($Link);
Next, you want to show the user their possible choices, so print out the value of the array. To do this, you have to take each individual element of the array and assign it to a new variable and then print that variable. To do this, use a while loop:
echo("<TABLE BORDER=1 WIDTH=\"75%\" CELLSPACIING=2 CELLPADDING=2 ALIGN=CENTER>\n");
echo("<TR ALIGN=CENTER VALIGN=TOP>\n");
echo("<TD ALIGN=CENTER VALIGN=TOP>PHONE NAME</TD>\n");
echo("</TR>");
while($Row = mysql_fetch_array($possibilities)){
echo("<TR ALIGN=CENTER VALIGN=TOP>\n");
echo("<TD ALIGN=CENTER VALIGN=TOP>$Row[phone_name]</TD>");
echo("</TR>\n");
}
echo("</TABLE>");
The table this makes is quite ugly but you can tweak the display of the results anyway you want… Additionally, you could add a link next to each phone name to display an image of the phone next to it and/or a link to get more info about the phone and/or radio buttons to let the user select the specific phone from their range of choices… on and on and on…
Hope this helped!
James Baker
Oscar wrote:
The Hague, 29 august 2001
Hi,
I have a problem. I want to make a function on my website so people can pick products by selecting on properties. For example: you are looking for a cellphone and you want to get a list of the phones that match your criteria; like you want the following on your new cellphone at least(!!):
voicedial, vibrabattery, bluetooth, gprs, infrarood.
The user has to give the asked properties up with a form. just checkboxes and drop-down menu's.
The DB is already made. Using one table called "producten", with several cols (the function of the cellphones, answered with "Yes" and "No") and the rows, with the different cellphones.
Could anyone help me please? I'm already looking a long time for such a script, but I couldn't find anything that I could use.
Thank you for your time and please reply.
Greeting,
Oscar