Here is the HTML/JS Code:
<script type="text/javascript">
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("dd123").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","externalphpcode.php?t=" + Math.random(),true);
xmlhttp.send();
}
window.onload=loadXMLDoc();
</script>
And the External PHP Code:
<?php
header ('Location: urlofHTMLcode');
$con = mysql_connect("hostname","databasename","password");
if (!$con)
{
die('Test Error'.mysql_error());
}
$db_selected = mysql_select_db("databasename", $con);
if (!db_selected)
{
die("Error 3 : ".mysql_error());
}
$result= "SELECT COLUMN_1 FROM T_DEALS WHERE COLUMN_2 = '2011-01-03'
and COLUMN_3 = 'VALUE_1'" or die ("Error 4 :".mysql_error());
$row = mysql_fetch_array($result);
echo $row;
mysql_close($con);
exit ();
Here's the issue I've been encountering, with much of the HTML/JS redacted for brevity. I've verified that the HTML/JS file is accurately calling the external PHP file by altering the PHP to insert into mySQL. I've been trying to get the SQL Query result to display in a specified DIV container via the PHP echo command paired with the ".responseText" command via AJAX. What am I doing wrong? There doesn't seem to be an issue with the object referencing in HTML, and when debugging the PHP/mySQL connection an error message would replace the DIV with the appropriate error message which is not occurring once the code is altered to call the mySQL data values.
Thank you in advance.