News défilantes avec base mysql (pour gestion des news) et page d'admin pour supprimer ou ajouter une news sans passer par le gestionnaire mysql
Source / Exemple :
fichier news.php, le reste se trouve dans le .zip
<script type="text/javascript">
function Defilant(id, pos_init, pos_min, pos_max, delta, direction) {
this.id = id;
this.element = document.getElementById(id);
this.pos_init = pos_init;
this.pos_min = pos_min;
this.pos_max = pos_max;
this.pos_current = pos_init;
this.delta = delta;
this.direction = direction;
}
Defilant.prototype.defile = function() {
if (!this.element) {
this.element = document.getElementById(this.id);
}
if (this.element) {
if(this.direction == "vertical"){
if(this.pos_current < (this.pos_min - this.element.offsetHeight) ){
this.pos_current = this.pos_init;
} else if (this.pos_current > this.pos_max ) {
this.pos_current = this.pos_init - this.element.offsetHeight;
} else {
this.pos_current += this.delta;
}
this.element.style.top = this.pos_current+"px";
} else if(this.direction == 'horizontal') {
if(this.pos_current < (this.pos_min - this.element.offsetWidth) ){
this.pos_current = this.pos_init;
} else if (this.pos_current > this.pos_max ) {
this.pos_current = this.pos_init - this.element.offsetWidth;
} else {
this.pos_current += this.delta;
}
this.element.style.left = this.pos_current+"px";
}
}
}
</script>
<?php
echo '<div align="justify" style="position:relative; overflow:hidden; width:170px; height:120px;">
<span id="defileH1"
style="position:absolute; width:170px; height:120px; background-color:#FF0000;"
onMouseover="defileH_1.delta=0"
onMouseout="defileH_1.delta=deltaH1">';
include('connec.php');
$req1_exe = mysql_query( 'select * from news_abs order by id desc' );
for ($i=0;($tab1=mysql_fetch_array($req1_exe)) && ($i!=5); $i++)
{
echo '<font style="color:#FFFFFF; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif;"><b>'.stripslashes($tab1[1]).'</b></font><br>
<font style="color:#FFFFFF; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.stripslashes($tab1[2]).'</font><br><br>';
}
echo '</span></div>';
?>
<script type="text/javascript">
var deltaH1 = -1;
var defileH_1 = new Defilant("defileH1", 130, 0, 130, deltaH1,"vertical");
setInterval("defileH_1.defile()",40);
</script>
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.