PDA

View Full Version : A select all option in Dreamweaver list/menu


Jimmel
10-10-2008, 11:28 AM
Hi

I would like to insert a select all option in multiple lists/menus on a search page. I am using php and mysql. Is there a value which I can use in the dynamic list/menu option box which will select everything from a specific field. The code for the search page is


<form action="resultspage.php" method="get" name="formtest" id="formtest">
<label></label>
<label>list
<select name="select" size="8" multiple="multiple">
<option value="Lyng" <?php if (!(strcmp("Lyng", $_GET['formtest']))) {echo "selected=\"selected\"";} ?>>Lyng</option>
<option value="Murphy" <?php if (!(strcmp("Murphy", $_GET['formtest']))) {echo "selected=\"selected\"";} ?>>Murphy</option>
<option value="Smith" <?php if (!(strcmp("Smith", $_GET['formtest']))) {echo "selected=\"selected\"";} ?>>Smith</option>
</select>
<select name="select2">
<option value="Cork" <?php if (!(strcmp("Cork", $row_Recordset1['Address']))) {echo "selected=\"selected\"";} ?>>Cork</option>
<option value="Ireland" <?php if (!(strcmp("Ireland", $row_Recordset1['Address']))) {echo "selected=\"selected\"";} ?>>Ireland</option>
<option value="*" <?php if (!(strcmp("*", $row_Recordset1['Address']))) {echo "selected=\"selected\"";} ?>>All towns</option>
</select>
<input name="Submit" type="submit" value="Submit" />
</label>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>


The code i have for the results page is


<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td width="142"><div align="center">ContactID</div></td>
<td width="144"><div align="center">FirstName</div></td>
<td width="162"><div align="center">LastName</div></td>
<td width="141"><div align="center">Address</div></td>
</tr>
<?php do { ?>
<tr>
<td><div align="center"><?php echo $row_test['ContactID']; ?></div></td>
<td><div align="center"><?php echo $row_test['FirstName']; ?></div></td>
<td><div align="center"><?php echo $row_test['LastName']; ?></div></td>
<td><div align="center"><?php echo $row_test['Address']; ?></div></td>
</tr>
<?php } while ($row_test = mysql_fetch_assoc($test)); ?>
</table>

It all works OK except for the select ALL TOWNS option in the search page

Thanks

davidj
10-10-2008, 01:12 PM
if i understand you correctly you want a single option to select everything in a multi select list like using highlighting every option and submitting that.

is this correct?

Jimmel
10-14-2008, 03:37 PM
Hiya

Yeah, thats what I would like. As users of the website may not realise that a complete search can be done on a field by higlhighting all the options.

davidj
10-14-2008, 06:06 PM
just set the top option to ALL then detect ALL through PHP and then handle the search within the SQL query

Jimmel
10-15-2008, 12:25 PM
Hi

I have placed 'All' in the value/name boxes of the list menu dialog box. This does not seem to work. Is there a special symbol for all that I should use for the value. Also I am not too sure what you mean by handling the search within the sql query.

davidj
10-15-2008, 01:28 PM
how much php have you written? (by hand)

do you understand SQL and PHP

Jimmel
10-15-2008, 02:01 PM
I have no experience with PHP and have only just delved into sql and it is beginning to make some sense. I am just beginning to become interested in both PHP and sql. But I was hoping that I may be able to sort out the 'select all' problem within dreamweaver itself using just the essential sql coding.

davidj
10-15-2008, 04:49 PM
contact me through MSN Messenger