0

Hi I am new to this forum and hoping someone could help I have set a dropdown menu with option value dynamically pulling in from a mysql database. these values when selected use xml to return the ids and content according to whats been selected. In the url there is a variable which im having trouble getting PHP to create a session variable from it. Can this be done? Thanks

Thanks, this is the code where the url is set

function showUser(str) { var xmlhttp; if (str.length==0) { document.getElementById("state").innerHTML=""; return; } if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("state").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(null); }

The php call '$id = $_GET['q']; $_SESSION['q'] = $id;'

3
  • You have a dropdown menu with values retrieved from database. When selected, what XML is used? Which URL variable is problem, how the URL looks like? What session variable you need to create. Please explain more and provide the code. Commented Mar 21, 2014 at 11:52
  • Hi I have provided the code above. I am also using buttons on the same page as the drop down which when clicked displays some content according to the selection in the drop down menu.The buttons use ajax calls to pull in php pages but need it to link with the drop down. Commented Mar 21, 2014 at 13:11
  • Ok, and where do you get the error? This code looks like after showUser() function is called the element with id state will have innerHTML updated with data recieved from PHP. Session variable should be also set, but this will take effect (in PHP) after page is reload. Commented Mar 21, 2014 at 13:48

1 Answer 1

1

Do you mean this?

http://www.domain.com/?action=delete

$action = $_GET['action'];
$_SESSION['action'] = $action;
Sign up to request clarification or add additional context in comments.

5 Comments

No its not been solved I have attached the code to the question.
PLease unlock this post by click on de v sign I will check it later for you.
Is this what you want or mean? w3schools.com/php/php_ajax_database.asp
Hi I managed to use the example given above and worked. Thanks for your help. I just copied the $_SESSION['q'] with session_start(); at top to my other pages :)
Great, can you close this topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.