PHP - Drop Down List Of... Days In The Current Week
So I was wondering if anyone could come up with a good way of having a drop down box list the dates of the previous week starting from Saturday. The dates would need to go from Saturday to the coming/current friday.
Or would I just be better off having it list the days 'Saturday' to 'Friday'. Any thoughts? Similar TutorialsHi, I'm wanting to find rows whose date is within the next week of the current month of the current year. The format of the date is, for example: 2010-10-28 Any ideas guys? Thanks lots! Hi i have this drop down list current the year is 2010 and downwards but i want to change the list to 2010 upwards u can notice on the 50-- so shows current year minus so current is 2010 to 61 how can i change 2010 to 2030 or sunfin?? echo '<select name="year_of_birth">',"\n"; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { if($i == $thisYear) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; Hi guys. So I have a little coding down but I am stuck on this problem: /* Using only a array and a foreach loop, write a program that prints the days of the week *\ $days = array { 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', }; //This is where I need help with the code echo "$day \r\n"; ?> Thanks in advance! I am trying to create a loop that will work through the dates of the current month; I have the following piece of code for the loop: Code: [Select] $monthFloor = DateTime::createFromFormat('j H:i:s', '1 0:0:0'); $monthCeiling = DateTime::createFromFormat('j H:i:s', $monthFloor->format('t').' 0:0:0'); for ( $monthDate = DateTime::createFromFormat('Y-m-d H:i:s', $monthFloor->format('Y-m-d H:i:s')); $monthDate->format('d') <= $monthCeiling->format('d'); $monthDate->modify('+ 1 day') ) { echo $monthDate->format('Y-m-d H:i:s')."<br />"; } But when I run this, it loops through the dates of the current month twice!? why is it doing this? and how can I rectify the loop so it only goes through the month once? (continuing from topic title) So if I set a date of July 7 2011 into my script, hard coded in, I would like the current date to be checked against the hard coded date, and return true if the current date is within a week leading up to the hard coded date. How could I go about doing this easily? I've been researching dates in php but I can't seem to work out the best way to achieve what I'm after. Cheers Denno show list of files uploaded by current session user to the database. I want to show different users when they log in to the website...they can see a list of old files that they have uploaded. can anyone tell me the code/script to this.....please, ty 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'])) 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? Helllo 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 get this error Warning: current() [function.current]: Passed variable is not an array or object.. for this Code: [Select] $lastblock = current( ${"s".$row} ); print_r($lastblock); when i change to this it works.. Code: [Select] $lastblock = current( $s0 ); print_r($lastblock); The problem is i won't know the $row seeing as it is in a while loop. Solution? 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> 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> 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,
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 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(); } ?> 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: 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"; } ?> 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. 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 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! |