Jump to content

learningPHP1

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by learningPHP1

  1. hello, Trying to convert 2 post variables to strtotime so that it can be saved to a database. The 2 variables are: $testDate = $_POST['date'] ; // containts: 2014-04-22 $testTime = $_POST['time']; // containt: 21:02:17 echo $date_time = $testDate . $testTime; // result: 6969-1212-3131 19:00:00 echo $new_date = date('yy-mm-dd H:i:s', strtotime($date_time)); // result: 6969-1212-3131 19:00:00 how do i go about setting the $new_date variable to 2014-04-22 21:02:17 so that it can be saved to a database(mysql data type: datetime) any help you can provide would be greatly appreciated. Thanks
  2. Thanks for the replay chocu3r but now i have large gaps between menus..not very attractive looking.
  3. Hello, I have a menu and using css to control the display. problem area: mouse over menu and bolding. for most part the menu works, what i like to do is prevent the bold (mouse over) from pushing surrounding menus to make space to display the bold. I know i need to somehow expand the menu spaceing so that when the mouse over wont pushing the other menus over but cant seem to hit that number. any ideas? <style rel="stylesheet" type="text/css"> #navcontainer ul { list-style-type: none; margin: 0; padding: 0; } #navcontainer ul li {display: inline; } #navcontainer ul li a { text-decoration: none; font-size: 18px; color: black; background-color: #FFFFFF;} #navcontainer ul li a:hover { color: darkblue; background-color: #FFFFFF; text-decoration:underline; font-weight:bold;} </style> </head> <body> <div id="navcontainer"> <ul> <li> <a href="#"> Home</a></li> <li>|<a href="#"> Project listing</a></li> <li>|<a href="#"> Directory</a></li> <li>|<a href="#"> Create project</a></li> <li>|<a href="#"> My project</a></li> </ul> </div> </body> </html>
  4. Hello everybody, I'm working on a script which has 2 div tages controled by 2 radio buttons and using jquery to hide/show the div tags based on the users selection. Like to have.. if a user selects one of the radio button i like to maintain the selection radio button and the div tag if the page is refreshed. Problem: if the user selects the second div tag and if the page refreshes the radio button and the div tag returns to the initial setup which is going back to the first radio button and div tag. how do i maintain the selection, radio button and the div tage after a refresh? <script type='text/javascript'> $(document).ready(function() { $("#DivB").hide(); $('input[name="myproject"]').change(function() { if($(this).val() == "A") { $("#DivA").show(); $("#DivB").hide(); } else { $("#DivA").hide(); $("#DivB").show(); } }); }); </script> <div style ="border:1px solid black;"> <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='POST'> <div id="div1"> <input type='radio' name='myproject' value='A' checked="checked" <?php echo (isset($_POST['myproject']) && $_POST['myproject'] == 'A') ? 'checked':''; ?> />Have projectID <input type='radio' name='myproject' value='B' <?php echo (isset($_POST['myproject']) && $_POST['myproject'] == 'B') ? 'checked':''; ?> />Lost projectID<br /> </div> <hr /> <div id='DivA'> projectID:<br /> <input type="text" name="proId"><br /> email: <br /> <input type="text" name="email"><br /><br /> <button name="btn_prj_info">View project status</button> <br /> </div> <div id='DivB'> Email: <br /> <input type="text" name="emailR"><br /><br /> <button name="btn_email">Email information</button> <br /> </div> </form> </div>
  5. Hello, I'm working on a small form script which submits the form without refreshing the whole page. its a email form which basically calles sendemail.php and returns either "done" or "failed". NOt yet scripted to send, just testing. I been at it for 3 days with no success and wondering if someone can help me fix the problem. Any help you can provide would be greatly appreciated... Thanks <!doctype html> <html> <head> <title>Submit form without refreshing the page</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" </script> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script> $(function() { $("#send").click(function(e) { e.preventDefault(); $.ajax( { type: "POST", url: "sendemail.php", data: $("#myform").serialize(), success: function(response) { if(response == "done") { alert("Form submitted successfully!"); } else { alert("Form submission failed!"); } } }); }); }); </script> </head> <body> <form id="myform" > Name: <br /><input type="text" name="name" id="name" /><br /> Email: <br /><input type="text" name="email" id="email" /> <br /> Message: <br /><textarea name="msg" id="msg"></textarea> <br /> <input type="submit" id="send" class="send" value="Submit" /> </form> </body> </html> small php script <?php $name = $_POST['name']; $message = $_POST['msg']; if(!empty($name) && !empty($message)) { //Do your MySQL or whatever you wanna do with received data //Do not forget to echo "done" when action was completed successfully. echo "done"; } else { echo "fail"; } ?>
  6. Hello, I wrote a small script that basically displays 20 to 30 categories on a page which a user has the option toeither select one or multiple items from the list. For the sack of argument the user selected the following items from the list: Table-> tbl_category : ‘Green car’, ‘truck’, ‘Van’, ‘minivan’,’ laptop’, ‘iPhone’, ‘great value mixed nuts 80% peanuts’, ‘cup’ Tables I have: Table-> tbl_user Table-> tbl_category What is the best practice in terms of saving the multiple selection: 1.Do I create a field in tbl_user and save the selection or selections into that one field? 2. Create a separate tbl_saveCategoreySelection and save them as individual records and link it to tbl_user? At the same time the saved category list will need to be searchable. Any help you can provide would be greatly appreciated. Thanks
  7. Thanks everybody, I greatly appreciate your post replies back. I ended up going with barands answer. I added the hidden input field and it seem to have fixed the issue in my script.. I did change one thing in Brands answer i changed the value='0' to value=''. this gave me what i needed.. again thanks for the help.
  8. Hello, Problem area: radio buttons in a user form. Initially the radio buttons are unchecked which is fine for what i need If one of the radio button is selected the process.php scripts recives the value via $_POST, which works fine. if the radio button isn't selected nothing is sent via $_POST. This is where the problem is.... I need: f the user forgets to select the radio button noting is sent via $_POST. If nothing is sent via $_POST the process.php script is unable to verify the wheather the user made a selection or not. print_r($_POST) ==>Array ( [name] => => [birthday] => [formSubmit] => Submit ) radiobutton doesn't appear. how can in include the radio button as part of the $_POST so that process.php can process the selection weather its empty or not? form.php <form name="formprocess" method="POST" action="process.php"> Name: <input type="text" name="name" value="<?php echo $name; ?>" > <br /> eMail: <input type="text" name="email" value="<?php echo $email; ?>" > <br /> Birthday:<input type="text" name="birthday" value="<?php echo $birthday; ?>" /><br /> <br /> <p> <input type="radio" name="radiobutton" value="1" <?php echo (isset($_POST['radiobutton']) && $_POST['radiobutton'] == 1) ? 'checked':''; ?>> OptionOne </p> <p> <input type="radio" name="radiobutton" value="2" <?php echo (isset($_POST['radiobutton']) && $_POST['radiobutton'] == 2) ? 'checked':''; ?>> OptionTwo </p> <p> <input type="radio" name="radiobutton" value="3" <?php echo (isset($_POST['radiobutton']) && $_POST['radiobutton'] == 3) ? 'checked':''; ?>> OptionThree</p> <input type="submit" name="formSubmit" value="Submit"> </form> process.php $allowedFields = array( 'name', 'email', 'birthday', 'radiobutton', ); $requiredFields = array( 'name', 'email', 'radiobutton', ); echo 'radiobutton1: '. $_POST['radiobutton']; echo '<br />'; print_r($_POST); //loop through the POST array $fieldErrors = array(); foreach($_POST as $key=>$value) { // allowed fields if(in_array($key, $allowedFields)) { $$key = $value; // required field? if(in_array($key, $requiredFields) && $value == '') { $fieldErrors[] = "The field $key is required."; } } }
  9. Problem keeping a variable in the receiving page. From the index.php, the taskid is sent to the receiving page projectasessment.php and this works, the varialble is received. problem is in the receiving page projectassessment.php (data entry form) it wont keep the variable when it returns back to the same page. - projectassessment page receives the variable $_GET['taskid']; - works - user clicks the save button to save the data. - after saving the page the page returns back to projectassessment.php to add another record. - at this stage $_SESSION['taskid'] = $_GET['taskid']; becomes blank. I'm assuming when the page returns back to projectassessment the $_get returns a blank as it has no values to return and in turn the session variable is blank. can any one recommend an alternative option to keep the session variable live? index.php while($row = mysqli_fetch_assoc($ProjectListResults)) { echo '<tr>'; echo "<td> <a href='projectassessment.php?taskid=" .$row['ci_taskid'] . " ' > " . $row['ci_taskid'] . "</a></td>"; echo '<td>' . $row['ci_firstname'] . ' '.$row['ci_lastname']. '</td>'; echo '<td>' . $row['ci_projectid']. '</td>'; echo '<td>' . $row['ci_sde'] . '</td>'; echo '<td>' . $row['ci_status']. '</td>'; echo '<td>' . $row['ci_title']. '</td>'; echo '</tr>'; } projectassessment.php <?php session_start(); echo $_SESSION['taskid'] = $_GET['taskid']; ... ?>
  10. Hello, PHP file upload script. Problem: Unable to upload file under ubuntu server. I have 2 different webservers setup: 1. xampp on usb and my problametic script works. 2. ubuntu server, exact same php script but it wont upload the file. What i noticed with xampp: <--works echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>"; result: tempFile=>:-G:\xampp\tmp\php2D.tmp print_r($imagearray); Array ( [0] => Array ( [1] => G:\xampp\tmp\php2D.tmp [2] => 1357153942_robinuser_dog.jpg ) ) What i noticed with Ubuntu server: echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>"; tempFile=>:/tmp/phpzN6e8U <-- looks like the "tmp" extention is missing. print_r($imagearray); Array ( [0] => Array ( [1] => /tmp/phpzN6e8U [2] => 1357153182_robinuser_bird.jpg ) ) if the temp file ext is missing how do I fix this?? Any help you can provide would be greatly appreciated if(isset($_POST['action'])=='uploadfiles') { for($x=0; $x<count($allowedUpload); $x++) { echo "<br>tempFile=>:-". $_FILES['data']['tmp_name'][$x] . "<br>"; if(!empty($_FILES['data']['name'][$x])) { $extension = end(explode(".", $_FILES['data']['name'][$x])); if ((($_FILES["data"]["type"][$x] == "image/gif") || ($_FILES["data"]["type"][$x] == "image/jpeg") || ($_FILES["data"]["type"][$x] == "image/png") || ($_FILES["data"]["type"][$x] == "image/pjpeg")) && ($_FILES["data"]["size"][$x] < $fileSize) && in_array($extension, $allowedExts)) { if ($_FILES["data"]["error"][$x] > 0) { echo "Error: " . $_FILES["data"]["error"][$x] . "<br>"; } else { //Sanitize the filename $sanitizedName = str_replace($remove_these, '', $_FILES['data']['name'][$x]); $newImageName = time()."_".$imageUserId."_".$sanitizedName; //move_uploaded_file($_FILES['data']['tmp_name'][$x], $upload_directory . $newImageName); if(!empty($newImageName)) { $imagearray[$x][1] = $_FILES['data']['tmp_name'][$x]; $imagearray[$x][2] = $newImageName; } } } else { echo "Invalid file: ".$_FILES["data"]["name"][$x]; } }// end of IF- if(!empty($_FILES['data']['name'][$x])) } // endo for loop print_r($imagearray); for($y=0; $y< count($imagearray); $y++) { move_uploaded_file($imagearray[$y][1], $upload_directory . $imagearray[$y][2]); echo $imagearray[$y][1] . " " .$upload_directory . $imagearray[$y][2]."<br>"; } } // end of upload button
  11. Thank for the suggestion. is there a something specific i should be searching for, a key word, is the process called anything?
  12. hello Everybody, I have a basic user form and the information is saved or submitted by of course a submit button. In the middle of the form i have a zip code lookup field and what I like to do is run the zip code lookup script and display the country, state, and city before moving to the next field. - I have the script which looks up the zip code and tested ok. How do I run a seprate code in the middle and have the resultes displayed before moving to the next field below? any help you can provide would be greatly appreciated. thanks
  13. Hello, I have 2 radio options, one for a new client and one for a returning client and there respective div tags(Div2 - new client and Div2 - returning client) when radio option 1 is selected div1 appears - works when radio option 2 is selected div2 appears - works problem: if radio option 2 is selected the div2 appears but if the page is submitted the returning page still has radio opiton 2 selected but div1 is displayed. need: 1. radio opiton 1 selected to display div1 and submitted. The returning page should have both radio option 1 and div1 selected 2. radio opiton 2 selected to display div2 and submitted. the returning page should have both radio option 2 and div2 selected. Any help you can provide would be greatly appreciated. Thanks you, <head> <script type="text/javascript" > $(document).ready(function () { $('#div2').hide(); $('#id_radio1').click(function () { $('#div2').hide('fast'); $('#div1').show('fast'); }); $('#id_radio2').click(function () { $('#div1').hide('fast'); $('#div2').show('fast'); }); }); </script> </head> <body> <?php if(isset($_POST['btnsave'])) { $userIdField = $_POST['userIdField']; $userPassword = $_POST['passwordField']; $radopt1 = $_POST['radopt']; $radopt2 = $_POST['radopt']; if($_POST['radopt'] == "1") { echo "STAGE: testing: inside new cient"; } else if($_POST['radopt'] == "2") { echo "Testing Inside returning client";} } ?> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST"> <br/> <center> <?php echo "Test: Radio option==>:". $_POST['radopt']; ?> <div align="center" style="border:2px solid red; width:600px; height:110px;" > <input id="id_radio1" type="radio" value = "1" name="radopt" checked="checked" <?php if ($radopt1 == "1") { echo 'checked="checked"'; } ?> /> New Client <input id="id_radio2" type="radio" value = "2" name="radopt" <?php if ($radopt2 == "2") { echo 'checked="checked"'; } ?> /> Returning Client <br/> <div id="div1" style=" border:2px solid blue; width:500px;"> <table boarder="1"> <tr> <th>userId:<input type = "text" name = "userIdField" value = "<?PHP if(!empty($_POST['userIdField'])) {echo $_POST['userIdField'];} else { echo '';} ?>" /> </th> <th>Password:<input type = "text" name ="passwordField" id = "passwordField" value = "" /> </th> </tr> <tr> <th>Email address:<input type = "text" id = "passwordField" value = "E-Mail address" /> </th> <th>re-enterPassword: <input type = "password" id = "passwordField" value = "" /> </th> </tr> </table> </div> <div id="div2" style=" border:2px solid green; width:500px; height:40px;"> <table boarder="1"> <tr> <th>UserId:<input type = "text" id = "userIdField" value = "User Id" /> </th> <th>Password:<input type = "text" id = "passwordField" value = "" /> </th> </tr> </table> <br/> </div> </div> <div> <br/><br/> <button type="submit" name="btnsave" value ="" >Submit Project</button> </div> </center> </form> </body>
  14. Hello topic: radio optoin button Problem: when the page loads up both radio options are blank. if i select one and change my mind and select the other one they both become selected. what i lke to see if i select one the other one needs to unselected. <input id="id_radio1" type="radio" value= "check1" name="newClient" <?php if (!empty($_POST['newClient'])) { echo 'checked="checked"'; } ?> /> New Client <input id="id_radio2" type="radio" value= "check2" name="returningClient" <?php if (!empty($_POST['returningClient'])) { echo 'checked="checked"'; } ?> />Returning Client Any help you can give me would be greatly appreciated. thanks l
  15. Hello everybody, Unable to output from array. whats wrong with the foreach loop?????? index.php $testdata = $classone->sendError(); echo "<br /> my value==>: ".$testdata[0][0]; <== works foreach ($testdata as $key => $value) <== Not working echo $key . '=>' . $value. '<br />'; results from var_dump($testdata); array(2) { [0]=> array(1) { [0]=> string(29) "First name must not be empty!" } [1]=> array(1) { [0]=> string(28) "Last name must not be empty!" } } my value==>: First name must not be empty! -------------------------------------------- the following class/function called from index.php: public function sendError() { if(classErray) {return $this->classError; } }
  16. hello, question regarding a property in a class. I'm working through a YIi framework tutorial and i came across the following line of code: $username=strtolower($this->username);. I'm new so bear with me.. looking at this code again: $username=strtolower($this->username); why can this be written as: $username=strtolower($username); why do i need "$this" to ref. the property within the class and why put extra code if its not necessary? and what does" =?" do in the line below? $user=User::model()->find('LOWER(username)=?',array($username)); copy/pasted the code below for better review: <?php class UserIdentity extends CUserIdentity { private $_id; public function authenticate() { $username=strtolower($this->username); $user=User::model()->find('LOWER(username)=?',array($username)); if($user===null) $this->errorCode=self::ERROR_USERNAME_INVALID; else if(!$user->validatePassword($this->password)) $this->errorCode=self::ERROR_PASSWORD_INVALID; else { $this->_id=$user->id; $this->username=$user->username; $this->errorCode=self::ERROR_NONE; } return $this->errorCode==self::ERROR_NONE; } public function getId() { return $this->_id; } }
  17. Hello everybody, Having problems keeping variables within the same page when the content of the page is saved or when the page is reloads to add the next set of data. The application is a data collecting page so I would need to keep certain variables the same as the same variables needs to appear in the next record. Looking at the code below, 2 variables are received into the page but it won?t stay if I hit the add button basically reloading the page. need the 2 variables returned back after clicking save. <?php echo "<br/>". $TaskId = $_POST['taskid1']; echo "<br/>". $Site = $_POST['site']; ?> <body> <form name="projectwalkthrough" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" > Task ID: <select name="taskid1" > <option value="selectid"> <?PHP if($TaskId) {echo $TaskId;} else {echo "Select Task ID";} ?></option> <?PHP while($row1=mysqli_fetch_array($ProjectIDResults)) { echo '<option value=" ' . $row1['ci_taskid'] . ' ">' . $row1['ci_taskid'] . '</option>'; } ?> </select> Site: <select name="site" > <option value="projectsite" > <?PHP if($Site) {echo $Site;} else {echo "select site";} ?></option> <?PHP while($row=mysqli_fetch_array($ProjectSiteResults)) { echo '<option value=" ' . $row['ps_site_short'] . ' ">' . $row['ps_site_short'] . '</option>'; } ?> </select> <input type="submit" name="savewalkthrough" id="button" value="Save current scope" /> </body> </form> </html>
  18. Hello everybody whats the best way to do this: Page: User entry page. focus: Dropdown list box - dropdown list box, populated from a database(works). -information pull for the dropdown listbox: Projectid(eg: 1,2,3...) and project name (eg: computer deployment) user makes the selection and clicks save. page returns back with the prev. selection which is fine but its a numeric value or the projectid. Need: like to have the project name appear rather then the project id but at the same time I need the projectid to save with the information collected in the user form so i can make reference to the project name at a later date using projectid . <form name="projectwalkthrough" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <body> Project name: <select name="projectid" > <option value="selectid"><?PHP if($ProjectID) {echo $ProjectID;} else {echo "Select Project ID";} ?></option> <?PHP while($row=mysqli_fetch_array($ProjectIDResults)) { echo '<option value=" ' . $row['ci_id'] . ' ">' . $row['ci_projectname'] . '</option>'; } ?> </select> any help you can provide would be greatly appreciated. thanks
  19. Hello everybody, I'm having probelms saving the valuses or the selections made from a checkbox. For most part the code works but the selection/data is saved only if all 3 options are checked in the checkbox. But with the checkbox the user has the option to either to sellect all or some of the options so how do i account for this in the mysql statement? <?php if(isset($_POST['button'])) { $devices_returned = $_POST['office']; $values = array(); foreach($devices_returned as $selection ) { if($selection) { $values[ $selection ] = 1; } else { $values[ $selection ] = 0; } } $insert1 = "INSERT INTO test_location (`desk`, `computer`, `whiteboard`) VALUES ({$values['desk']}, {$values['computer']}, {$values['whiteboard']})"; ?> html code <form name="checkbox" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="checkbox" name="office[]" value="desk"> Desk <input type="checkbox" name="office[]" value="computer"> Computer <input type="checkbox" name="office[]" value="whiteboard"> whiteboard <br> <input type="submit" value="Submit" name="button"> </form>
  20. Hello Alex_Hill Yes all the test scripts work. since then I added a few Alarts in the javascripts to narrow down the problem. The problem seem to be still the same. the following coded just not taking the country variable. I added a few echo statements (echo $country = $_GET['country'] to disply the content and its there. its just the javascript isnt taking it or the format is incorrect. select name="state" onchange="getCity([color=red][b]'<?=$country ?>'[/b][/color],this.value)"> <option>Select State</option> the code below isn't receiving the country variable. the state comes through but not the country. function getCity(country,stateId) { alert('Country==>:' + country + ' State==>: ' + stateId + '.'); var strURL="findCity.php?country="+country+"&state="+stateId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { document.getElementById('citydiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } }
  21. Hello All, I'm working on a script which I'm sure has been done many times, using 3 dropdown list box to select country, state, and city. Using PHP, AJAX, and MYSQL Whats working: I'm able to populate and select a country. At the same time I'm able to populate the state based on the country selection and select a state. Whats not working: not able to populate the city dropdown box. - not getting any errors to work with. the state variable is passed but the country variable isnt getting passed. I believe the problem is in "function getCity(countryId,stateId)" ajax script Any help you can provide would be greatly appreciated. <html> <head> <title> learning</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript" type="text/javascript"> function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");} catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getState(countryId) { var strURL="findprovstate.php?country="+countryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { document.getElementById("statediv").innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } function getCity(countryId,stateId) { var strURL="findCity.php?country="+countryId+"&state="+stateId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { document.getElementById('citydiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> </head> <body> <form method="post" name="form1"> <table border="0" cellpadding="0" cellspacing="0" width="60%"><tbody> <tr> <td width="150">Country</td> <td width="150"> <select style="background-color: #ffffa0" name="country" onchange="getState(this.value)">'; <?php require_once("C:\wamp\www\servicebid\inc\FindCountry.php"); while($row=mysqli_fetch_assoc($result)) {if($nextcountry = $row['country']) { echo '<option value="' . $row['country'] . '">' . $row['country'] . '</option>'; } } ?> </select></td> </tr> <tr style=""> <td>State</td> <td > <div id="statediv"> <select name="state" > <option>Select Country First</option> </select> </div> </td> </tr> <tr style=""> <td>City</td> <td ><div id="citydiv"> <select name="city"> <option>Select State First</option> </select> </div> </td> </tr> </tbody> </table> </form> </body> </html> The colde is used to populate the state/province. <?php require_once("C:\wamp\www\servicebid\inc\connection.php"); $country = $_GET['country']; $provinceState_query = "SELECT DISTINCT province from tb_location where country = '$country'"; $result= mysqli_query($dbconnect, $provinceState_query) or die('<br/>Error reading Database:'.mysql_error()); ?> <select name="state" onchange='getCity("<?=$country?>",this.value)'> <option>Select State</option> <?php while($row=mysqli_fetch_assoc($result)) { echo '<option value="' . $row['province'] . '">' . $row['province'] . '</option>'; } ?> </select> The code below is used to populate the city dropdown list box. at this stage the state is comming through but the country isnt. <?php require_once("C:\wamp\www\servicebid\inc\connection.php"); $countryId = $_GET['country']; $stateId = $_GET['state']; echo '<br> ==>:1'.$countryId; echo '<br> ==>:2'.$stateId; $city_query = "SELECT city from tb_location WHERE country ='$countryId' AND province='$stateId'"; $result= mysqli_query($dbconnect, $city_query) or die('<br/>Error reading Database:'.mysql_error()); while($row=mysqli_fetch_array($result)) { //testing echo 'br>'.$row['city']; } ?> <select name="city"> <option>Select City</option> <?php while($row=mysql_fetch_array($result)) { echo '<option value="' . $row['city'] . '">' . $row['city'] . '</option>'; } ?> </select>
×
×
  • 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.