Jump to content

Search the Community

Showing results for tags 'dropdown'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. Hi all, Trying to update two rows in a MySQL table using MySQLi and PHP with values from a bootstrap dropdown. No errors or anything (have error reporting turned on), just nothing is updated in the database. Here is the update code (if anyone has a prepared version of it would love to have it). if(isset($_POST['Update'])){//if the submit button is clicked if(isset($_GET['issue_id']) && isset($_POST['issue_priority']) && isset($_POST['issue_status'])) { $sql="UPDATE maintenance_requests SET issue_status='$issue_status', issue_priority='$issue_priority' WHERE issue_id='".$_GET['issue_id']."'"; $link->query($sql) or die("Cannot update");//update or error } } ?> And here is the form: <form role="form" method="POST" action="" /> <table class="table table-striped table-bordered table-hover" id="bookings_table"> <thead> <tr> <th class="text-center">Issue ID</th> <th class="text-center">Driver Name</th> <th class="text-center">Date Submitted</th> <th class="text-center">Fleet Number</th> <th class="text-center">Issue</th> <th class="text-center">Description</th> <th class="text-center">Priority</th> <th class="text-center">Status</th> </tr> </thead> <tbody> <tr class="odd gradeX"> <td class="text-center"><?php echo $issue_id; ?></td> <td class="text-center"><?php echo $driver_name; ?></td> <td class="text-center"><?php echo $issue_date; ?></td> <td class="text-center"><?php echo $fleet_number; ?></td> <td class="text-center"><?php echo $issue_name; ?></td> <td class="text-center"><?php echo $issue_description; ?></td> <td class="text-center"> <select name="issue_priority"> <option value="" hidden="hidden"><?php echo $issue_priority; ?></option> <option value="High">High</option> <option value="Medium">Medium</option> <option value="Low">Low</option> </select> </td> <td class="text-center"> <select name="issue_status"> <option value="" hidden="hidden"><?php echo $issue_status; ?></option> <option Value="Open">Open</option> <option Value="Pending">Pending</option> <option value="Repaired">Repaired</option> </select> </td> </tr> </tbody> <?php } $stmt -> close(); } mysqli_close($link); ?> </table> <input type="submit" class="btn btn-default" name="Update" value="Update Issue"> </div> </form> Any help would be really appreciated. Have searched the forums and searched Google but nothing found. Thanks heaps.
  2. Hi all ! I am using this tutorial and I am modifying it to include csrf protection. The index.php uses getToken(); to generate an anti-csrf token which is then inserted in the form as a hidden input field as below: <tr> <td> <select id="country_dropdown" > <option value="-1">Select country</option> <?php while($stmt->fetch()) { ?> <option value="<?php echo $country_id ?>"><?php echo $country_name ?></option } <?php // token added as hidden field echo '<input type = "hidden" name = "token" value = "'.$_SESSION['token'].'" />'; ?> </select> </td> </tr> <tr> <td> <select id="state_dropdown" > <?php echo $_SESSION['token']; // debug ?> <option value="-1">Select state</option> </select> <?php // The token does not change even when it is changed in loaddata.php. The change values // does not get reflected here. So adding the below code is useless, so commented out. // echo '<input type = "hidden" name = "token" value = "'.$_SESSION['token'].'" />'; ?> <span id="state_loader"></span> </td> </tr> This scheme works if the same token is to be used for all drop downs. If I change destroy and change the token in loaddata.php, the ajax response file, where the data is sent and received from for proceeding to the next drop-down, the change in the token value is not reflected in the index.php since, i guess, that file is not refreshed to load the new token value. So how can I make this work? Please help. Thanks !
  3. This is the code for a dynamic dropdown list which i use to create a record. It works. But i find it slow when updating a record. It takes time to load the cities dropdown data. I am wondering, is there a more efficient way to do this dropdown so it loads the data more quickly? <script> function getCity(val) { $.ajax({ type: "POST", url: "../snippets/get_cities.php", data:'state_id='+val, success: function(data){ $("#city-list").html(data); } }); } function getState(val) { $.ajax({ type: "POST", url: "../snippets/get_states.php", data:'country_id='+val, success: function(data){ $("#state-list").html(data); } }); } function selectCountry(val) { $("#search-box").val(val); $("#suggesstion-box").hide(); } </script> <fieldset> <label>Location:</label><br/> <select name="country" id="country-list" onChange="getState(this.value);"> <option value="">Select Country</option> <?php $get_countries = $db->prepare("SELECT * FROM countries2"); $get_countries->execute(); $result_countries = $get_countries->fetchAll(PDO::FETCH_ASSOC); if(count($result_countries) > 0) { foreach($result_countries as $row) { $get_country_id = trim($row['id']); $get_country_name = trim($row['name']); ?><option value="<?php echo $get_country_id; ?>" <?php if($record_country_id == $get_country_id) { echo 'selected'; }; ?>><?php echo $get_country_name; ?></option><?php } } ?> </select> <select name="state" id="state-list" onChange="getCity(this.value);"> <option value="">Select State/Province</option> <?php $get_states = $db->prepare("SELECT * FROM states"); $get_states->execute(); $result_states = $get_states->fetchAll(PDO::FETCH_ASSOC); if(count($result_states) > 0) { foreach($result_states as $row) { $get_state_id = trim($row['id']); $get_state_name = trim($row['name']); ?><option value="<?php echo $get_state_id; ?>" <?php if($record_state_id == $get_state_id) { echo 'selected'; }; ?>><?php echo $get_state_name; ?></option><?php } } ?> </select> <select name="city" id="city-list"> <option value="">Select City</option> <?php $get_cities = $db->prepare("SELECT * FROM cities"); $get_cities->execute(); $result_cities = $get_cities->fetchAll(PDO::FETCH_ASSOC); if(count($result_cities) > 0) { foreach($result_cities as $row) { $get_city_id = trim($row['id']); $get_city_name = trim($row['name']); ?><option value="<?php echo $get_city_id; ?>" <?php if($record_city_id == $get_city_id) { echo 'selected'; }; ?>><?php echo $get_city_name; ?></option><?php } } ?> </select> </fieldset>
  4. Hi I have an issue to insert data from dropdown to mysql. It is inserting the partial data to database Example: if selection is Account Dept, but inserted only Account. missing Dept if selection is Non Active, inserted only Non. missing Active. whatever coming after space, it cannot be inserted. It happens only in dropdown control. In Database, using varchar(30) for column Pls advice where I did wrong. Thank you Maideen Here is my HTML code <label>Status</label> <select class="form-control" data-placeholder="Choose a Category" name="status"> <option></option> <?php $sql = "select * from tbl_parameter where paramhead ='STATUS' order by paramdetails"; $stmt = $pdo->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $optvalue = $row['paramdetails']; print '<option value ='.$optvalue.'>' .$row['paramdetails']. '</option>'; } ?> </select> php code if(isset($_POST['add'])) { if($_SERVER["REQUEST_METHOD"] == "POST") { $staffid =$_POST['staffid']; $staffname =$_POST['staffname']; $gender =$_POST['gender']; $department=$_POST['department']; $emailid=$_POST['emailid']; $hpno=$_POST['hpno']; $address=$_POST['address']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; $status=$_POST['status']; $createdby=$_COOKIE['username']; $time = strftime("%X"); $date = strftime("%B %d,%Y"); $createdon = date("Y-m-d H:i:s"); $terminal=$_COOKIE['terminal']; $bool = true; $sql="insert into tbl_staff_master(staffid,staffname,gender,department,emailid,hpno,address,city,state,country,status,createdby,createdon,terminal) values ('$staffid','$staffname','$gender','$department','$emailid','$hpno','$address','$city','$state','$country','$status','$createdby','$createdon','$terminal')"; $stmt=$pdo->prepare($sql); $stmt->execute(); $pdo = null; print '<script>alert("Saved");</script>'; header("location:staff_add.php"); } }
  5. Is it possible to format the menu items in the drop down box? Below is the code used at the moment. What I would like is to make Yes = Green, No = Red and N/A stay black. I tried using the class and style setting on the inline code but had no luck. Can anyone please shed some light on how I would go about this? <select name="ob_admin_quals" class="standard_left" id="ob_admin_quals"> <option value="Yes"<?php echo($ob_admin_quals == 'Yes') ? ' selected' : '';?>>Yes</option> <option value="No"<?php echo($ob_admin_quals == 'No') ? ' selected' : '';?>>No</option> <option value="N/A"<?php echo($ob_admin_quals == 'N/A') ? ' selected' : '';?>>N/A</option> </select>
  6. Right now I have a mobile dropdown that works fine. The only issue I have is that when viewing it on my smartphone, the dropdown gets cut off at the bottom and I am unable to scroll it down to rest of it. Is there a way to fix it so that It's scrollable? Here's my js code of the dropdown. $(document).ready(function() { $(".nav-mobile li a").each(function() { if ($(this).next().length > 0) { $(this).addClass("parent-arrow"); } }) $(".toggle-mobile-menu").click(function(e) { e.preventDefault(); $(this).toggleClass("active-mobile"); $(".nav-mobile").toggle(); }); adjustMenu(); }); $(window).bind('resize orientationchange', function() { ww = document.body.clientWidth; adjustMenu(); }); var adjustMenu = function() { var ww = document.body.clientWidth; if (ww <= 850) { $(".toggle-mobile-menu").css("display", "block"); if (!$(".toggle-mobile-menu").hasClass("active-mobile")) { $(".nav-mobile").hide(); } else { $(".nav-mobile").show(); } $(".nav-mobile li").unbind('mouseenter mouseleave'); $(".nav-mobile li a.parent-arrow").unbind('click').bind('click', function(e) { // must be attached to anchor element to prevent bubbling e.preventDefault(); $(this).parent("li").toggleClass("hover"); }); } else if (ww > 850) { $(".toggle-mobile-menu").css("display", "none"); $(".nav-mobile").hide(); $(".nav-mobile li").removeClass("hover"); $(".nav-mobile li a").unbind('click'); $(".nav-mobile li").unbind('mouseenter mouseleave').bind('mouseenter mouseleave', function() { // must be attached to li so that mouseleave is not triggered when hover over submenu $(this).toggleClass('hover'); }); } }
  7. I have a simple setup where I have a collapsed menu. When you click on the button, it will open a menu. If the menu is already opened and you open another menu, the previous menu will collapse. All that works. The only thing I noticed is that It will not collapse the opened menu if I click the same button. That menu will only collapse if I open a different menu. I was wondering how the code below will look with that extra function added? Here's the code for that. <h5 class="mobile-collapse__title">Title Button</h5> <div class="mobile-collapse__content"> <ul> <li>list 1</li> <li>list 2</li> <li>list 3</li> </ul> </div> <script> $(document).ready(function($){ $(".mobile-collapse__title").click(function(e) { e.preventDefault(); $('.mobile-collapse__content:visible').hide(); $(this).next('div.mobile-collapse__content').show(); }); }); </script>
  8. http://www.tirerack.com/content/tirerack/desktop/en/wheels.html See the window where it says "Shop by Vehicle"? Is there a script already out there that does the dropdown search by make/model/year? I am only looking for the front-end code; javascript/jquery code in particular.
  9. Hi I'm using PHP for my Navigation Menu, My navbar is in a file named "home.php" looks like this: <ul class="nav navbar-nav navbar-right"> <li><a href="?page=home">Home</a></li> <li><a href="?page=about">About</a></li> <li><a href="?page=services">Services</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="?page=service2">Service 2</a></li> </ul> </ul> Then in my index.php: $page = $_GET['page']; if (!isset($page)) { include('home.php'); } if ($page == "home") { include('home.php'); } if ($page == "about") { include('about.php'); } if ($page == "services") { include('services.php'); } if ($page == "service2") { include('service2.php'); } It all works how I want it to except for one thing; I'd like to add; <li class="active"> To the page that is currently being viewed. How can I do this? Thank you in advance.
  10. Unfortunately my ideas out pace my skills. I have a database that I would like certain people to access their own info, but nobody else's. It's not super sensitive info and won't mean much to anyone other than the end user but we don't like the idea of others accessing it so we'd like to put some protection on it. What I was hoping for is a dropdown list (there's about 30 or so clients that would be in a mysql table) where they can pick out their name, then text box for the password. When they hit submit button it would lead them to their own page with a table and their own info from a mysql table. I can get each one of these details to work separately, but I'm having trouble putting them all together (the password is where things get muddled). Can anyone point me to a place where they've already figured this out? Thanks!
  11. I'm building a form for an organisation that organises a workshop for teenagers. There is an option to bring one or both parents to the workshop. So for each parent, there's a dropbox to answer the question "Will you participate in the workshop as well?" Depending if one, both or no parents will join, the user will be redirected to a different url after submiting (submit is always in the same place). The form is built with chronoforms in Joomla. This is the code for the dropdowns, please note that I can't change the values "Ja" or "Nee" because these option values are also sent to an exterior, custom made program so i'm not allowed to change it. Code for the dropdowns: <select class="cf_inputbox validate-selection required" id="select_17" size="1" title="verplicht veld" name="oudersessieouder1" style="width: 193px;"> <option value="">Make your choice</option> <option value="Ja">Yes, will participate</option> <option value="Nee">No, will not participate</option> </select><label class="cf_label" style="width: 150px;"> Will this parent join the workshop?</label> <select class="cf_inputbox validate-selection required" id="select_18" size="1" title="verplicht veld" name="oudersessieouder2" style="width: 193px;"> <option value="">Make your choice</option> <option value="Ja">Yes, will participate</option> <option value="Nee">No, will not participate</option> </select><label class="cf_label" style="width: 150px;"> Will this parent join the workshop?</label> And this is the after submitting, here I can write the code to redirect depending on the values of the previous two dropdowns: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>bedankt</title> </head> <body> <script> if (one parent comes, so one of the 2 dropdown values will be "Ja") window.location.replace("http://www.website.be/inschrijven-pe-jongeren-1-parent.html") else if (both parents come, so both dropdown values will be "Ja") window.location.replace("http://www.website.be/inschrijven-pe-jongeren-both-parents.html") else window.location="http://www.website.be/inschrijven-pe-jongeren.html" </script> <p align="center"> </p> </body> </html>
  12. Keep getting these two errors when trying to UPDATE a field called "type" to 'banana' based on the fuitid. Why is this happening? Undefined index: fruitid in update.php You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 <form method="POST" action="update.php"> <select> <option value="">Select</option> <?php $sql = "SELECT fruitid, datefrom, dateto FROM fruits"; $sqlresult = $link->query($sql); $sqllist = array(); while($row = mysqli_fetch_array($sqlresult)) { echo "<option>".$row['datefrom']." - ".$row['dateto']."</option>"; } ?> </select> <input type="hidden" value="<?php echo $fruitid;?>" name="fruitid"/> <input type="submit" value="Submit" name="submit"/> </form> <?php if(isset($_POST['submit'])) { $fruitid= mysqli_real_escape_string($link,$_POST['fruitid']); $sql = "UPDATE `fruits` SET `type`='banana' WHERE fruitid = $fruitid"; if (mysqli_query($link, $sql)) { echo "updated"; } else { echo "problem: " . mysqli_error($link); } } ?>
  13. Hi. I have 2 problems which I'm hopeing someone can help me with. 1. For the following script to change the pages language, I would like it so that whichever option selected is set on the page (i.e. if you select Euskal, the select box stays set as Euskal, and not Espanyol as it does at the moment) <form name="Language" action="" method="post" id="Language"> <div class="btn-group"> <?php $uri = strtok($_SERVER["REQUEST_URI"],'?');; $url="http://".$_SERVER['HTTP_HOST'].$uri; ?> <span class="btn btn-primary"> <select name="lang" onchange="javascript:change_langs(this.form)"> <option value="Esp">Espanyol</option> <option value="Eng">English</option> <option value="Cat">Catalan</option> <option value="Bas">Euskal</option> <option value="Gal">Galego</option> </select> </span> </div></form> 2. I have 2 dropdown lists in the following format: <select class="form-control" name='category'> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="A"))?"selected='A'":""); ?> value='A'><?=getlg($lang,"A")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="b"))?"selected='b'":""); ?> value='b'><?=getlg($lang,"b")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="c"))?"selected='c'":""); ?> value='c'><?=getlg($lang,"c")?></option> </select> <select class="form-control" name='category'> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="D"))?"selected='D'":""); ?> value='D'><?=getlg($lang,"D")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="e"))?"selected='e'":""); ?> value='e'><?=getlg($lang,"e")?></option> <option <?php print ((isset($_GET["category"]) && ($_GET["category"]=="f"))?"selected='f'":""); ?> value='f'><?=getlg($lang,"f")?></option> </select> However, I require just one dropdown list with catagories A and D as the main item. Catagories b & c should be a sub category of A, and e & f should be a sub category of D Any help would be appreciated. Thanks
  14. i am new to web designing, i don't know much about javascript. <select id="plan" align="center" valign="center"> <option value="images/21.jpg">PHASE 1</option> <option value="images/22.jpg">PHASE 2</option> <option value="images/23.jpg">PHASE 3</option> <option value="images/24.jpg">PHASE 4</option> <option value="images/25.jpg">PHASE 5</option> <option value="images/200.jpg">PHASE 6</option> <option value="images/210.jpg">PHASE 7</option> </select> <img id="image" src="images/21.jpg" align="center" valign="center" Onclick="zoom"/> <script type="text/javascript"> function setplan() { var img = document.getElementById("image"); img.src = this.value; return false; } document.getElementById("plan").onchange = setplan; </script> above is the code given. the above codes changes the images when the values of the dropdown menu are selected, every dropdown menu has a specific image bind to it. when the image is displayed after selecting any item from dropdown, now i want to popup or zoom the image or open it itnto new widow when i click on the image, plz help me. http://gdcindia.co.in/SAI%20SHOBHAN.html plz visit this link, and go to 2nd tab floor plan. then u will know what i want plz help me.
  15. for starters, i am a complete beginner at PHP, so i know almost nothing. so, the basic outline is that i am required to create a table with 2 columns, and use PHP where i can so the first set of code lays down the table and the ability to type in text of "name" and "surname". ----i think this "input" is HTML, yes?? is there a way to enter it as PHP? <table border=\"2\"> <tr><th><b>Requirements</b></th><th><b>Selections</b></th></tr> <tr><td>Name</td><td><input type="text" name="name"/></td></tr> <tr><td>Surname</td><td><input type="text" name="surname"/></td></tr> so, for this next section, adding on is the part for "age". i want this to appear as a dropdown selection. i've written PHP where possible, however this does not work when opening the file in a browser. it simply leaves a blank dropdown menu with no options. ???? <tr><td>Age</td><td><select> <?php for ($num=11; $num<=22; $num++){ echo '<option>' .$num. '</option>'; } ?> </select> lastly, i have the part for "activity choice". this again i believe i wrote the radio buttons in HTML??? am i able to write this as PHP???? <tr><td>Activity Choice</td><td><input type="radio" name="activityChoice" value "music"/> Music ($30.00)<br> <input type="radio" name="activityChoice" value "swimming"/> Swimming ($25.50)<br> <input type="radio" name="activityChoice" value "tennis"/> Tennis ($20.00)<br> <input type="radio" name="activityChoice" value "basketball"/> Basketball ($15.50)<br> <input type="radio" name="activityChoice" value "netball"/> Netball ($15.50)<br> <input type="radio" name="activityChoice" value "dance"/> Dance ($10.50)<br> <input type="radio" name="activityChoice" value "communityService"/> Community Service (No Charge)</td></tr> please please please help??
  16. Hopefully someone can help, firstly i am a newbie at php coding but keen to learn more. Here is my problem The database is built correctly with all the information i need, the first part is the dropdown menu which you select a car, next you choose a month and mileage - from there it shall show you the correct price for each one. There is columns for each price, mileage and months i just need to figure out how best to start this thing. I first started by this $query = "SELECT DISTINCT Full_Description FROM import"; $result = mysql_query($query) or die(mysql_error()); echo "<select name=\"carname\">"; echo '<option value="">Please select...</option>'; while($row = mysql_fetch_array($result)) echo "<option value='{$row['id']}'>{$row['Full_Description']}</option>"; echo "</select>"; $carids = $_POST["carname"]; $_SESSION["carid"] = $package_id; echo $_SESSION["carid"]; $query2 = "SELECT Mileage FROM import WHERE id = '$carnames22'"; $resultsdsd = mysql_query($query2) or die(mysql_error()); ?> This got me all the cars listed in a dropdown select, but it did not store the selected car id for me to use else where, i am not even sure if this is the best approach. Please can some help me! Jay
  17. Normally you can get input names from form using $_GET method. However, with a multi level dropdown, the php query files are called externally and through the js code. So I am wondering, what is the best way to get the input names of each dropdown? For eg. country, state, city. Getting the input name for the country is easy; how would I get it for the state and city if they are in a seperate php files? Do I get the input name in their own files and put them in a session?
  18. I was following a tutorial from else where that showed how to do dynamic dropdown with ajax. Unfortunatly he only does it for two drop downs. I need a third dropdown. I have a dropdown for select country and select region. They work great. How can I add the select city dropdown as well with js? js code on index.php <html> <head> <script> function showHint(str) { var xmlhttp; if (str.length==0) { document.getElementById("regiondiv").innerHTML=""; return; } if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("regiondiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","geo.php?country="+str,true); xmlhttp.send(null); } </script> </head> <body> <div class="field"> <label for="cat">Country</label> <select id="country" name="country" onChange="showHint(this.value);" required > <option value="0">--Select Country--</option> <?php $getCountry = DB::getInstance()->query("SELECT * FROM countries"); if(!$getCountry->count()) { echo 'No Country found!'; } else { foreach($getCountry->results() as $row) { $country_id = escape($row->countryId); $country_name = escape($row->countryName); ?><option value="<?php echo $country_id; ?>" ><?php echo $country_name; ?></option><?php } } ?> </select> </div> <label for="cat">Region</label> <div id="regiondiv"> <select name="region" id="region"> <option>--Select State--</option> <option></option> </div> </body> </html> ajax.php <?php require_once 'core/init.php'; $country_id = escape(Input::get('country')); $select_region = DB::getInstance()->get('regions', array('countryId', '=', $country_id)); if(!$select_region->count()) { echo 'No Country found!'; } else { ?><select name="region" id="region"><?php foreach($select_region->results() as $row) { $region_id = escape($row->regionId); $region_name = escape($row->regionName); ?><option value="<?php echo $region_id; ?>" ><?php echo $region_name; ?></option><?php } ?></select><?php }
  19. hi,,, i need question about populate table based on dropdown this my php file kecamatan.php <?php require 'config_db.php'; $self='kelurahan.php'; if (isset($_POST['action'])&&$_POST['action']=='edit'){ $namakelurahan = _post('namakelurahan'); if ($namakelurahan==''){ r2($self,'e','Nama kelurahan tidak boleh kosong'); } $id = _post('id'); $grp = ORM::for_table('kelurahan')->find_one($id); $grp->set('namakelurahan', $namakelurahan); $grp->save(); r2($self,'s','Perubahan data berhasil di lakukan'); } elseif (isset($_POST['action'])&&$_POST['action']=='delete'){ $trid = _post('trid'); $tr = ORM::for_table('kelurahan')->find_one($trid); if (!$tr){ r2($self,'e','Nama kelurahan tidak di temukan'); } $tr->delete(); r2($self,'s','Data berhasil di hapus'); } elseif (isset($_POST['action'])&&$_POST['action']=='add'){ $namakelurahan = _post('kelurahan'); if ($namakelurahan==''){ r2($self,'e','Nama kelurahan wajib diisi'); } $grp = ORM::for_table('kelurahan')->create(); $grp->namakelurahan=$namakelurahan; $grp->save(); r2($self,'s','kelurahan berhasil disimpan'); } else {?> <?php $query ="SELECT * from kecamatan"; $stmt = $dbh->prepare("$query"); $stmt->execute(); $reskecamatan = $stmt->fetchAll(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?php echo 'Sistem Informasi Surveilans' // lc('WebsiteTitle'); ?></title> <link rel="shortcut icon" type="image/x-icon" href="../assets/img/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link type='text/css' href='views/bmsapp/css/cstyle.css' rel='stylesheet' /> <link href="../assets/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="../assets/css/clientstyle.css" rel="stylesheet"> <link href="../assets/css/common.css" rel="stylesheet" type="text/css" /> </head> <body style='background-color: #FBFBFB;'> <div id='main-container'> <div class='header'> <div class="header-box wrapper"> <div class="hd-logo"><a href="#"><img src="../assets/uploads/logo.png" alt="Logo"/></a></div> </div> </div> <div class="navbar"> <?php include 'menu.php';?> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <h3>Data kelurahan</h6> <table> <tr> <td> Kecamatan : <select onchange=""> <option value="-1">Semua Kecamatan</option> <?php foreach($reskecamatan as $allkecamatan) { $id = $allkecamatan['id']; $namakecamatan = $allkecamatan['namakecamatan']; ?> <option value="<?php echo $allkecamatan['id']?> "> <?php echo $allkecamatan['namakecamatan']; ?> </option> <?php } ?> </select> </td> </tr> </table> <table class="table table-bordered table-striped table-hover"> <tr> <th scope="col">No</th> <th scope="col" style="display:none;">Id kelurahan</th> <th scope="col">Nama kelurahan</th> <th scope="col">Nama Kecamatan</th> <th scope="col">Olah Data <img id="ajxspin" src='../assets/img/blue_spinner.gif'/></th> </tr> <?php $query ="SELECT kelurahan.id, kelurahan.idkecamatan, kecamatan.namakecamatan, kelurahan.namakelurahan FROM kecamatan INNER JOIN kelurahan ON kelurahan.idkecamatan = kecamatan.id"; $stmt = $dbh->prepare("$query"); $stmt->execute(); $result = $stmt->fetchAll(); $i='0'; foreach($result as $accgroup) { $i++; $id = $accgroup['id']; $namakelurahan = $accgroup['namakelurahan']; $namakecamatan = $accgroup['namakecamatan']; echo "<tr> <td>$i</td> <td style=\"display:none;\">$id</td> <td>$namakelurahan</td> <td>$namakecamatan</td> <td><a href=\"kelurahan.edit.php?_cmd=$id\" data-toggle=\"modal\"><i class=\"icon-pencil\"></i></a> <a href=\"kelurahan.delete.php?_cmd=$id\" data-toggle=\"modal\"><i class=\"icon-remove\"></i></a></td> </tr>";} ?> <tr> <!--td colspan="3"><a class="btn btn-inverse" href="my-tickets.php"><?php echo 'view' ?> <?php echo 'all_support_tickets' ?></a> <a class="btn btn-primary" href="create-ticket.php"><?php echo 'new_ticket' ?></a></td--> <td colspan="4"> <a class="btn btn-inverse" href="kelurahan.add.php" data-toggle="modal" ><i class="icon-plus icon-white"></i>Tambah Data</a> <a class="btn btn-primary" href="kelurahan.lap.php"><i class="icon-list icon-white"></i>Laporan</a> </td> </tr> </table> </div> </div> </div> </div> </div> <div class="footer"><?php echo $footerTxt; ?><br /><br /></div> </body> </html> <?php } ?> and this output my code in browser: and my question, how to populate the table based on selected dropdown value? sorry my english is bad thanks b4
  20. hello i have a dropdown box where i have populated values from the sql database. no when i select a value from the drop dopwn, i want to display all the records related to that value under the dropdown. here is my code <?php $select=FALSE; require_once ("configFile.php"); $result=mysql_query("SELECT Registration_No FROM vehicle_master "); if($result == FALSE) { die(mysql_error()); // TODO: better error handling } //populate dropdown with vehicles //echo "<label>Select vehicle number : </label>"; //echo "<select name='vehicles'>"; //while ($row = mysql_fetch_array($result)) //{ // echo "<option value='numberPlate'>" . $row['Registration_No'] . "</option>"; //} //echo "</select>"; //echo "<br><br>"; // $select=isset($_POST['vehicles']); ?> <form id="form1" name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php echo "<select name='select'>"; $list=mysql_query("SELECT * from vehicle_master"); while($row_list=mysql_fetch_assoc($list)) { ?> <option value="<?php echo $row_list['Registration_No']; ?>" <?php if($row_list['Registration_No']==$select) { echo "selected"; } ?>> <?php echo $row_list['Registration_No']; ?> </option> <?php } ?> </select> <input type="submit" name="Submit" value="select" /> </form> <br> <?php if (isset($_POST['SELECT'])) { $Registration_Nos=mysql_real_escape_string($_POST['SELECT']); $result=mysql_query("SELECT * FROM vehicle_master WHERE Registration_No='".$Registration_Nos."'"); while ($row=mysql_fetch_assoc($result)) { echo "".$row['Emergency_Contact_1'].""; } }?>. can anyone tell me where am i going wrong ? control.php
  21. Hi Everyone, I am fairly new in PHP Development but have used Wordpress for the last 2 years. I am currently modifying a plugin to suit the client's requirements. It is a Custom To-DO list plugin. You may check out my progress here : [Page on meshfun.com] The plugin I am modifying is WordPress › TaskFreak! Free " WordPress Plugins It is almost all the required features, just the feature of Creating Groups and assigning is absent. When a new task is created,an option of assigned to is present but that can assign task to ONLY ONE Person. It should be able to assign to multiple users. The whole data is stored in the database in 8-9 tables. The main table DO has a field called as user_ID as you can see in the image below. It is updated when a new task is created. It contains a number (User ID of person who is assigned the task) or left blank in case the task is not assigned to anyone. : I would like the ability to assign to multiple users instead of one. What would be the ideal way ? Create new table or store the number of people assigned as array ? If a new table is created, what will be the fields to be created ? Note I was not able to add images so please check out here to see couple of images I wanted to show you : http://www.quora.com/Need-help-in-Modifying-a-Wordpress-Plugin I understand that you guys are quite busy but if you guys can atleast guide me on how to proceed, it would be great ! Thanks, Shalabh Here is the code which displays dropdown menu in the front end (taskfreak/inc/views/front/edit.php) <li> <label for="tfk_user_id"><?php _e('Assigned to', 'taskfreak') ?></label> <select name="user_id" id="tfk_user_id"> <option value="">—</option> <?php foreach ($this->users as $user): ?> <option value="<?php echo $user->ID ?>"<?php if ($this->pid && $this->data->get('user_id') == $user->ID) { echo " selected"; } ?>><?php echo $user->display_name ?></option> <?php endforeach; ?> </select> <?php echo $this->data->errors['user_id'] ?> </li> UPDATE : One gentleman suggested me to create a table with the following SQL COde : CREATE TABLE `task_user` ( `task_id` int(11) unsigned NOT NULL, `user_id` int(11) unsigned NOT NULL, `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'status field is optional', UNIQUE KEY `task_user` (`task_id`,`user_id`,`type`) USING BTREE, KEY `task_id` (`task_id`), ) CHARSET=utf8 But I am still not able to convert the display into multiple checkboxes.
  22. Can anyone help me please? I am trying to populate my page with data that is filtered from the dropdown box. It can either be "onchange" or clicking a button, not too fussed on this. I have tried so many ways but getting more and more lost an confused and ended up with nothing at all. I have stripped the coding back to where it last worked so any help is appreciated. <body> <table width="680" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td> </td> </tr> <tr><td class="text-heading"><p>Financial Services Guides and Adviser Profiles</p><p class="Text_Heading_Black1">PAGE STILL IN DEVELOPMENT</p> <form id="form1" name="form1" method="post" action=""> <span class="text-questions">Adviser: </span> <select name="advselect" id="advselect"> <option value=" " selected="selected"> </option> <?php require ('../edb.php'); if (!$con) { die("MySQL could not connect!"); } $result= mysql_query("SELECT id, LastName, FirstName, UserType FROM `eusers` WHERE UserType='ADV' or UserType='STF' ORDER by LastName ASC"); while ($row = mysql_fetch_array($result)){ echo '<option value="'. $row['id'] .'">'. $row['LastName'] .', '. $row['FirstName'] .'</option>'; } ?> </select> <input type="submit" name="advselect" id="advselect" value="Filter / View" /> </form></td> </tr> <tr><td><p class="Text_SubHeading">Current Version </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='Y' and ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table> <p class="Text_SubHeading">Previous Versions </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='N' ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table></td> </tr> </table> </body>
  23. Hi. Sorry if I've posted in the wrong forum or something - I joined this forum a few seconds ago. I'm trying to create something which displays all of the users in a database table in a drop-down menu. I've tried this code: <?php include 'config.php'; session_start(); $suser = $_SESSION['user']; $con = mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); mysql_select_db($config['database']); $cpuTable = $config['cpuTable']; $query = mysql_query("SELECT * FROM $cpuTable WHERE suser='$suser'"); while($row = mysql_fetch_assoc($qa)) { $users = $row['username']; echo " <select name='cpuser'> <option value='user'>$users</option> </select>"; } I created two users in the database - "cp_test1" and "cp_test2", tried the code and it outputted this: Instead of listing the users in one drop-down menu, it creates two and lists one in each. Can anyone help? Thanks
  24. Hello I was wondering how could i autofill a form based on a drop down list using raw php and mysql . I know that the connection to database would have to be established but what next ? Any Pointers would be helpful Also check the attached photo to maybe understand more than I'm explaining
  25. I am developing php page, I am struck on one part :banghead: I have 3 dropdown menus. 1) Room Type 2) No of Person 3) Extra Person and a Textbox Now my Issue is, When I select Room type as Executive the amount should be shown on textbox and select "premium" relevant amount should be shown. when I add Extra Person, Rs 500 should be added in textbox. Thanks shamil
  • 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.