Jump to content

wispas

Members
  • Posts

    71
  • Joined

  • Last visited

    Never

Everything posted by wispas

  1. no worries figured it out. ha a value in there... lol
  2. I am using a date picker from the internet and not very good with jscript... teh calender popup works really well... just need it to display the current date... anyone good with javascript can help me out... thank you very much. /* * DatePicker * @author Rick Hopkins * @modified by Micah Nolte and Martin Vašina * @version 0.3.2 * @classDescription A date picker object. Created with the help of MooTools v1.11 * MIT-style License. -- start it up by doing this in your domready: $$('input.DatePicker').each( function(el){ new DatePicker(el); }); */ var DatePicker = new Class({ /* set and create the date picker text box */ initialize: function(dp){ // Options defaults this.dayChars = 1; // number of characters in day names abbreviation this.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; this.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; this.format = 'mm/dd/yyyy'; this.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; this.startDay = 7; // 1 = week starts on Monday, 7 = week starts on Sunday this.yearOrder = 'asc'; this.yearRange = 10; this.yearStart = (new Date().getFullYear()); // Finds the entered date, or uses the current date if(dp.value != '') { dp.then = new Date(dp.value); dp.today = new Date(); } else { dp.then = dp.today = new Date(); } // Set beginning time and today, remember the original dp.oldYear = dp.year = dp.then.getFullYear(); dp.oldMonth = dp.month = dp.then.getMonth(); dp.oldDay = dp.then.getDate(); dp.nowYear = dp.today.getFullYear(); dp.nowMonth = dp.today.getMonth(); dp.nowDay = dp.today.getDate(); // Pull the rest of the options from the alt attr if(dp.alt) { options = Json.evaluate(dp.alt); } else { options = []; } dp.options = { monthNames: (options.monthNames && options.monthNames.length == 12 ? options.monthNames : this.monthNames) || this.monthNames, daysInMonth: (options.daysInMonth && options.daysInMonth.length == 12 ? options.daysInMonth : this.daysInMonth) || this.daysInMonth, dayNames: (options.dayNames && options.dayNames.length == 7 ? options.dayNames : this.dayNames) || this.dayNames, startDay : options.startDay || this.startDay, dayChars : options.dayChars || this.dayChars, format: options.format || this.format, yearStart: options.yearStart || this.yearStart, yearRange: options.yearRange || this.yearRange, yearOrder: options.yearOrder || this.yearOrder }; dp.setProperties({'id':dp.getProperty('name'), 'readonly':true}); dp.container = false; dp.calendar = false; dp.interval = null; dp.active = false; dp.onclick = dp.onfocus = this.create.pass(dp, this); }, /* create the calendar */ create: function(dp){ if (dp.calendar) return false; // Hide select boxes while calendar is up if(window.ie6){ $$('select').addClass('dp_hide'); } /* create the outer container */ dp.container = new Element('div', {'class':'dp_container'}).injectBefore(dp); /* create timers */ dp.container.onmouseover = dp.onmouseover = function(){ $clear(dp.interval); }; dp.container.onmouseout = dp.onmouseout = function(){ dp.interval = setInterval(function(){ if (!dp.active) this.remove(dp); }.bind(this), 500); }.bind(this); /* create the calendar */ dp.calendar = new Element('div', {'class':'dp_cal'}).injectInside(dp.container); /* create the date object */ var date = new Date(); /* create the date object */ if (dp.month && dp.year) { date.setFullYear(dp.year, dp.month, 1); } else { dp.month = date.getMonth(); dp.year = date.getFullYear(); date.setDate(1); } dp.year % 4 == 0 ? dp.options.daysInMonth[1] = 29 : dp.options.daysInMonth[1] = 28; /* set the day to first of the month */ var firstDay = (1-(7+date.getDay()-dp.options.startDay)%7); /* create the month select box */ monthSel = new Element('select', {'id':dp.id + '_monthSelect'}); for (var m = 0; m < dp.options.monthNames.length; m++){ monthSel.options[m] = new Option(dp.options.monthNames[m], m); if (dp.month == m) monthSel.options[m].selected = true; } /* create the year select box */ yearSel = new Element('select', {'id':dp.id + '_yearSelect'}); i = 0; dp.options.yearStart ? dp.options.yearStart : dp.options.yearStart = date.getFullYear(); if (dp.options.yearOrder == 'desc'){ for (var y = dp.options.yearStart; y > (dp.options.yearStart - dp.options.yearRange - 1); y--){ yearSel.options[i] = new Option(y, y); if (dp.year == y) yearSel.options[i].selected = true; i++; } } else { for (var y = dp.options.yearStart; y < (dp.options.yearStart + dp.options.yearRange + 1); y++){ yearSel.options[i] = new Option(y, y); if (dp.year == y) yearSel.options[i].selected = true; i++; } } /* start creating calendar */ calTable = new Element('table'); calTableThead = new Element('thead'); calSelRow = new Element('tr'); calSelCell = new Element('th', {'colspan':'7'}); monthSel.injectInside(calSelCell); yearSel.injectInside(calSelCell); calSelCell.injectInside(calSelRow); calSelRow.injectInside(calTableThead); calTableTbody = new Element('tbody'); /* create day names */ calDayNameRow = new Element('tr'); for (var i = 0; i < dp.options.dayNames.length; i++) { calDayNameCell = new Element('th'); calDayNameCell.appendText(dp.options.dayNames[(dp.options.startDay+i)%7].substr(0, dp.options.dayChars)); calDayNameCell.injectInside(calDayNameRow); } calDayNameRow.injectInside(calTableTbody); /* create the day cells */ while (firstDay <= dp.options.daysInMonth[dp.month]){ calDayRow = new Element('tr'); for (i = 0; i < 7; i++){ if ((firstDay <= dp.options.daysInMonth[dp.month]) && (firstDay > 0)){ calDayCell = new Element('td', {'class':dp.id + '_calDay', 'axis':dp.year + '|' + (parseInt(dp.month) + 1) + '|' + firstDay}).appendText(firstDay).injectInside(calDayRow); } else { calDayCell = new Element('td', {'class':'dp_empty'}).appendText(' ').injectInside(calDayRow); } // Show the previous day if ( (firstDay == dp.oldDay) && (dp.month == dp.oldMonth ) && (dp.year == dp.oldYear) ) { calDayCell.addClass('dp_selected'); } // Show today if ( (firstDay == dp.nowDay) && (dp.month == dp.nowMonth ) && (dp.year == dp.nowYear) ) { calDayCell.addClass('dp_today'); } firstDay++; } calDayRow.injectInside(calTableTbody); } /* table into the calendar div */ calTableThead.injectInside(calTable); calTableTbody.injectInside(calTable); calTable.injectInside(dp.calendar); /* set the onmouseover events for all calendar days */ $$('td.' + dp.id + '_calDay').each(function(el){ el.onmouseover = function(){ el.addClass('dp_roll'); }.bind(this); }.bind(this)); /* set the onmouseout events for all calendar days */ $$('td.' + dp.id + '_calDay').each(function(el){ el.onmouseout = function(){ el.removeClass('dp_roll'); }.bind(this); }.bind(this)); /* set the onclick events for all calendar days */ $$('td.' + dp.id + '_calDay').each(function(el){ el.onclick = function(){ ds = el.axis.split('|'); dp.value = this.formatValue(dp, ds[0], ds[1], ds[2]); this.remove(dp); }.bind(this); }.bind(this)); /* set the onchange event for the month & year select boxes */ monthSel.onfocus = function(){ dp.active = true; }; monthSel.onchange = function(){ dp.month = monthSel.value; dp.year = yearSel.value; this.remove(dp); this.create(dp); }.bind(this); yearSel.onfocus = function(){ dp.active = true; }; yearSel.onchange = function(){ dp.month = monthSel.value; dp.year = yearSel.value; this.remove(dp); this.create(dp); }.bind(this); }, /* Format the returning date value according to the selected formation */ formatValue: function(dp, year, month, day){ /* setup the date string variable */ var dateStr = ''; /* check the length of day */ if (day < 10) day = '0' + day; if (month < 10) month = '0' + month; /* check the format & replace parts // thanks O'Rey */ dateStr = dp.options.format.replace( /dd/i, day ).replace( /mm/i, month ).replace( /yyyy/i, year ); dp.month = dp.oldMonth = '' + (month - 1) + ''; dp.year = dp.oldYear = year; dp.oldDay = day; /* return the date string value */ return dateStr; }, /* Remove the calendar from the page */ remove: function(dp){ $clear(dp.interval); dp.active = false; if (window.opera) dp.container.empty(); else if (dp.container) dp.container.remove(); dp.calendar = false; dp.container = false; $$('select.dp_hide').removeClass('dp_hide'); } }); this is the html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>MooTools DatePicker Example</title> <script type="text/javascript" src="mootools.v1.11.js"></script> <script type="text/javascript" src="DatePicker.js"></script> <script type="text/javascript"> // The following should be put in your external js file, // with the rest of your ondomready actions. window.addEvent('domready', function(){ $$('input.DatePicker').each( function(el){ new DatePicker(el); }); }); </script> <link href="DatePicker.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="yep"> <p> <label for="birthday">default calendar</label> <input id="birthday" name="birthday" type="text" class="DatePicker" tabindex="1" value="10/24/2016" /> </p> </div> </body> </html>
  3. I have a simple form with a text area. i add 2 line breaks to start a new paragraph and insert it into the mysql database. so i retrieve the post data: $city_desc = $_POST['city_desc'] ; and it will stick all of the data together when i output with php.. i want it to retain the 2 line breaks so they are like new paragraphs... any ideas?
  4. Haha - can you do it... lol. Simple enough i managed to get a upload script working: <form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php $target = "images/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } ?> It does not display the image and link when i have uploaded the image. Anyone know why?
  5. Not sure if this is possible but what i want to do is have a form field and a text input: <form name="myForm"> <input type="text" name="img_url" id="img_url" /> </form> There will be a upload button next to it and when selected will allow user to select file and upload to a folder called 'images' - it will then generate a link with full directory path and if possible will automatically add the link inside the input field... does anyone know if this is possible and would be so kindly show me how to do it. thanks!
  6. Im doing this bit wrong: <?php echo "var thetext4 = new Array('".implode('\',\'','<img src="'.$row["hotel_img"].'" >')."');"; ?> Initially it was <?php echo "var thetext4 = new Array('".implode('\',\'',$hotel_img)."');"; ?> But this only displays a URL but i want it to display the image instead of a URL.
  7. Currently all of my implodes displays as text strings properly... i have a field called 'hotel_img' which contains a URL to an image in my MySQL database... but im not sure if i am doing it properly here as the image does not load: <?php // Connect database include("includes/connectdb.php"); $sql="SELECT hotel_id, hotel_name, hotel_location, hotel_desc, hotel_img FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); $options=""; $id_array = array(); $hotel_name = array(); $hotel_location = array(); $hotel_desc = array(); $hotel_img = array(); while ($row=mysql_fetch_array($result)) { $id_array[]=$row["hotel_id"]; $hotel_name[]=mysql_real_escape_string($row["hotel_name"]); $hotel_location[]=mysql_real_escape_string($row["hotel_location"]); $hotel_desc[]=mysql_real_escape_string($row["hotel_desc"]); $hotel_img[]=mysql_real_escape_string($row["hotel_img"]); $options.="<option VALUE='".$row["hotel_id"]."'>".$row["hotel_name"]."</option>"; } ?> I am using implode and it works with the strings: <?php echo "var thetext1 = new Array('".implode('\',\'',$hotel_name)."');"; ?> <?php echo "var thetext2 = new Array('".implode('\',\'',$hotel_location)."');"; ?> <?php echo "var thetext3 = new Array('".implode('\',\'',$hotel_desc)."');"; ?> <?php echo "var thetext4 = new Array('".implode('\',\'','<img src="'.$row["hotel_img"].'" >')."');"; ?> Not sure what have done wrong... any ideas?
  8. Thanks Neil. I have also done this which also works: <?php include('includes/config.php'); $tbl_name="city"; // Table name // Get values from form $city_name = mysql_real_escape_string($_POST['city_name']) ; $city_desc = mysql_real_escape_string($_POST['city_desc']) ; $city_meta_keywords = mysql_real_escape_string($_POST['city_meta_keywords']) ; $city_meta_desc = mysql_real_escape_string($_POST['city_meta_desc']) ; // Insert data into mysql $sql="INSERT INTO $tbl_name(city_name, city_desc, city_meta_keywords, city_meta_desc)VALUES('$city_name', '$city_desc', '$city_meta_keywords', '$city_meta_desc')"; $result=mysql_query($sql); ?>
  9. I need help adding a mysql_real_escape_string into my code as whenever i insert a ' into my city description it gives me a error and does not insert into the database... please help. <?php include('includes/config.php'); $tbl_name="city"; // Table name // Get values from form $city_name=$_POST['city_name']; $city_desc=$_POST['city_desc']; // Insert data into mysql $sql="INSERT INTO $tbl_name(city_name, city_desc)VALUES('$city_name', '$city_desc')"; $result=mysql_query($sql); ?>
  10. Thanks so much Keith for helping me out. Some of my database fields will not load such as the 'hotel_desc'. I am getting the following error when i check the error console: Error: missing ) after argument list Line: 25, Column: 48 Source Code: ue New York, NY 10016','Cavendish Row,, Upper O'Connell Street Dublin 1, Co. Dublin, Ireland','Calle Barcelonina 5 46002 Valencia, Spain','263 Hollywood Road','Via Vittorio Bachelet, 4 00185 Roma (Lazio), Italy','2880 Las Vegas Blvd S Las Vegas, NV 89109, is there something i can put in there to allow the ' to be used. Thanks!
  11. Hi Keith, Script works really well. Thank you so so much... One last thing... if i was to add another field like 'hotel_location' to: <?php echo "var thetext1 = new Array('".implode('\',\'',$hotel_desc)."');"; ?> how would that work?
  12. Hi Keith, I have opened the error console and am getting the following error: "thetext1 is not defined" I have also copied and pasted the code:
  13. Hi Keith. Thanks for the help. Much appreciated. It seems to now load all of the hotel names in the drop down but does not seem to show the description beside it.
  14. Hi Keith, Im a bit lost at the moment working in the code. Can you help me out with it... heres what i have so far: <?php // Connect database include("includes/connectdb.php"); $sql="SELECT hotel_id, hotel_name, hotel_location, hotel_desc FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); $options=""; $id_array = array(); $hotel_name = array(); $hotel_location = array(); $hotel_desc = array(); while ($row=mysql_fetch_array($result)) { $id_array[]=$row["hotel_id"]; $hotel_name[]=$row["hotel_name"]; $hotel_location[]=$row["hotel_location"]; $hotel_desc[]=$row["hotel_desc"]; $options.="<option VALUE='".$row["hotel_id"]."'>".$row["hotel_location"]."</option>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <!--Example drop down menu 1--> <form name="form1"> <select name="select1" size="1" style="background-color:#FFFFD7" onChange="displaydesc(document.form1.select1, thetext1, 'textcontainer1')"> <option selected value="http://www.javascriptkit.com">JavaScript Kit </option> <option value="http://freewarejava.com">Freewarejava.com</option> <option value="http://wired.com" target="newwin">Wired News</option> <option value="http://www.news.com">News.com</option> <option value="http://www.codingforums.com" target="newwin">Coding Forums</option> </select> <span id="textcontainer1" align="left" style="font:italic 13px Arial"> </span> </form> <script type="text/javascript"> var thetext1=new Array() thetext1[0]="Comprehensive JavaScript tutorials and over 400+ free scripts" thetext1[1]="Direct link to hundreds of free Java applets online!" thetext1[2]="Up to date news on the technology front" thetext1[3]="News.com- The #1 technology News site." thetext1[4]="Web Coding and development forums" // Now, see 2) below for final customization step function displaydesc(which, descriptionarray, container){ if (document.getElementById) document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex] } function jumptolink(what){ var selectedopt=what.options[what.selectedIndex] if (document.getElementById && selectedopt.getAttribute("target")=="newwin") window.open(selectedopt.value) else window.location=selectedopt.value } displaydesc(document.form1.select1, thetext1, 'textcontainer1') </script> </body> </html>
  15. I am following another tutorial now and it is changing very well depending on what i am selecting... i want to use my database data instead... can you show me how i can do this please? <?php // Connect database include("includes/connectdb.php"); $sql="SELECT hotel_id, hotel_name, hotel_desc FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <!--Example drop down menu 1--> <form name="form1"> <select name="select1" size="1" style="background-color:#FFFFD7" onChange="displaydesc(document.form1.select1, thetext1, 'textcontainer1')"> <option selected value="http://www.javascriptkit.com">JavaScript Kit </option> <option value="http://freewarejava.com">Freewarejava.com</option> <option value="http://wired.com" target="newwin">Wired News</option> <option value="http://www.news.com">News.com</option> <option value="http://www.codingforums.com" target="newwin">Coding Forums</option> </select> <span id="textcontainer1" align="left" style="font:italic 13px Arial"> </span> </form> <!--IMPORTANT: Below script should always follow all of your HTML codes above, and never proceed them--> <!--To be safe, just add below script at the end of your page--> <script type="text/javascript"> /*********************************************** * Drop down menu w/ description- © Dynamic Drive (www.dynamicdrive.com) * This notice must stay intact for use * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ //1) CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE var thetext1=new Array() thetext1[0]="Comprehensive JavaScript tutorials and over 400+ free scripts" thetext1[1]="Direct link to hundreds of free Java applets online!" thetext1[2]="Up to date news on the technology front" thetext1[3]="News.com- The #1 technology News site." thetext1[4]="Web Coding and development forums" /// You may define additional text arrays if you have multiple drop downs: var thetext2=new Array() thetext2[0]="CNN- US and World News." thetext2[1]="MSNBC- NBC News online." thetext2[2]="BBC News- Updated every minute of every day." thetext2[3]="TheRegister- Daily IT news." // Now, see 2) below for final customization step function displaydesc(which, descriptionarray, container){ if (document.getElementById) document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex] } function jumptolink(what){ var selectedopt=what.options[what.selectedIndex] if (document.getElementById && selectedopt.getAttribute("target")=="newwin") window.open(selectedopt.value) else window.location=selectedopt.value } //2) Call function displaydesc() for each drop down menu you have on the page // This function displays the initial description for the selected menu item // displaydesc(name of select menu, name of corresponding text array, ID of SPAN container tag): // Important: Remove the calls not in use (ie: 2nd line below if there's only 1 menu on your page) displaydesc(document.form1.select1, thetext1, 'textcontainer1') </script> </body> </html>
  16. Hi Kickstart, Really appreciate the help. Im not sure where to begin editing this. It comes up as blank when i test it.
  17. <?php // Connect database include("includes/connectdb.php"); $sql="SELECT hotel_id, hotel_name, hotel_location, hotel_desc FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["hotel_id"]; $hotel_name=$row["hotel_name"]; $hotel_location=$row["hotel_location"]; $hotel_desc=$row["hotel_desc"]; $options.="<OPTION VALUE=\"$id\">".$hotel_name." (".$hotel_location.")"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script language="javascript"> function disp_text() { var w = document.myform.mylist.selectedIndex; var selected_text = document.myform.mylist.options[w].text; document.getElementById('someDivName').innerHTML = selected_text; //alert(selected_text); } </script> <title>PHP Dynamic Drop Down Menu</title> </head> <body> <form id="myform" name="myform" method="post" action="selected.php"> <SELECT NAME="mylist" onChange="disp_text()"> <OPTION VALUE=0>Choose <?=$options.="<OPTION VALUE=\"$id\">".$hotel_name.'</option>';?> </SELECT> </form> <div id='someDivName'></div> </body> </html>
  18. I currently have a drop down that displays a list of hotel names and upon selection it will show the name in the div container... but i want it to show me more that just the hotel name like the hotel description as well. i want the drop down to only show the hotel name, but when selected for it to show the hotel name and hotel description. Can someone help me with this please.
  19. <?php // Limit $summary to how many characters? $limit = 57; $summary = <<< summary Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text summary; if (strlen($summary) > $limit) $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...'; echo $summary; function bigone() { $limit = 100; echo $summary; } ?>
  20. I currently have a script that will limit the amount of words string. instead i want it to display all of the text upon clicking a read more link at the end. is this possible with php?
  21. thanks so much 'kickstart'. worked well!!!!!!
  22. Like the title says, i want to have a paragraph of text and shorten it to 25 characters... it will have a read more button and when clicked it will expand all of the text. not sure if this is php... if so does anyone know what this is called and how this is done. thanks!
  23. I got an alert to work now.... when i select from the lists it will give me an alert box telling me of the selected item... does anyone know how to get that text to display in a div instead of an alert box. <?php // Connect database include("includes/connectdb.php"); $sql="SELECT hotel_id, hotel_name, hotel_location FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["hotel_id"]; $hotel_name=$row["hotel_name"]; $hotel_location=$row["hotel_location"]; $options.="<OPTION VALUE=\"$id\">".$hotel_name." (".$hotel_location.")"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script language="javascript"> function disp_text() { var w = document.myform.mylist.selectedIndex; var selected_text = document.myform.mylist.options[w].text; alert(selected_text); } </script> <title>PHP Dynamic Drop Down Menu</title> </head> <body> <form id="myform" name="myform" method="post" action="selected.php"> <SELECT NAME="mylist" onChange="disp_text()"> <OPTION VALUE=0>Choose <?=$options.="<OPTION VALUE=\"$id\">".$hotel_name.'</option>';?> </SELECT> </form> </body> </html>
  24. Heres my code so far: <?php // Connect database include("includes/connectdb.php"); $sql="SELECT hotel_id, hotel_name FROM hotel ORDER BY hotel_name ASC"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["hotel_id"]; $hotel_name=$row["hotel_name"]; $options.="<OPTION VALUE=\"$id\">".$hotel_name; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP Dynamic Drop Down Menu</title> </head> <body> <form id="form1" name="form1" method="post" action="selected.php"> <SELECT NAME=id> <OPTION VALUE=0>Choose <?=$options.="<OPTION VALUE=\"$id\">".$hotel_name.'</option>';?> </SELECT> <label> <input type="submit" name="submit" id="submit" value="Submit" /> </label> </form> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.