PHP - Get Value From Drop Down List
Hi ,
I am pretty new to php. I would like to create a php website based on folders.
I have a code so far that shows the names of folder in a selection box. What I would like to achieve now is how i get the images inside the folder after I click on submit. I know how to get the images with a glob function. What I don't know is how to get the value of each specific folder name. How would I do that?
I have this code so far to get the names of the folders in the selection box:
<form action="test.php" method="post"> <select name="myDirs"> <option value="" selected="selected">Select a genre</option> <?php $dirs = glob("*", GLOB_ONLYDIR); foreach($dirs as $val){ echo '<option value="'.$val.'">'.$val."</option>\n"; } ?> </select> <input type="submit" name="submit2"> <?phpif (isset($_POST['submit2'])) Similar TutorialsHelllo Every1 well im kinda new to php and i needed some help i was working on a page all my text boxes and check boxes are at the bottom of my file and like this //====================================================================== </script> </head> <body> <div style="margin-left: 170px"> <input type="checkbox" id="getitems" checked value="1">Run Plugin? <input type="checkbox" id="sellitm" checked value="1">Sell Items?<br><br> Item Name:<br><input type="text" id="itemd" value=""><br><br>How Many Cycles?:<br><input type="text" id="runtm" value="10"></div> <div style="margin-left: 170px"><br> <button id="btn_save" style="color:white;background-color:#00660F;border-width:1px;border-style:solid; "> Save settings </button> </div> '; echo $this->ObjectTable(); echo ' </body> </html> '; } } ?> and well i decided to do away wit one of the text boxes and use a drop down list instead that is populate from a text file and the only code that i could find that i was able to get working was this 1 <?php $text = file_get_contents("itemlist.txt"); $array = explode("\n",$text); echo "<select>"; foreach ($array as $value) { echo "<option value='$value'>$value</option>"; } echo "</select>"; and the problem im having is with that one it just stays at the top of the page when loaded like i have no way to position it... and im really stuck i tried saving it in another php and i tried using <?php include(); ?> function but it did not work if any1 could help me out that would be awsome. T.I.A I have a "select"-drop down bar and I want to have a numbered list in it, i've tried but it doesn't seem to be possible. Is there any way that i'm able to do this? hi, I'm sruggling to get a drop down list to post the chosen value from an sql database.. could someone please point me in the right direction many thanks! I'm useing a simple HTML drop-down list box. But now I want to be able to and an editable drop-down box so that if the particular item in the drop-down is not changed it won't update the database. But if a new value is selected it will update the DB with the new value.
I am not clear on a couple of things. should the valuse of the drop down be in a seperate DB table. And then the script to change the new value or keep the old.
I've googled this and can't seem to find a workable solution.
Thanks in advance,
I have a drop down list which retrieves site name acronym and the url from the database. I need help in 2 things. 1.I do not want the url to be displayed in the drop down list. 2. When I hit submit I need to echo the sitename acronym as well as the url in a page called display.php. Here is my code so far: Code: [Select] <form action="display.php" method ="post"> <tr> <td>Category</td> <td> <select name="new_id"> <option value="">=============</option> <?php foreach($acronym as $key=>$value){ ?> <option value="<?php echo $value['site_id']; ?>"><?php echo $value['acronym']; ?></option> <option value="<?php echo $value['site_id']; ?>"><?php echo $value['url']; ?></option> <?php }?> </td> </tr> <input type="submit" name="submit" value="submit" /> </form> I have two basic dropdown lists in a form, my question is this: After selecting an item from the 1st dropdown list, the second dropdown list should automatically load only fields that are connected with the first selected item. (ex Site1 has Tank01 and Tank06, but Site2 has Tank03, Tank04 and also a Tank06). What is the script needed / or how do I change my script to accommodate this? Here is the basic script I use for the second dropdown list: <?php include("../xxx.php"); $cxn = mysqli_connect($host,$user,$password,$dbname); $query = "SELECT DISTINCT `diesel_tank_id` FROM `diesel_tank` ORDER BY `diesel_tank_id`"; $result = mysqli_query($cxn,$query); while($row = mysqli_fetch_assoc($result)) { extract($row); echo "<option value='$diesel_tank_id'>$diesel_tank_id</option>\n"; } ?> Hello, I'm trying to get a drop down list (ordinary html function, select option ...) but I want it to start from an image. When you click the image I want the drop down list to appear. Hove can I do this? /Pelle I have a drop down list that contains expiration dates in the format 01/12 and if the user selected a certain drop down list I would like that same date selected. Does anyone know the code to do this? Thanks. Hey guys, I made in php an sql droplist. But I need some help. I want it to work like this. When I select something from the list and click Add To Cart, that also the product gets send to the cart and not only the quantity. you can check it out here : http://fhcs.be/cart-demo2/index.php I also added my index.php as an attachment Greets I'm doing this activity where a user chooses a base timezone and when the user clicks convert the current time in the selected GMT will be converted to GMT-11 to GMT+13. As of now, I have these codes: act09_view.php: Code: [Select] <?php session_start(); $s="GMT "; echo "Select the base time zone:</br>"; for($n=-11;$n<=13;$n++) { if ($n>=0) $s="GMT +"; $gmt[]=$s . $n . "</br>"; } echo "<select name='gmt'>"; foreach ($gmt as $value) { echo '<option value="' . $value . '">' . $value . '</option>\n'; } echo '</select>'; //$_SESSION['value']=$value; ?> <form action="act09_process.php"> </br><input type='submit' value='Convert'/> </form> act09_process.php: Code: [Select] <?php session_start(); //$value=$_SESSION['value']; //echo $value; date_default_timezone_set('Asia/Manila'); $gmttime=date('M j, Y g:i:s A'); echo "The current date and time at" . " is " . $gmttime; ?> I've tried using session variables. I think I executed them incorrectly. The output is supposed to look like this: Hi, I am trying to create a drop down list in php and I want the data to come from a table that I have created in phpmyadmin. The code that I have created allows me to select values from the drop down list and insert the rest of the data. However when I check the the table the SID and Cid are set to 0 and the grade field is empty and the comments field contains the grade. The SID and Cid are both composite keys. <?php $sql = "SELECT Cid FROM course"; $db1 = new DBStudent_Course(); $db1->openDB(); $result = $db1->getResult($sql); echo"<select name = Cid>"; while ($row = mysql_fetch_object($result)) { echo "<option value = '" . $row->Cid . "'>$row->Cid</option>"; } echo"</select>"; echo "</p>"; ?> <?php $sql = "SELECT SID FROM student"; $db1 = new DBStudent_Course(); $db1->openDB(); $result = $db1->getResult($sql); echo"<select name = SID>"; while ($row = mysql_fetch_object($result)) { echo "<option value = '" . $row->SID . "'>$row->SID</option>"; } echo"</select>"; echo "</p>"; ?> <?php if (!$_POST) { //page loads for the first time ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> grade:<input type="text" name="grade"/><br/> comments:<input type="text" name="comments" /><br /> <input type="submit" value="Save" /> </form> <?php } else { $Cid = $_POST["Cid"]; $SID = $_POST["SID"]; $grade = $_POST["grade"]; $comments = $_POST["comments"]; $db1 = new DBStudent_Course(); $db1->openDB(); $numofrows = $db1->insert_student_course("", $SID, $Cid, $grade, $comments); echo "Success. Number of rows affected: <strong>{$numofrows}<strong>"; $db1->closeDB(); } ?> how do i loop this so that the option in the drop down list loop. i tried this but get an error Code: [Select] <select name="age"><?php for ($i=10; $i<71; $i++;) { echo "<option value='$i'>$i</option>"; } ?></select> Basically I have a form and What I want it to do is when a user selects the 'For Sale' radio button the minimum and maximum prices will be displayed in the drop down list as "70,000"+ but when the user selects the 'To Rent' radial button then the minimum and maximum drop down list prices will change to e.g. "200"+. How would I do this? Heres my Code for the form: Code: [Select] <div id="ptype"> <input type="radio" class="styled" name="ptype" value="forsale"/> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent"/> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any"/> Any </p> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td><div id="NB"> <select name="min bedrooms"> <?php $roomLimit = 5; for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){ if ($minRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minRooms\">$minRooms</option>"; } } ?> </select> to <select name="max bedrooms"> <?php $roomLimit = 5; for($maxRooms = 0; $maxRooms <= $roomLimit; $maxRooms++){ if ($maxRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxRooms\">$maxRooms</option>"; } } ?> </select> </div> </td> <td><p class="PR">Price range:</p></td> <td><div id="PR"> <select name="min price" style='width:80px;'> <?php $priceLimit = 350; for($minPrice = 40; $minPrice <= $priceLimit; $minPrice =( $minPrice+ 10)){ if ($minPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minPrice000\">£$minPrice,000</option>"; } } ?> </select> to <select name="max price" style='width:80px;'> <?php $priceLimit = 350; for($maxPrice = 40; $maxPrice <= $priceLimit; $maxPrice =( $maxPrice+ 10)){ if ($maxPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxPrice000\">£$maxPrice,000</option>"; } } ?> </select> Thanks in advance. Hello all,
I am new in php and would like to help me in in code.
I would like to implement a html form that will upload to my linux server some files, some info as well and will run a bash command.
To be more clear, users will:
Send to the linux server two files (I have done it).
Select from a drop down list a specific directory, and once this specific directory has been selected to activate one other drop down menu with its childs.
Send all those info to a bash script.
For case b, assume that we have the following structure
my_dir/cars/brand1
my_dir/cars/brand2
my_dir/cars/brand3
my_dir/motors/brand5
my_dir/motors/brand6
the first drop down list should list only cars and motors while the second only brand1, brand2, and brand3 if cars is selected or brand5 and brand6 if motors is selected.
For case c, once the form is submitted, I would like the command:
./script.sh –a uploadedfile1 –b uploadedfile2 –c dropdown1 –d dropdpwn2
Any help is appreciated.
Best,
Hey--I'm new to the forum, to php, and to web development in general. I am using php to populate a drop-down list from a MySQL database, and then echo the text in a field associated with the selected value below. I'm having no trouble creating the drop-down list, but I can't figure out how to echo the associated field below, or the ?Abbreviation=value that I expected in the url. Here is the php file: Code: [Select] <!DOCTYPE HTML> <html> <head> </head> <body> <form name="form" method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select> <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("calculators", $con); $result = mysql_query("SELECT * FROM calculator"); while($row = mysql_fetch_array($result)) { echo "<option type='text' name='Title' " . "value='" . $row['Title'] . "'>" . $row['Abbreviation'] . "</option>"; } mysql_close($con); ?> </select> <br> <input type="submit" name="submit"> </form> <?php echo $_GET['Title']; ?> </body> </html> This is what the source code looks like in the browser: Code: [Select] <!DOCTYPE HTML> <html> <head> </head> <body> <form name="form" method="GET" action="/calculators/index.php"> <select> <option type='text' name='Title' value='Mean Arterial Pressure'>MAP</option><option type='text' name='Title' value='Body Mass Index'>BMI</option></select> <br> <input type="submit" name="submit"> </form> </body> </html> And this is appearing in the url after I press submit: Code: [Select] ?submit=Submit I'm sorry if this is a silly question, or if I'm being long-winded in asking it. I'm very new to web development, and I'm not sure exactly what information is necessary to solve the problem. Also, though changes to the code are helpful, I may need an explanation to understand them... Thanks, Davis for some reason my code only posts the first word of the username even tho the last names are in the database. www.checkmyweave.co.uk/new/dropdown.php dropdown.php Quote <?php mysql_connect("localhost","****","****"); mysql_select_db("checkmyw_database") or die("Unable to select database"); ?> <form action="/new/dropdown2.php" Method="POST"> User:<select name="username"> <?php $result = mysql_query("SELECT * FROM members") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "<option value=".$row['username'].">"; echo $row['username']."</option>"; } ?> </select> <form action="/new/dropdown2.php" METHOD="POST"> <input type = "submit" value="New!"> </form> dropdown2.php Quote <?php $username=$_POST["username"]; echo $username ; ?> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316053.0 Okay, so, here's my dilemma. I'm wanting to have it so someone can edit an item in the database, but it is a dropdown menu for the options to choose from. How do I make it so that the option that the item currently is is what the default showing is? For instance, if the item is for a "warrior", it will show warrior already in the dropdown menu. However, I could go to the dropdown menu and select a different option if I wanted. The {{class}} doesn't seem to give that default. Right now, it just defaults to "All" regardless of what the item truly goes to, such as "warrior". Thanks in advance!! Here's what I have for the coding: <tr><td width="20%">Class:</td><td><select name="class" value="{{class}}"> <option value="1" {{class1select}}>All</option> <option value="2" {{class2select}}>Alchemist</option> <option value="3" {{class3select}}>Assassin</option> <option value="4" {{class4select}}>Dark Arts</option> <option value="5" {{class5select}}>Dark Paladin</option> <option value="6" {{class6select}}>Entertainer</option> <option value="7" {{class7select}}>Hunter</option> <option value="8" {{class8select}}>Mage</option> <option value="9" {{class9select}}>Monk</option> <option value="10" {{class10select}}>Paladin</option> <option value="11" {{class11select}}>Pirate</option> <option value="12" {{class12select}}>Priest</option> <option value="13" {{class13select}}>Psion</option> <option value="14" {{class14select}}>Scholar</option> <option value="15" {{class15select}}>Thief</option> <option value="16" {{class16select}}>Warlock</option> <option value="17" {{class17select}}>Warrior</option> </select></td></tr> I am new to PHP and currently trying to develop a website... i am stuck at one place. Lets say i'm a user(mrX) that has 4 types of car that are Ferrari, Lamborghini, Evo and BMW. So, i will register to the system about my details and all of my car info such as their cc, transmission, plat number, engine capacity. Then, i will log on into the system and after log on, there will be a drop down list. If i pick Ferrari for example, under the drop down list there will be all the information about the car. The same on the other car also. |