من این کد رو تغییر دادم
ولی فقط 1 رکورد چاپ و تکرار میکنه و رکوردهای دیگه رو نمایش نمیده
کد HTML:
<?php
mysql_connect('localhost', 'root', '') or die('Connection error');
mysql_select_db('slide') or die('Database does not exist');
$q = mysql_query('SELECT * FROM `slide` ORDER BY `id` DESC LIMIT 5');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<div class=ticki>
<p dir=rtl>
<font style="FONT-SIZE: 8pt" face=Tahoma color="#3366ff"><span id=theTicker></span></font>
<script type="text/javascript">
var theSummaries = new Array();
var theSiteLinks = new Array();
<?php
while($line = mysql_fetch_assoc($q)) { $i=0; ?>
theSummaries[<?php echo $i; ?>]= "<?php echo $line['txt']; ?>";
<?php
$i++;
}
?>
var theCharacterTimeout = 50;
var theStoryTimeout = 5000;
var theWidgetOne = "_";
var theWidgetTwo = "-";
var theWidgetNone = "";
var theItemCount = theSummaries.length;
var NS6=(document.getElementById && !document.all) ? true : false;
function startTicker(){
theCurrentStory = -1;
theCurrentLength = 0;
if (document.getElementById){
runTheTicker();
}
else{
document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
return true;
}
}
function runTheTicker(){
var myTimeout;
if(theCurrentLength == 0){
theCurrentStory++;
theCurrentStory = theCurrentStory % theItemCount;
theStorySummary = theSummaries[theCurrentStory];
theTargetLink = theSiteLinks[theCurrentStory];
}
var textTitle = theStorySummary.substring(0,theCurrentLength) + whatWidget();
if (theTargetLink ){
if (NS6){
document.getElementById("theTicker").innerHTML = '<a target="_blank" href='+theTargetLink+'>'+textTitle+'</a>';
}
else{
document.all.theTicker.innerHTML = '<a target="_blank" href='+theTargetLink+'>'+'<font face="Tahoma" style="font-size: 8pt"><span style="text-decoration: none">'+textTitle+'</span></font>'+'</a>';
}
}
else {
if (NS6){
document.getElementById("theTicker").innerHTML = '<a target="_blank" href='+theTargetLink+'>'+'<span class="tickertext">'+textTitle+'</span>'+'</a>';
}
else{
document.all.theTicker.innerHTML = '<a target="_blank" href='+theTargetLink+'>'+'<span class="tickertext">'+textTitle+'</span>'+'</a>';
}
}
if(theCurrentLength != theStorySummary.length){
theCurrentLength++;
myTimeout = theCharacterTimeout;
}
else{
theCurrentLength = 0;
myTimeout = theStoryTimeout;
}
setTimeout("runTheTicker()", myTimeout);
}
function whatWidget(){
if(theCurrentLength == theStorySummary.length){
return theWidgetNone;
}
if((theCurrentLength % 2) == 1){
return theWidgetOne;
}
else{
return theWidgetTwo;
}
}
startTicker();
</script>
</p></div>
</body>
</html>