Forums Archive Index > Cool free scripts > v_Newsticker 1 php&Mysql
Date: 22 Jan 2005 9:47 am
Hi,
I downloaded the v_Newsticker and use the 1st
with the big box. Now i Wantet to put all my News
in a MySQL DB an display them over the newsticker
but i don't know hot to do it.
I did the following:
renamed the v_newsticker_1.js to v_newsticker_1.php
i include my output.php in the content part and in this
file i'm getting my info from the database.... than i load the script
over
<script language=javascript1.2>
<? include .......
</script>
to the place where i want it to be displayed...
if i look at the Source Code later all I want
is in there, put the ticker doesn't work :(
Anyone cann tell me exactly what i Have to do
to load my news from a DB ???
Date: 22 Jan 2005 10:54 am
Hi Thommy,
Please take a look at the following topic first- --> http://www.smartmenus.org/forum/viewtopic.php?t=10 and let me know if you have any questions after that.
Thanks!
Date: 22 Jan 2005 11:13 am
Hey, i saw this thread (na dthe others of course) before,
but if i Do it like this, the script stops working :(
I did everything like it's been written in this
topic, but it doesn't work.
You can llokk at the following: --> http://klasse8asb.kl.funpic.de/ticker/Kopie%20von%20v_newsticker_1.php
In Source Code everything seems to be ok for
me, but the script does not show up anything ....
my outputfile looks like this:
Code:
<?php
// Connect
include ("db.php");
// Read Data
$query = "SELECT * FROM 8a_hausi";
$result = mysql_query($query);
// Make it easy to select
while ($line = mysql_fetch_array($result)) {
?>
['#','<img src=images/icon_link_arrow_red.gif> <span class=news_header><?=$line[fach]?>:</span><br><?=$line[hausi]?>','_blank'],
<?
}
mysql_free_result($result);
// Disconnect
mysql_close();
?>
and i changed the script like this:
Code:
// === 2 === THE CONTENT - ['href','text','target']
// Use '' for href to have no link item
v_content=[ <?php include("tick_con.php"); ?>
];
nothing shows up :(
Date: 22 Jan 2005 5:47 pm
The problem is that the loop you've used outputs a comma symbol after the last item. So just change the following:Code:
while ($line = mysql_fetch_array($result)) {
?>
['#','<img src=images/icon_link_arrow_red.gif> <span class=news_header><?=$line[fach]?>:</span><br><?=$line[hausi]?>','_blank'],
<?
}
with: (for instance)Code:
$ticker_output="";
while ($line = mysql_fetch_array($result))
$ticker_output.="['#','<img src=images/icon_link_arrow_red.gif> <span class=news_header>".$line[fach].":</span><br>".$line[hausi]."','_blank'],";
$ticker_output=substr($ticker_output,0,-1); // removes the last comma
echo $ticker_output;
Date: 23 Jan 2005 5:30 am
Yeah ...... it works ... :) :)
Thank you very very much! This is
the best Newsticker i've ever
seen on the www ... ;)