Hi, i think i posted this wrong in databases...more a php-question I think.
I wanna open a php-file from my javascript and then in the php-file search through my databse and display the results on the original site(the one that called the javascript) with innerHTML. Or if you have any option to that, the main thing is that its done without the page reloads.
You see my code down here, thats so far i have got, its getting messy when i try to either display the results from inside the php-file, or passing the results back to the javascript...I would be very happy to get help with this
displaydata.js
function displaydata(kurskod)
{
var url = "displaydata.php?kurskod=" + kurskod;
var mozillaFlag = false;
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
var XMLHttpRequestObject = new XMLHttpRequest();
if (XMLHttpRequest.overrideMimeType) {
XMLHttpRequestObject.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) {
try {
var XMLHttpRequestObject = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
var XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {}
}
}
if(XMLHttpRequestObject) {
XMLHttpRequestObject.open("GET", url, true);
XMLHttpRequestObject.onreadystatechange = function()
{
}
XMLHttpRequestObject.send(null);
}
}
displaydata.php
<?php
include "conn.php";
$kurskod = $_GET['kurskod'];
if (isset($kurskod))
{
$query = "SELECT * FROM litteraturlista_temp WHERE kurskod = $kurskod";
$result = mysql_query($query) or die("SQL: $query <br />\n".mysql_error());
echo "<table>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr><td>{$row['titel']}</tr></td>";
}
}
?>
<script language="javascript">
var target = document.getElementById("reklam");
target.innerHTML += '<p "' + iconurl + '">' ;
</script>
<td id="{$row['id']}"></td>