Jump to content
MakeWebGames

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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>";
}
Posted

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='...........';

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...