I know, I know. From the title up above, you are probably wondering what in in the world I am asking. Let me try and break this down a little easier because I am stuck and cannot figure this out. So here goes…I have a place on my site where a user can look at a list of news items that have been posted in the past. All of the news items are listed in a MYSQL database and is retrieved and displayed on the page using PhP. That part I get. What I cannot figure out is how, when they click on a particular entry in the list, it will load a new .php page in a DIV below the list without reloading the page, and the page that opens will be pre-populated with all of the content of the news item they have clicked on. In the past, I have done something similar using <a href="someurl.com?var=<?php echo $variable_from_list; ?> However, because I need the page to load into a DIV without reloading the page, that method does not work for me. I have had success loading the page into the DIV without a page reload using this coding:<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(“myDiv”).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open(“GET”,“demo_post2.php?<?php echo $variable_from_list; ?>”,true);
xmlhttp.setRequestHeader(“Content-type”,“application/x-www-form-urlencoded”);
xmlhttp.send(“fname=Henry&lname=Ford”);
}
</script>
The above code does indeed load the php page into the DIV, but it is only passing across the variable from the first item in the list, regardless of which news entry the user clicks on. I have racked my brain trying to find the answer but have been unsuccessful. I would be so greatly appreciative if anyone out there has some solutions for me to try. Thanks so much…