par
betman » 14 déc. 2005, 11:04
Bonjour à tous,
J'ai un javascript qui crée un texte déroulant, je souhaiterai afficher dynamiquement les données qui défileront. Le problème c'est que je n'arrive pas à placer ma balise de fermeture PHP.
Pour info mes mon script est placé dans une celulle
le code :
<td>
<?php
include('connection.inc.php');
$query = "SELECT * FROM actu";
$result = mysql_query($query);
$nb = mysql_numrows($result);
while ($val = mysql_fetch_array($result))
{ /* On parcoure les résultats de la requête */
$id = $val["id"];
$titre = $val["titre"];
$sstitre = $val["sstitre"];
$photo = $val["photo"];
?>
<script>
// CONFIGURATION:
// Go to http://www.24fun.com
// and create your own text animation
// with our new Text Factory.
var textbgcolor="#F5F5F5"
var textwidth=250
var textheight=200
var textborder=0
var textbordercolor=""
var i_text=0
var textcontent=""
var thisspan=""
var content=""
var contentbg=""
var toggle=1
var timer
var scrollready=true
var tablewidth
var tableheight
var step=1
var content
var padding=3
var textcontentheight
var ie=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0
var ns4=document.layers?1:0
if (ie || ns6) {
document.write('<table cellpadding=0 cellspacing=0 border=0 height='+textheight+' width='+textwidth+'><tr><td>');
document.write('<div id="marker" style="position:relative; width:'+textwidth+'; height:'+textheight+'"></div>');
document.write('</td></tr></table>')
if (ns6) {
var tablewidth=textwidth-2*textborder
var tableheight=textheight-2*textborder
}
else {
var tablewidth=textwidth
var tableheight=textheight
}
document.write('<div ID="roof" style="position:absolute;width:'+ tablewidth +'px;height:'+ tableheight +'px;border-style:solid;border-width:'+ textborder +'px;border-color:'+ textbordercolor +';background-color:'+ textbgcolor +';overflow:hidden;visibility:hidden" onMouseOver="setscrollready(0)" onMouseOut="setscrollready(1)">')
document.write('<span ID="ticker" style="position:absolute;top:0px;left:0px;visibility:hidden">')
}
if (ns4) {
document.write('<table cellpadding=0 cellspacing=0 border=0 height='+textheight+' width='+textwidth+'><tr><td>');
var widthMinusTwoBorder=textwidth-2*textborder
var heightMinusTwoBorder=textheight-2*textborder
var widthMinusFourBorder=textwidth-4*textborder
var heightMinusFourBorder=textheight-4*textborder
}
</script>
<ilayer name="marker" left="-2" z-index="2" width="450" height="" visibility="hide" bgcolor=""></ilayer>
<layer name="tickerbg" left="" top="" z-index="4" width="450" visibility="hide" bgcolor="">
</layer>
<layer name="roof" z-index="5" width="450">
<layer name="ticker" left=-4 top=0 z-index="1" width="450" onMouseOver="setscrollready(0)" onMouseOut="setscrollready(1)">
<p align="left"><span class="texte_lien_rouge"> <?php echo ($titre); ?> </span> <span class="texte_lien"><a href="#" class="texte_lien">test</a></span></p>
<p align="left"><span class="texte_lien_rouge"> > test : </span> <span class="texte_lien"><a href="#" class="texte_lien">test</a></span></p>
<p align="left"><span class="texte_lien_rouge"> > test : </span> <span class="texte_lien"><a href="#" class="texte_lien">test</a></span></p>
</layer>
</layer> <?php
}
?>
<script>
if (ns4) {
document.write('</td></tr></table>')
}
if (ie || ns6) {
document.write('</span></div>')
}
function doscroll(){
if (scrollready) {
if(ns4){
document.roof.document.ticker.top+=-step;
if(document.roof.document.ticker.top<-textcontentheight + 30) {
document.roof.document.ticker.top=textheight;
}
}
if (ie) {
document.all.ticker.style.posTop+=-step
if (document.all.ticker.style.posTop<-textcontentheight + 30) {
document.all.ticker.style.posTop=textheight
}
}
if (ns6) {
document.getElementById('ticker').style.top=parseInt(document.getElementById('ticker').style.top)-step
if (parseInt(document.getElementById('ticker').style.top)<-textcontentheight) {
document.getElementById('ticker').style.top=textheight
}
}
timer=setTimeout("doscroll()",40)
}
else {
clearTimeout(timer)
}
}
function DL_GetElementLeft(eElement) {
var nLeftPos = eElement.offsetLeft;
var eParElement = eElement.offsetParent;
while (eParElement != null) {
nLeftPos += eParElement.offsetLeft;
eParElement = eParElement.offsetParent;
}
return nLeftPos;
}
function DL_GetElementTop(eElement) {
var nTopPos = eElement.offsetTop;
var eParElement = eElement.offsetParent;
while (eParElement != null) {
nTopPos += eParElement.offsetTop;
eParElement = eParElement.offsetParent;
}
return nTopPos;
}
function initscroller(){
if (ns4) {
var thisspan=eval("document.roof.document.ticker")
textcontentheight=thisspan.clip.bottom-thisspan.clip.top;
document.roof.left=document.marker.pageX
document.roof.top=document.marker.pageY+1*textborder
document.tickerbg.left=document.marker.pageX+1*textborder
document.tickerbg.top=document.marker.pageY+1*textborder
document.roof.clip.width=textwidth;
document.roof.clip.height=textheight-2*textborder;
thisspan.top=textheight;
thisspan.clip.width=textwidth;
thisspan.clip.height=textcontentheight;
document.roof.visibility="show";
document.tickerbg.visibility="show";
thisspan.visibility="show";
}
if (ie) {
textcontentheight=document.all.ticker.clientHeight
document.all.roof.style.posLeft=DL_GetElementLeft(document.all.marker);
document.all.roof.style.posTop=DL_GetElementTop(document.all.marker);
document.all.ticker.style.posTop=textheight
document.all.ticker.style.clip='rect(0px, '+(textwidth-4)+'px, '+(textcontentheight)+'px, 0px)';
document.all.roof.style.visibility="visible";
document.all.ticker.style.visibility="visible";
}
if (ns6) {
textcontentheight=document.getElementById('ticker').offsetHeight
document.getElementById('roof').style.left=DL_GetElementLeft(document.getElementById('marker'));
document.getElementById('roof').style.top=DL_GetElementTop(document.getElementById('marker'));
document.getElementById('ticker').style.top=-textcontentheight
document.getElementById('ticker').clip='rect(0px, '+(textwidth-4)+'px, '+(textcontentheight)+'px, 0px)';
document.getElementById('roof').style.visibility="visible";
document.getElementById('ticker').style.visibility="visible";
}
doscroll()
}
function setscrollready(whatanswer) {
if (whatanswer==1) {
scrollready=true
checkscroll()
}
else {
scrollready=false
}
}
function checkscroll() {
clearTimeout(timer)
if (scrollready) {
doscroll()
}
}
function reopenpage() {
history.go(0)
}
window.onresize=reopenpage
window.onload=initscroller
</script>
</td>
Bonjour à tous,
J'ai un javascript qui crée un texte déroulant, je souhaiterai afficher dynamiquement les données qui défileront. Le problème c'est que je n'arrive pas à placer ma balise de fermeture PHP.
Pour info mes mon script est placé dans une celulle
le code :
[php] <td>
<?php
include('connection.inc.php');
$query = "SELECT * FROM actu";
$result = mysql_query($query);
$nb = mysql_numrows($result);
while ($val = mysql_fetch_array($result))
{ /* On parcoure les résultats de la requête */
$id = $val["id"];
$titre = $val["titre"];
$sstitre = $val["sstitre"];
$photo = $val["photo"];
?>
<script>
// CONFIGURATION:
// Go to http://www.24fun.com
// and create your own text animation
// with our new Text Factory.
var textbgcolor="#F5F5F5"
var textwidth=250
var textheight=200
var textborder=0
var textbordercolor=""
var i_text=0
var textcontent=""
var thisspan=""
var content=""
var contentbg=""
var toggle=1
var timer
var scrollready=true
var tablewidth
var tableheight
var step=1
var content
var padding=3
var textcontentheight
var ie=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0
var ns4=document.layers?1:0
if (ie || ns6) {
document.write('<table cellpadding=0 cellspacing=0 border=0 height='+textheight+' width='+textwidth+'><tr><td>');
document.write('<div id="marker" style="position:relative; width:'+textwidth+'; height:'+textheight+'"></div>');
document.write('</td></tr></table>')
if (ns6) {
var tablewidth=textwidth-2*textborder
var tableheight=textheight-2*textborder
}
else {
var tablewidth=textwidth
var tableheight=textheight
}
document.write('<div ID="roof" style="position:absolute;width:'+ tablewidth +'px;height:'+ tableheight +'px;border-style:solid;border-width:'+ textborder +'px;border-color:'+ textbordercolor +';background-color:'+ textbgcolor +';overflow:hidden;visibility:hidden" onMouseOver="setscrollready(0)" onMouseOut="setscrollready(1)">')
document.write('<span ID="ticker" style="position:absolute;top:0px;left:0px;visibility:hidden">')
}
if (ns4) {
document.write('<table cellpadding=0 cellspacing=0 border=0 height='+textheight+' width='+textwidth+'><tr><td>');
var widthMinusTwoBorder=textwidth-2*textborder
var heightMinusTwoBorder=textheight-2*textborder
var widthMinusFourBorder=textwidth-4*textborder
var heightMinusFourBorder=textheight-4*textborder
}
</script>
<ilayer name="marker" left="-2" z-index="2" width="450" height="" visibility="hide" bgcolor=""></ilayer>
<layer name="tickerbg" left="" top="" z-index="4" width="450" visibility="hide" bgcolor="">
</layer>
<layer name="roof" z-index="5" width="450">
<layer name="ticker" left=-4 top=0 z-index="1" width="450" onMouseOver="setscrollready(0)" onMouseOut="setscrollready(1)">
<p align="left"><span class="texte_lien_rouge"> <?php echo ($titre); ?> </span> <span class="texte_lien"><a href="#" class="texte_lien">test</a></span></p>
<p align="left"><span class="texte_lien_rouge"> > test : </span> <span class="texte_lien"><a href="#" class="texte_lien">test</a></span></p>
<p align="left"><span class="texte_lien_rouge"> > test : </span> <span class="texte_lien"><a href="#" class="texte_lien">test</a></span></p>
</layer>
</layer> <?php
}
?>
<script>
if (ns4) {
document.write('</td></tr></table>')
}
if (ie || ns6) {
document.write('</span></div>')
}
function doscroll(){
if (scrollready) {
if(ns4){
document.roof.document.ticker.top+=-step;
if(document.roof.document.ticker.top<-textcontentheight + 30) {
document.roof.document.ticker.top=textheight;
}
}
if (ie) {
document.all.ticker.style.posTop+=-step
if (document.all.ticker.style.posTop<-textcontentheight + 30) {
document.all.ticker.style.posTop=textheight
}
}
if (ns6) {
document.getElementById('ticker').style.top=parseInt(document.getElementById('ticker').style.top)-step
if (parseInt(document.getElementById('ticker').style.top)<-textcontentheight) {
document.getElementById('ticker').style.top=textheight
}
}
timer=setTimeout("doscroll()",40)
}
else {
clearTimeout(timer)
}
}
function DL_GetElementLeft(eElement) {
var nLeftPos = eElement.offsetLeft;
var eParElement = eElement.offsetParent;
while (eParElement != null) {
nLeftPos += eParElement.offsetLeft;
eParElement = eParElement.offsetParent;
}
return nLeftPos;
}
function DL_GetElementTop(eElement) {
var nTopPos = eElement.offsetTop;
var eParElement = eElement.offsetParent;
while (eParElement != null) {
nTopPos += eParElement.offsetTop;
eParElement = eParElement.offsetParent;
}
return nTopPos;
}
function initscroller(){
if (ns4) {
var thisspan=eval("document.roof.document.ticker")
textcontentheight=thisspan.clip.bottom-thisspan.clip.top;
document.roof.left=document.marker.pageX
document.roof.top=document.marker.pageY+1*textborder
document.tickerbg.left=document.marker.pageX+1*textborder
document.tickerbg.top=document.marker.pageY+1*textborder
document.roof.clip.width=textwidth;
document.roof.clip.height=textheight-2*textborder;
thisspan.top=textheight;
thisspan.clip.width=textwidth;
thisspan.clip.height=textcontentheight;
document.roof.visibility="show";
document.tickerbg.visibility="show";
thisspan.visibility="show";
}
if (ie) {
textcontentheight=document.all.ticker.clientHeight
document.all.roof.style.posLeft=DL_GetElementLeft(document.all.marker);
document.all.roof.style.posTop=DL_GetElementTop(document.all.marker);
document.all.ticker.style.posTop=textheight
document.all.ticker.style.clip='rect(0px, '+(textwidth-4)+'px, '+(textcontentheight)+'px, 0px)';
document.all.roof.style.visibility="visible";
document.all.ticker.style.visibility="visible";
}
if (ns6) {
textcontentheight=document.getElementById('ticker').offsetHeight
document.getElementById('roof').style.left=DL_GetElementLeft(document.getElementById('marker'));
document.getElementById('roof').style.top=DL_GetElementTop(document.getElementById('marker'));
document.getElementById('ticker').style.top=-textcontentheight
document.getElementById('ticker').clip='rect(0px, '+(textwidth-4)+'px, '+(textcontentheight)+'px, 0px)';
document.getElementById('roof').style.visibility="visible";
document.getElementById('ticker').style.visibility="visible";
}
doscroll()
}
function setscrollready(whatanswer) {
if (whatanswer==1) {
scrollready=true
checkscroll()
}
else {
scrollready=false
}
}
function checkscroll() {
clearTimeout(timer)
if (scrollready) {
doscroll()
}
}
function reopenpage() {
history.go(0)
}
window.onresize=reopenpage
window.onload=initscroller
</script>
</td>
[/php]