Hi,
Does anyone know how to collect information from a database and then display it in an array built within javascript.
These are the three pages I have currently:
The first is the html page which will hopefully display the results.
The second is the javascript which is called when the page is loaded
The third code is the php script which i want to use to pull the information from the database.
So what I want to be able to do is instead of the message 1 message 2 and message 3 which is in the javascript code above i would like it to display the results from the database which could be an unlimited amount of results.
Can any one give me guidance on how to do this.
Regards
Andy
Does anyone know how to collect information from a database and then display it in an array built within javascript.
These are the three pages I have currently:
The first is the html page which will hopefully display the results.
Code:
<html>
<head>
<script src="getcontents.js"></script>
</head>
<body onload="slidemessage()">
<form name="slideshow"><div align="center"><center>
<input type="text" size="300" style="font-style: italic; border: none; background-color: transparent;">
<!--<input type="button" value="Take me there!" name="B1" onClick="window.location=messagelinks[curmsg]">--></p>
</center></div>
</form>
</body>
</html>
The second is the javascript which is called when the page is loaded
Code:
var curmsg=-1
var messages=new Array()
messages[0]="Message 1"
messages[1]="Message 2"
messages[2]="Message 3"
var messagelinks=new Array()
messagelinks[0]="[URL unfurl="true"]http://message1.com"[/URL]
messagelinks[1]="[URL unfurl="true"]http://www.message2.com"[/URL]
messagelinks[2]="[URL unfurl="true"]http://www.message3.com"[/URL]
function slidemessage(){
if (curmsg<messages.length-1)
curmsg++
else
curmsg=0
//document.getelementbyname("s").value=messages[curmsg]
document.slideshow[0].value=messages[curmsg]
setTimeout("slidemessage()",4500)
}
slidemessage()
The third code is the php script which i want to use to pull the information from the database.
Code:
<?
require_once ('../templates/mysql_connect.php');
$query = "SELECT summary, content FROM content where companyID = $company and rss = 1";
$result = @mysql_query ($query);
if ($result){
while ($row =mysql_fetch_array($result, MYSQL_NUM)){
echo"$row[0]\n";
}
mysql_free_result ($result);
}
?>
So what I want to be able to do is instead of the message 1 message 2 and message 3 which is in the javascript code above i would like it to display the results from the database which could be an unlimited amount of results.
Can any one give me guidance on how to do this.
Regards
Andy