PHP - Moved: How To Change 3 Dropdown List Without Page Reloading--some Help Please?
This topic has been moved to Ajax Help.
http://www.phpfreaks.com/forums/index.php?topic=305930.0 Similar TutorialsThis topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=314750.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=326913.0 Hello, I have links at above of the page. if i click a link a new page will appear. The menu links above are same for all pages. Which is better reloading the whole page with all menu links or keeping the above menu link permanent/unchange reloading bottom division with ajax? I mean only one page will contain the menu.Is it better? Or every page will contain the menu above.Is it better then the first one? I say many web site they have link menus above if i click a link from above it seems the whole page reloads or chages. For example:http://www.sitepoint.com/ Thank you. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316599.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316053.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=331067.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=343748.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=356195.0 I have a php generated image: (number.txt contains a number 1 or 2) pic.php Code: [Select] <?php // Set the content-type header('Content-type: image/bmp'); // Create the image $im = imagecreatetruecolor(80, 80); $count_my_page = ("number.txt"); $hits = file($count_my_page); if ($hits[0] == 1) { $im = imagecreatefrompng("image1.png"); $hits[0] ++; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]"); fclose($fp); }else{ $im = imagecreatefrompng("image2.png"); $hits[0] --; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits[0]"); fclose($fp); } // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 1, 1, 1); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> And I have another page index.html Code: [Select] <img src="pic.php"> <img src="pic.php"> Basically, I need one of the images on the index page to be image1 and then the second image to be image2, but it must be contained within the php file because I am unable to edit index.html. Is there anyway to do this? The method I have now where it reads a file to see if it's value is 1 or 2 doesn't seem to compute each time the image is generated. I have tried header("Cache-Control: no-cache"); header("Pragma: no-cache"); in the image code to force it not to cache but to no avail. Can anyone solve this? hey guys im sure this is possible im wondering how a user can execute a mysql query by a click of a button but without the page reloading...thanks guys Hi everybody I am a PHP rookie for now, and I want to reload the same dynamic page - it's content in several languages - by clicking little flags which are located at some point on the page - AND ITS NOT WORKING. Clicking on the flag triggers a PHP script which basically says Code: [Select] ]$_SESSION['lang'] = <Some_language>; require ('webpage.php'); where webpage.php is the dynamic page, in different languages, with it's content drawn out from a database (which contains the content in all languages I chose to display, blah, blah) Funny thing - when I look at the page html (View Page Source) - it seems OK (identical from one page to the next) ! But WHAT is displayed after the first attempt to change the language is not. Is something fundamentally wrong with my approach ? Mike What is the best function to use to ensure an order is not re-entered when the user selects reload page? I can link code if you'd like but I'm only looking for a direction to go in and search google with. 'reload current page inserts extra' that google search hasn't been fruitful. I'm trying to show the same data, but updated right away. For example. I want to update my coords on a map and refresh a div to show the new data, but as the code now, it keeps the same data until I reload the page. Here is the code I have now. if ($north) { $ylocation = $users['y'] + 1; if ($ylocation > 5) { $ylocation = 0; } $locationyupdate = ("UPDATE players SET y = '$ylocation' WHERE name='$users[name]'"); mysql_query($locationyupdate) or die("could not register");?> <script type="text/javascript"> $('#npc').load('npc.php'); $('#description').load('description.php'); </script><?} The update code is before the reload script for the two div's. The data DOES change in the database, but the two div's won't display the new data until it is refreshed again. Do I need to reactivate fetch to get the new data? Hi, I am trying to call the data from Mysql but I am getting an empty drop down list, this is the code: mysql: Code: [Select] create table years ( yearID integer auto_increment, year varchar(30), primary key (yearID) ); insert into years (yearID, year) values ('1', '2007-2008'); insert into years (yearID, year) values ('2', '2008-2009'); insert into years (yearID, year) values ('3', '2009-2010'); insert into years (yearID, year) values ('4', '2010-2011'); insert into years (yearID, year) values ('5', '2011-2012'); insert into years (yearID, year) values ('6', '2012-2013'); PHP: Code: [Select] <?php require_once('../Connections/connection.php'); ?> <?php $result = @mysql_query( "select yearID, year, from sss.years"); print "<p>Select a year:\n"; print "<select name=\"yearID\">\n"; while ($row = mysql_fetch_assoc($result)){ $yearID = $row[ 'yearID' ]; $year = $row[ 'year' ]; print "<option value=$yearID>$year\n"; } print "</select>\n"; print "</p>\n"; ?> Thank you! I have the following code currently: Code: [Select] <?php foreach ((array)$node->field_buy_at as $item) { ?> <?php print $item['view'] ?> <?php } ?> I would like to make the list a drop down with a link so that when a user selects, he goes to a new page. I tried the following: Code: [Select] <select name="select"> <?php foreach ((array)$node->field_buy_at as $item) { ?> <?php $url = $node->field_buy_at[0]['url']; $store = $item['view']; ?> <? echo "<option value='$url'>$store</option>";?> <?php } ?> </select> I'm pretty sure it's this "$url = $node->field_buy_at[0]['url'];" that I don't have correct. Hi i'm new to php. I want to get all the values of dropdown list on another page wether selected or not. Hey Guys, I know it may seem pretty simple, but im having trouble populating a drop down list. Here is my code at the moment, but what it's doing is displaying the names all in one value, where it should be in separate select values. *Note that i have only done it to the first one. See attachment. 'AntonMatt' are next to each other, they should be separate select values. Code: [Select] <? $id = $_GET['id']; $selectplayers="SELECT * FROM players WHERE club='$club' AND team='$team'"; $player=mysql_query($selectplayers); ?> <table class='lineups' width="560" cellpadding="5"> <tr> <td colspan="2">Starting Lineup</td> <td colspan="2">On the Bench</td> </tr> <tr> <td width="119"> </td> <td width="160"> </td> <td width="69"> </td> <td width="160"> </td> </tr> <tr> <td>Prop</td> <td><select name="secondary" style="width: 150px"> <option value='' selected="selected"><? while($rowplayer = mysql_fetch_array($player)) { echo $rowplayer['fname']; } ?></option> </select></td> <td>16.</td> <td><select name="secondary16" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> </tr> <tr> <td style="padding-top: 8px;">Hooker</td> <td style="padding-top: 8px;"><select name="secondary2" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> <td style="padding-top: 8px;">17.</td> <td style="padding-top: 8px;"><select name="secondary17" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> </tr> </table> </div> </div> I'm trying to sort this dropdown box. It reads from a directory, and lists the file name in the dropdown box. Here's the tricky part... the filename is listed differently in the dropdown than in the directory by using explode(). I want to sort it though since it's still being sorted by the directory listings... For example: Filename starts out as: 123_abc_567.pdf then gets listed as abc_123_567.pdf in the dropdown, but it's still getting sorted as if it were 123_abc_567.pdf How can I do that? Here's my code: // Define the full path to folder from root $path = "C:/Work_Orders/"; // Open the folder $dir_handle = @opendir($path) or die("Unable to open $path"); echo "<form method=\"POST\" action='".$_SERVER['PHP_SELF']."' name='selectworkorder'><select name='ordernumber2'>"; // Loop through the files while ($file = readdir($dir_handle)) { //Remove file extension $ext = strrchr($file, '.'); if($ext !== false) { $file = substr($file, 0, -strlen($ext)); } if($file == "." || $file == ".." || $file == "index.php" ) continue; //explode file name $changedordernumber = explode("_",$file); //put in new order $changedordernumber = $changedordernumber[1]."_".$changedordernumber[0]."_".$changedordernumber[2]; $changedordernumber=trim($changedordernumber,"_"); //list options echo "<option name='$file' value='$file'>$changedordernumber</option>\n"; } echo "</select><input type='submit' value='Change' name='submit'/></form></div>"; // Close closedir($dir_handle); i have been trying to get this code to get a list of usernames from a database and i have now got that to work but when i try and save it it saves all the usernames from the drop down list and not just the one i have selected how can i get it to just use the one i have selected Code: [Select] <?php include "connect.php"; //connection string include("include/session.php"); print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<table class='maintables'>"; print "<tr class='headline'><td>Post a message</td></tr>"; print "<tr class='maintables'><td>"; // Write out our query. $query = "SELECT username FROM users"; // Execute it, or return the error message if there's a problem. $result = mysql_query($query) or die(mysql_error()); $dropdown = "<select name='username'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['username']}'>{$row['username']}</option>"; } $dropdown .= "\r\n</select>"; if(isset($_POST['submit'])) { $name=$session->username; $yourpost=$_POST['yourpost']; $subject=$_POST['subject']; $to=$dropdown; if(strlen($name)<1) { print "You did not type in a name."; //no name entered } else if(strlen($yourpost)<1) { print "You did not type in a post."; //no post entered } else if(strlen($subject)<1) { print "You did not enter a subject."; //no subject entered } else { $thedate=date("U"); //get unix timestamp $displaytime=date("F j, Y, g:i a"); //we now strip HTML injections $subject=strip_tags($subject); $name=strip_tags($name); $yourpost=strip_tags($yourpost); $to=strip_tags($to); $insertpost="INSERT INTO forumtutorial_posts(author,title,post,showtime,realtime,lastposter,name) values('$name','$subject','$yourpost','$displaytime','$thedate','$name','$to')"; mysql_query($insertpost) or die("Could not insert post"); //insert post print "Message posted, go back to <A href='forum.php'>Forum</a>."; } } else { print "<form action='newtopic.php' method='post'>"; print "Your name:<br>"; print "$session->username<br>"; print "User to send to:<br>"; print "$dropdown"; print "Subject:<br>"; print "<input type='text' name='subject' size='20'><br>"; print "Your message:<br>"; print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } print "</td></tr></table>"; ?> MOD EDIT: Changed PHP manual link [m] . . . [/m] tags to [code] . . . [/code] tags. |