PHP - Huge Drop Down Box
I have a like 100 of these in a drop down box
and drop down box on html is really new to me Id like to put all the option values into one variable. but i dont know if the form works like that? cause I want to store the -1200 and not whats in the drop down box I feel like my approach with this is way off if someone could help guide me in a direction would appreciate it so I can say Code: [Select] <?php mysql_query("UPDATE users SET time_offset= '".mysql_real_escape_string($_POST['$________'])."' WHERE id = '".mysql_real_escape_string($_SESSION['user_id'])."'"); <select name="cars"> <option value="-1200">(GMT -1200) International Date Line West </option> <option value="-1100">(GMT -1100) Coordinated Universal Time -11 </option> <option value="-1100">(GMT -1100) Samoa </option> <option value="-1000">(GMT -1000) Hawaii </option> <option value="-0900">(GMT -0900) Alaska </option> ?> Similar TutorialsHello! I have a small question... I used to upload all my member's images in same directory, but now i've decided to put 1000 images in each directory Code: [Select] <?php $ID = $get_member_id_from_mySQL; if($ID >=0 AND $ID <=1000 ){ $directory_name='from0to1000'; } else if($ID >=1001 AND $ID <=2000 ){ $directory_name='from1001to2000'; } else if($ID >=2001 AND $ID <=3000 ){ $directory_name='from2001to3000'; } else if($ID >=3001 AND $ID <=4000 ){ $directory_name='from3001to4000'; } if(is_dir($directory_name)){ imagejpeg( $tmp_img, "{$directory_name}{$image_name}" ); }else{ mkdir("/path/to/my/$directory_name", 7777); imagejpeg( $tmp_img, "{$directory_name}{$image_name}" ); } ?> Is there any simpler way to continue with the IF function? Because I can't do this until 1000000 ? I need to validate the POST fields below except a few hidden inputs like User_id & category: They are not huge but i would not like to write for each a line of code like if(empty($_popst['field'])) ... How can simplify this by checking only if they are empty and display a message that lists all fields that were not filled? Code: [Select] array('user_id'=>$data['Id'], 'surname'=>$_POST['surname'], 'firstname'=>$_POST['firstname'], 'middlename'=>$_POST['middlename'], 'id_number'=>$_POST['id_number'], 'pin_number'=>$_POST['pin_number'], 'street'=>$_POST['street'], 'estate'=>$_POST['estate'], 'hse_number'=>$_POST['hse_number'], 'town'=>$_POST['town'], 'tele'=>$_POST['tele'], 'mobi'=>$_POST['mobi'], 'work_street'=>$_POST['work_street'], 'work_building'=>$_POST['work_building'], 'company'=>$_POST['company'], 'work_town'=>$_POST['work_town'], 'work_tele'=>$_POST['work_tele'], 'work_fax'=>$_POST['work_fax'], 'cont_surname'=>$_POST['cont_surname'], 'cont_firstname'=>$_POST['cont_firstname'], 'cont_middlename'=>$_POST['cont_middlename'], 'cont_street'=>$_POST['cont_street'], 'cont_building'=>$_POST['cont_building'], 'cont_company'=>$_POST['cont_company'], 'cont_home_tele'=>$_POST['cont_home_tele'], 'cont_office_tele'=>$_POST['cont_office_tele'], 'cont_mobi'=>$_POST['cont_mobi']); Hi, I have this text file with a 123mb size then i ran my simple script to read it and render it via browser $fh = fopen('worldcitiespop.txt',r); while(!feof($fh)) { $content = fgets($fh); echo $content."<br />"; } fclose($fh); I was expecting the 'whole' output via browser but then it didn't show "all" because when I opened the text file via a wordpad, it's really huge.. can you tell me what's wrong with my script ?...( btw, there's no max execution time error at all ) Hi Guys, I need a function which makes huge numbers normally readable... For example 1000000 must become 1.000.000 The same with smaller or lager numbers... Does someone know a simple solution ? Cheers Hi, I'm pretty new to this, so apologies if there's some simple solution/misunderstanding. It seems to me that when the user uploads a file, PHP pulls in the file into the temporary directory and then you can query it using the $_FILES array. Assuming I am correct so far, I have two questions: 1. Is there anyway to prevent the upload to the temporary folder based on file size? Seems to me a good way to overload a server to upload 10GB files, even if they are picked up as "errors" and deleted from the temp folder. 2. How long do files stay in the temporary folder? Does PHP delete them automatically, and if so, when? Thanks. I'm ok with PHP but probably not half as good as some of you guys on here. I am basically trying to find a way to grab a line from a huge and I mean huge text file.... its basically a list of keywords I want to call by line number but without preferably going through them all before I get to that line.....otherwise couldmcrash my server obviously. At the moment im using this Code: [Select] $lines = file('http://www.mysite.com/keywords.txt'); // Loop through our array, show HTML source as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { echo "$line_num"; } This works but im sure theres gotta be a better way of doing to save on usuage because this is putting the whole file into the memory and if I can simply say to php give me line number 97, would umm RULE.... Hope you guys can come up with a solution as your much smarter than me ty I am creating a form that will allow the user to select the make of vehicle "FORD" for example. If that make of vehicle is selected among different makes of vehicles, then another box will appear, with all the models for that particular model "Fiesta" for example. What type of code accomplishes this setup in my web page? I do not want to list 500 models in one drop down list, but just those for each make in the first drop down list. Thanks much! Hi All, I have 2 tables: one CarMake - CarMakeID - CarMakeDesc two CarModel - CarModelID - CarModelMake - CarModelDesc Depending on what the user selects in the first dropdown (carmake) the possible selection in the second dropdown (model) needs to be limited to only the models from the selected carmake. in the second table (Carmodel : the 'CarModelMake' = CarMakeID, to identify the make) How do I limit the dropdown 'CarModel' based on the selected CarMake in the first dropdown. link : http://98.131.37.90/postCar.php code : -- -- -- Code: [Select] <label> <select name="carmake" id="CarMake" class="validate[required]" style="width: 200px;"> <option value="">Select CAR MAKE...</option> <?php while($obj_queryCarMake = mysql_fetch_object($result_queryCarMake)) { ?> <option value="<?php echo $obj_queryCarMake->CarMakeID;?>" <?php if($obj_queryCarMake->CarMakeID == $CarAdCarMake) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryCarMake->CarMakeDesc;?></option> <?php } ?> </select> </label> <label> <select name="carmodel" id="CarModel" class="validate[required]" style="width: 200px;"> <option value="">Select MODEL...</option> <?php while($obj_queryCarModel = mysql_fetch_object($result_queryCarModel)) { ?> <option value="<?php echo $obj_queryCarModel->CarModelID;?>" <?php if($obj_queryCarModel->CarmodelID == $CarAdCarModel) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryCarModel->CarModelDesc;?></option> <?php } ?> </select> </label> I'm a novice.. and appreciates all the help ! Hi all, ive got a script ive finishing coding from the other day, but ive got a slight problem with it. <?php if ($fetch->missions == "4"){ // Mission 4, Toyota Aygo up to 500MPH $car = "Toyota Aygo"; if ($garage->car == $car && $garage->mph == "500"){ $rightcar = "Yes"; }else{ $rightcar = "No"; } if (strip_tags($_POST['submit'])){ if ($rightcar == "Yes"){ echo ("<table width='30%' cellpadding='0' align='center' cellspacing='0' border='1' class='table'> <tr> <td class='header' align='center'>Well Done!</td> </tr> <tr> <td>You Successfully Completed Mission 3!</td> </tr> </table><br />"); $newmoney = $fetch->money + 70000000; $newrep = $fetch->rep + 750000; mysql_query ("UPDATE users SET money='$newmoney' WHERE username='$username'"); mysql_query ("UPDATE users SET rep='$newrep' WHERE username='$username'"); mysql_query ("UPDATE users SET missions='5' WHERE username='$username'") or die ("Error - Query : Line 121 : " . mysql_error()); mysql_query ("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$username', 'System', 'Well done! <br /> As You completed Mission 4 Successfully we will reward you with<br /> £70,000,000 Money<br /> 750,000 Rep!', '$date', '0', '0', '0' )"); } } } // Mission 4 ?> <?php if ($fetch->missions == "4"){ ?> <form action="" method="POST" name="mission4"> <table width="50%" cellpadding="0" cellspacing="0" border="1" class="table" align="center"> <tr> <td class='header' align='center'>Mission 4</td> </tr> <tr> <td>Now SD Stars can now see your progressing, they have asked you if you can get a Toyota Aygo up to 500MPH. You must get it to them without any damage to prove your werthy!</td> </tr> <tr> <td align='center' class='header'>Select Your Car:</td> </tr> <tr> <td><select class="dropbox"> <option selected>Pick Car</option> <?php $get=mysql_query("SELECT * FROM garage WHERE owner='$username' AND car='Toyota Aygo' AND mph='500'"); while($stats=mysql_fetch_object($get)){ echo "<option value=?carname=$stats->id>$stats->car, $stats->damage%, $stats->mph MPH</option>"; } ?></select></td> </tr> <tr> <td class='omg'><input type="submit" name="submit" class="button" value="Send Car!"></td> </tr> </table> </form> <?php } ?> I blive it works apart from the Drop Down Box. It selects all the cars its suppose to but when I pick the car and press submit it just basicly refreshes the page :S. I'm not sure why its doing it . Can any one else see the problem? Thanks for any help given Hi all, ive just coded a new thing for my website which lets users upgrade there car to a certain speed, its all coded and works fine, but im just not sure how todo one thing on it. <?php $getall = mysql_query("SELECT car, id FROM garage WHERE owner='$username'"); while($row = mysql_fetch_array($getall)){ echo $row['car']. " - ". $row['id']; echo "<br />"; } ?> That bit of my code, select the car and the car ID from my table garage, but i'm wanting it in a drop down box which shows all the cars in there garage, but not sure how I would do this. Any advice? Thanks. hi how do i get the id value from the dropdown selection from the database Here is my code. i need the id to store it another table to refer it in my application. its like a categories and subcategories table. <html> <form id="name" action="<?php $_POST['SERVER_SELF'] ?>" method="POST" > <input type="text" name="name1"> <br> <select name="select"> <?php mysql_connect('localhost','root','') or die('Could not connect to mysql ' . mysql_error()); // error message mysql_select_db("dbtest") or die(mysql_error()); $query = "select name,id from main"; $result = mysql_query($query); if ($query) { while ($row = mysql_fetch_array($result)) { $strB=$row['name']; ?> <option value="<?php $stra ?>"><?php echo $strB ?></option> <br> <?php } } ?> </select> <input type="text" name="name2"> <br> <input type="submit" name="submit1"> </form> <?php if(isset($_POST['submit'])) { //$name=$_POST['val']; $strB=$stra; mysql_connect('localhost','root','') or die('Could not connect to mysql ' . mysql_error()); // error message mysql_select_db("dbtest") or die(mysql_error()); $query = "insert into sub (sub) values('$strB')"; $result = mysql_query($query); if ($query) { echo "query executed"; } } ?> </html> thanks Hello, must admit i'm very new to this and just a hobiest , I am creating a page which will be used for logging information. With a mysql database i have two tables "tbl_rides" & "tbl_courses" rides is the main table for storing information and has a foreign key associating column "course_id" with course_id in the tbl_courses What i want to do on a HTML/PHP page is display a drop down box that has the contents of "course" from the tbl_courses but when the user selects it and submits the record is written to the main form "tbl_rides" "course_id" so display the friendly name via the foreign key but the record is written to "tbl_rides" Can that be done .. am i going about this wrong ?
Thanks for any help Andrew. The code for the drop down: Code: [Select] echo '<select name="select" ONCHANGE="goto(this.form)">'; while ($dropDown > 0) { if ($page == $dropDown) { $selected = 'selected="selected"'; } else { $selected = ""; } echo "<option value=\"searchFlights.php?page=" . $dropDown . "\" $selected>" . $dropDown . "</option>"; $dropDown = $dropDown - 1; } echo '</select>'; It works fine, but I want 1 to be at the top of the list and go down from there because right now, it starts with the biggest number and goes down. Any suggestions? Thanks! trying to get my drop down box to display more then one result. I have two users with Mod wrote in the column Monitor but right now it only displays just the one. So I need to display all the goaulds that have mod in the monitor column <?php Code: [Select] $result = mysql_query("SELECT goauld FROM users WHERE monitor ='mod' ORDER BY id DESC") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { if($row['goauld'] == $_POST['name_list']){ echo '<div class="containerc">'; echo '<div class="search">'; echo '<form method="post" >'; echo '<select name="name_list" class="textbox" id="name_list">'; echo "<option value=\"".$row['goauld']."\">".$row['goauld']."</option>"; echo "<option selected=\"selected\" value=\"".$row['goauld']."\">".$row['goauld']."</option>"; echo '</select>'; echo '<input type="submit" name="remove" id="remove" value="Remove">'; } } } '</form>'; '</div>'; '</div>'; ?> Hello, I'm trying to use a dropdown to display different divs. <html> <head> <title>DDlist Div Display</title> <script type="text/javascript"> function ShowDivArea(info) { var sel = document.getElementById('divArea').getElementsByTagName('div'); for (var i=0; i<sel.length; i++) { sel.style.display = 'none'; } if (info == '0') { return; } document.getElementById('divArea'+info).style.display = 'block'; } </script> <style type="text/css"> .divArea { display:none; height:100px; width:200px; border:1px solid red; } </style> </head> <body> <select id="DDDivList" onchange="ShowDivArea(this.selectedIndex)"> <option value="0" selected> -- Select A Design Service --</option> <option value="1"> QR Bookmark </option> <option value="2"> Twitter </option> <option value="3"> Ning or Tumblr </option> <option value="4"> Flyers </option> <option value="5"> Business Card or Brochure</option> <option value="6"> Album or Mixtape cover</option> <option value="7"> Other</option> </select> <div id="divArea"> <div id="divArea1" class="divArea"> <h1>QR Bookmarks</h1> <form action='qrgen.php' method='POST'> <input type='text' name='bmarksite'> URL<br> <input type='text' name='sitedesc'> Description<br> <input type='submit' value='Convert'><br> <?php include("QrCodes.php") ?> <?php $bmarksite = $_POST['bmarksite']; $sitedesc = $_POST['sitedesc']; if ($sitedesc&&$bmarksite) { $qrcode = new QrCodes; $qrcode -> IsImage =1; echo $qrcode -> GetBookmark("$bmarksite","$sitedesc"); echo "</br>"; echo $bmarksite; echo "</br>"; print $sitedesc; } else { echo "Please fill in all the required fields."; } ?> </div> <div id="divArea2" class="divArea">Twitter</div> <div id="divArea3" class="divArea">Ning or Tumblr</div> <div id="divArea4" class="divArea">Flyers</div> <div id="divArea5" class="divArea">Business Card or Brochure</div> <div id="divArea6" class="divArea">Album or Mixtape Cover</div> <div id="divArea7" class="divArea">Other</div> </div> </body> </html> The problem is with this line: <form action='qrgen.php' method='POST'>. I am using a wordpress page template. What should I change the qrgen.php to? Or how do I get it to work? Thank you for your help. Holy smoke, it has been a looooooong time since I have been here. Love the new look of the site btw. Well I am working on a new project for my church. The idea is an email to SMS program. So one use of this would be that if there is a youth activity I could send a message to the entire youth group with one message. I am trying to figure out something specific with it. I need to create a form that grabs info from the database. So more specifically what I need is one drop down that will have "Youth Group", "Parents", "Deacons", etc. now based on what I select I need the second drop down to populate with the corresponding people in that group. Now I want an "All" to be in the drop down to which would let me send the message I type to ALL people in the desired group but to also have the individual names come up just in case I need to do a specific person. How would I go about doing something like this? I have done much research and cant quite find what I would need to do. Any help would be GREATLY appreciated. hey guys just a quick one i want a drop down box which is populated from a mysql query which is eay enough but also at the same time i also want the dropdown box to look at the current record and have the value in the drop down box e.g. the drop down has values 1, 2, 3, 4, 5 in it which are pulled from a table called values the current record is from a table called staff and it has an id of 45 and a user level of 3 i want the drop down to have all the values selectable to update the record but on load it will have 3 as the current, i want to be able to chage this 3 to a 5 and update the record how can i do this.? just a brief code example would be awsome and ill adopt it to fit Hi. I have drop down boxes for date and time that work. The year is a problem because I am using variables instead of fixed values. Code: [Select] <select name="Year" style="width:60px"> <option value="2010" >Test <option value="<?=$ThisYear?>" <? if ($Year == "<?=$ThisYear?>"){?> SELECTED <?}?> ><?=$ThisYear?> <option value="<?=$NextYear?>" <? if ($Year == "<?=$NextYear?>"){?> SELECTED <?}?> ><?=$NextYear?> </select> <select name="Hour" style="width:50px"> <option value="10" <? if ($_SESSION["Hour"] == "10"){?> SELECTED <?}?> >10 <option value="11" <? if ($_SESSION["Hour"] == "11"){?> SELECTED <?}?> >11 <option value="12" <? if ($_SESSION["Hour"] == "12"){?> SELECTED <?}?> >12 <option value="13" <? if ($_SESSION["Hour"] == "13"){?> SELECTED <?}?> >13 <option value="14" <? if ($_SESSION["Hour"] == "14"){?> SELECTED <?}?> >14 <option value="15" <? if ($_SESSION["Hour"] == "15"){?> SELECTED <?}?> >15 <option value="16" <? if ($_SESSION["Hour"] == "16"){?> SELECTED <?}?> >16 <option value="17" <? if ($_SESSION["Hour"] == "17"){?> SELECTED <?}?> >17 <option value="18" <? if ($_SESSION["Hour"] == "18"){?> SELECTED <?}?> >18 <option value="19" <? if ($_SESSION["Hour"] == "19"){?> SELECTED <?}?> >19 <option value="20" <? if ($_SESSION["Hour"] == "20"){?> SELECTED <?}?> >20 </select> however this works Code: [Select] <select name="Year" style="width:60px"> <option value="2010" >Test <option value="<?=$ThisYear?>" <? if ($Year == "2011"){?> SELECTED <?}?> ><?=$ThisYear?> <option value="<?=$NextYear?>" <? if ($Year == "2012"){?> SELECTED <?}?> ><?=$NextYear?> </select> Can anyone help with this please TIA Desmond. im fairly new to php so tend to do trial and error..... more error than trial tbh. im wondering if it is possible to get a drop down menu to fill from a mysql database and to arrange it alphabetically. i have created the menu just dont know how to arrange it better. also how can i use the items id in drop menu to load other info from that row on the database. hope you can help me. Code: [Select] <FORM> <?php $result = mysql_query( "SELECT * FROM movie_info" ) ; echo "<select name= film onChange='submit()' >film name</option>"; while ($nt=mysql_fetch_array($result)){ ?> <?php echo "<option value='$nt[id]'>$nt[title] </option>"; } ?> </select> </FORM> I really can't get my head around this dynamic drop box. What I want is for a drop box to be populated with values in my database. I have this that connects to my SQL and picks out the table required: function displayUsers(){ global $database; $q = "SELECT username," ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username"; $result = $database->query($q); ... I then have this to pick out any errors, and also using the num_rows to get the number of rows (values) there a $num_rows = mysql_numrows($result); if(!$result || ($num_rows < 0)){ echo "Error displaying info"; return; } if($num_rows == 0){ echo "Database table empty"; return; } From here, I guess I want the num_rows to keep 'adding on' the number of <option value=""> in my selection box according the number of values I have in my database. At this point, I can pull out the values into a dynamic table ... but I want it into a drop box -- but I'll but up the code for the dynamic table so you can get an idea: /* Display table contents */ echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"; echo "<tr><td><b>Username</b></td></tr>\n"; for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"username"); echo "<tr><td>$uname</td></tr>\n"; } echo "</table><br>\n"; } I hope you can use the code above to help me develop this darn drop box! Thanks, Ollie! |