PHP - Reloading The Page Renters An Order Into Mysql.
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.
Similar TutorialsI'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? 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. I have a session to check when the users login and fetch the details from their account but when they edit their avatar I want it to update the value right away. For it to change the value for the user they need to log out and back in, destroying the original session and recreating a new one on that account. Is there a way to have it always getting the data I need from the database while they're logged in? Because I don't want it to only get the orignial data in case they change a setting so they don't have to log out and then back in to change the setting. I hope you understand 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? 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 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 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=305930.0 This 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 I'm currently trying to grab data from my database for my chatbox, which when displayed, displays in an ascending order, when I call it to descend, it shows the messages ONCE in descending order, then just repeats but in random order.. Code: [Select] $sql = "SELECT * FROM `message` WHERE `chat_id` = 1 AND `message_id` > $last ORDER BY `message_id` DESC"; Database: message_id | name 1 RSX 2 RSX 3 RSX 4 RSX Code: [Select] RSX: 4 RSX: 3 RSX: 2 RSX: 1 RSX: 4 RSX: 3 RSX: 2 RSX: 4 RSX: 3 RSX: 4 It is ordering it correctly, just repeats, I'm using Ajax, could that be the problem, or is it within the PHP code? Edit: I read it wrong, it displays as shown under "output". Lets say I have this query: $sql = mysql_query("SELECT * FROM Member ORDER BY posts DESC LIMIT 10"); while ($get = mysql_fetch_array($sql)){ $row .= $get['id']; $posts .= $get['posts']; echo "$row - $posts<br />"; } Lets say I have two of rows, with posts fields of 84 and 803. When it displays it, it grabs the 84 row first, when I want the bigger number 803 first. Is there a way to fix this? Hello, I would like to order by date that contains day and month, like this: 14-3 Is this possible? Quote $sql = mysql_query("SELECT * FROM date WHERE online='1'"); This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=347726.0 When you make a mysql query the results are always returned with the first being the first entry in the database. I was wondering if there is a way to make it so that the last entry is returned first and so on? Thanks for any help. ok so i want to order by high to low on the field price but i don't know how to do this. i can order low to high by using ORDER BY `Price` ASC but how can i order high to low? hello all. I have a list of records, which each have a comment button, just like any forum does. when I click on the comment button it brings up the current record at the top, and a blank form, to which you enter in information. When I submit this information, I want it to show up on the main page as a child of the parent record. I want it similar to the example I've shown below: Code: [Select] id name dob address email username 1 john smith 10/11/1986 124 Peermont Drive john.smith@yahoo.com john smith1 >> 2 Harry 15/12/1985 98 The Roundhay harry@gmail.com harry23 >>> 3 jhk 08/11/1976 65 dfgdfg gfdfg@ yahoo.com jhk345 4 john smith 10/11/1986 124 Peermont Drive john.smith@yahoo.com john smith1 >> 5 Harry 15/12/1985 98 The Roundhay harry@gmail.com harry23 >>>> 6 jhk 08/11/1976 65 dfgdfg gfdfg@ yahoo.com jhk345 I've been stuck on this for hours, and I haven't got anywhere. Any ideas? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=320026.0 How can i select the last 3 rows in a table and order it by ASC. When i use DESC it displays the results in the wrong order. $query24 = mysql_query("SELECT * FROM notifications WHERE to_id='$session' AND state='1' ORDER BY id DESC LIMIT 3 "); This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=349226.0 Im displaying scores from my database from highest to lowest but 10 always comes out first. Why? |