NationGamer Posted February 1, 2011 Posted February 1, 2011 ok the problem im having is with preferences ive edited it so it returns a message on same page say i post some data like a new username the php dont update till next page refresh as im sending back a msg that prints out aswell like so $msg ="Username Changed!!"; <?echo$msg?> is there anyway to make the php update aswell after the query has been inserted into the database more like dynamic php varibles really Quote
Dayo Posted February 1, 2011 Posted February 1, 2011 Not really sure what you are trying to qcheive but is this the sort of thing If (mysql_query(....)) { echo $msg; } that will run the query then if it is successful it will show the variable Quote
NationGamer Posted February 1, 2011 Author Posted February 1, 2011 yh i know how to echo the message out but the problem is after the mysql update and the msg has echoed on the page the value that was update into database dont update on the php page till the page is refreshed example current username: demo change the username to: test and after the mysql query gos through the value stay the same on the page till next page refresh is it possible to make the value on the page update strait after the query without using like header location and the refresh function as i need to return a message to the php page after the update Quote
bluegman991 Posted February 1, 2011 Posted February 1, 2011 u will have to do it vie javascript add an id to the element were username is conatained eg:<span id="username">Username</span> can have a js function like this function changeUsername(newname) { document.getElementById('username').innerHTML=newname; } then as the php code ad if(mysql_query(...)) { echo "<script>changeUsername('$newusername');</script>"; } Quote
Dayo Posted February 1, 2011 Posted February 1, 2011 kk for this you need to do the query before $ir is set OR run the code before header.php is included if it is the username your changing you would do something like mysql_query(.....); $ir['username']=$newname; $msg='...........'; Quote
NationGamer Posted February 2, 2011 Author Posted February 2, 2011 thanks dayo never thought you could do that it worked a dream thanks again it all dynamically updating now as i didnt want to use the javascript alternative as i think it adds code that you dont actually need and bulks the script up lol thanks again Quote
Dayo Posted February 2, 2011 Posted February 2, 2011 No problem, I use this for the mercenary it looks so much better aswell :) Quote
NationGamer Posted February 2, 2011 Author Posted February 2, 2011 yeah for sure i love how it updates now as i hated to see the not dynamic as it look cheap and nasty and lowers the game alot in user eyes Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.