473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP / mySQL select all variable in a pulldown menu

Hey everyone!

Still working on a site I posted for a while ago. Essentially I have a search function that is populated through by a database in mySQL and PHP. I need a few things to help the finishing touches on this...

I need to have a "select all" option in each pulldown menu that will select all rows, and pass them onto the next page so that they can still be selected. Hopefully this makes sense.

Here is the code for the first page (after connecting to the database):

[PHP]<form method="POST" action="search2.php"> Type of Listing: <select name="type">

<?php $sql = mysql_query("SELECT DISTINCT type FROM listings WHERE state LIKE '$state' ORDER BY type ASC"); while ($row = mysql_fetch_array($sql)) { ?>

<option name="<?php echo $row['type']; ?>" id="<?php echo $row['type']; ?>"> <?php echo $row['type']; ?> </option> <?php } ?>

</select>

<input type="submit" value="Continue Search"></form>[/PHP]

Code for the second page:

[PHP]<form method="POST" action="results.php"> Type of Listing: <select name="type">
<?php $sql = mysql_query("SELECT DISTINCT type FROM listings WHERE type LIKE '$type'"); while ($row = mysql_fetch_array($sql)) { ?>
<option name="<?php echo $type; ?>" id="<?php echo $type; ?>"> <?php echo $type; ?> </option> <?php } ?></select>

<br><br>

Area/Location:<select name="area">
<?php $sql = mysql_query("SELECT DISTINCT area FROM listings WHERE type LIKE '$type' ORDER BY area ASC"); while ($row = mysql_fetch_array($sql)) { ?>
<option name="<?php echo $row['area']; ?>" id="<?php echo $row['area']; ?>"> <?php echo $row['area']; ?> </option> <?php } ?></select>

<input name="" type="submit" value="Display Listings"></form>[/PHP]

Here is the results page:

[PHP]<?php

$query="SELECT * FROM listings WHERE area LIKE '$area' AND type LIKE '$type'";
$result=mysql_query($query);

$num=mysql_numrows($result);

echo "<p class='purple_text' align='center'><b>Results for $type in $area</b></p>";

mysql_close();

$i=0;
while ($i < $num) {

$type=mysql_result($result,$i,"type");
$area=mysql_result($result,$i,"area");
$name=mysql_result($result,$i,"name");
$content=mysql_result($result,$i,"content");
$address=mysql_result($result,$i,"address");

if ($name != "") { echo "<hr width='50%'><p align='center'><b>$name</b>"; }
if ($content != "") { echo "<br><i>$content</i>"; }
if ($address != "") { echo "<br>$address"; }

$i++;

}

?>[/PHP]

Thank you so much!
Jul 29 '07 #1
4 3516
kovik
1,044 Expert 1GB
I need to have a "select all" option in each pulldown menu that will select all rows, and pass them onto the next page so that they can still be selected. Hopefully this makes sense.
No, it doesn't really. :-/

Is there a reason that all of this is split into three pages?
Jul 29 '07 #2
No, it doesn't really. :-/

Is there a reason that all of this is split into three pages?

It is split cause that is the only way I knew how to do it. Here is the site: http://forpetsake.com/test/search_map.php - hopefully this will help.

All i need is a "Select All" option at the top of each pulldown menu.
Jul 30 '07 #3
kovik
1,044 Expert 1GB
You could always allow them to select exactly which ones they want, and as many as they want. Just use the "multiple" attribute. Also, be sure to cope for the fact that the posted variable will no longer be a string, but an array.

[html]<select name="foo" multiple>[/html]
Jul 30 '07 #4
You could always allow them to select exactly which ones they want, and as many as they want. Just use the "multiple" attribute. Also, be sure to cope for the fact that the posted variable will no longer be a string, but an array.

[html]<select name="foo" multiple>[/html]

how would i pass the array to each page and output it then? Sorry I am a newbie - this is just very confusing to me!
Jul 31 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
1
by: cgplays.com | last post by:
I have a select-pulldown at http://computergroupplays.com/fb-pres2.asp that changes the 3rd pulldown (Dbase) depending on what the user enters in the 2nd (Wk). My associate wants the values inside...
9
by: flarkblark | last post by:
I recently had the displeasure of looking at the code required to implement the pop-up menus used in a pulldown menu system for a webpage. The sheer amount of Javascript required was amazing...
2
by: Simon Wigzell | last post by:
Is it possible within javascript to stop the little pulldown menu (with the values that the browser remembers have previously been entered into the field) from appearing? I have one very dense form...
1
by: leicklda | last post by:
Hi there, I'm very novice to web design. I'm trying to make a pulldown menu, but the formatting keeps getting screwed up when you roll the mouse over it. Please see www.boundarysys.com for...
7
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I...
5
by: Bubba | last post by:
I have a dynamic pulldown list (ASP with javascript) that when a user picks a state, the corresponding counties for that state appear in a dynamic second pulldown list. When I submit the form, the...
2
by: Boujii | last post by:
Greetings, I have been attempting to make a drop down menu of countries. From this menu I wish to create a variable in order to INPUT into mysql database. I have no trouble making the drop down menu,...
3
by: WiseG1rly | last post by:
Hey everyone! I am completley new and I will start off by saying that I am not a programmer - figuring out this search took so long! I am debugging now and would appreciate any help :) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.