Forums Archive Index > Cool free scripts > V-NewsTicker with php?

Author: 7724

Date: 11 Jul 2005 11:56 am

Hi Guys,

I'm using the V-NewsTicker and want to know where I add my headlines to get the script to run if I can make the script look in a table in mysql database instead called 'frontpage' and pull out the contents from $headlineone, $headlinetwo and $headlinethree for frontpageid=1, rather than just updaing the .js file headlines each time?

Could someone please post an example of how this is done as i'm confused?

Thanks

7724


Code:

<?php

// login stuff

include("********.php");

   $result = mysql_query("SELECT * FROM frontpage WHERE frontpageid='1'");
   $row = mysql_fetch_array($result, MYSQL_BOTH);
   $headlineone = $row['headlineone'];
   $headlinetwo = $row['headlinetwo'];
   $headlinethree = $row['headlinethree'];
?>


Author: smartmenus

Date: 11 Jul 2005 6:15 pm

Please take a look at the following topic for an example how you could pull the headlines from MySQL:

--> http://www.smartmenus.org/forum/viewtopic.php?t=219


Author: 7724

Date: 12 Jul 2005 5:22 am

Hi,

Thanks for that - i've tried looking around the forums, and trying what is suggested, but i'm still stuck.

Here's how I understand it:

1) change the v_newsticker from a .js extension to a .php extention.

2) go into the newsticker and edit:

Code:

// === 2 === THE CONTENT - ['href','text','target']
// Use '' for href to have no link item
v_content=[
['http://www.smartmenus.org/other.php','<img src=strelka.gif align=top width=20 height=11 border=0>Welcome to the V-NewsTicker example page! Presenting the best FREE vertical news scroller ever written.','_blank'],
['','<img src=strelka.gif align=top width=20 height=11 border=0>Featuring: support for the most popular browsers, easy setup, small size, pausing, sliding up or down...','_blank'],
['http://www.smartmenus.org/','<img src=strelka.gif align=top width=20 height=11 border=0>Don\'t wait and also get the most advanced navigation system for your site- the SmartMenus DHTML menu.','_blank']
];


to make the file look for a php page uploaded to your site, where it will include that text on that page and use it in the scroller.

So I modified the code to simply show:

Code:


// === 2 === THE CONTENT - ['href','text','target']
// Use '' for href to have no link item
v_content=[<?php include ("marquee.php"); ?>];



Now the above points to --> http://www.mysite.com/marquee.php to get a headline which gets it's text from a variable in a 'table' in a mysql database, so I think it *should* pull out that text from the database and put on the marquee.php page and also put it into the newsticker?

3) So the last thing I need to do I think is either call in the v_newsticker to my frontpage, so do I either still call the newsticker in like this?:

Code:

<script language=JavaScript1.2 src=v_newsticker_1.php></script>


or

or as a php file?:

Code:

<?php include("v_newsticker_1.php"); ?>


Can anyone help?

Thanks

Chris


Author: smartmenus

Date: 12 Jul 2005 3:42 pm

Yep, that's it. You have to call the script like this:

<script language=JavaScript1.2 src=v_newsticker_1.php></script>


Author: 7724

Date: 13 Jul 2005 4:55 am

Hi,

Sorry, but still got that problem. If you take a look at:

--> http://www.slougheaz.org/ticker_test.php

That's my page that calls in the php file - it's set up as follows:

Code:

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<script language=JavaScript1.2 src=v_newsticker_1.php></script>
</body>
</html>


Which should call in this file, but it throws up a scrip error on line 50 - saying expected ']'.

Now I have my v_newsticker_1.php set up to call in marquee.php

Code:
// === 2 === THE CONTENT - ['href','text','target']
// Use '' for href to have no link item
v_content=[<?php include("marquee.php");?>];


and if you take a look in my actual v_newsticker_1.php file, which can be found at:

--> http://www.slougheaz.org/v_newsticker_1.php

and look in the source code You will see it calls in the headline from --> http://www.slougheaz.org/marquee.php saying 'The Biggest Variety Of Hits - Your Radio FM'

So why is it throwing up that error please in my ticker_test.php?

Thanks

7724


Author: smartmenus

Date: 14 Jul 2005 6:46 am

I just took a look at:

--> http://www.slougheaz.org/ticker_test.php

and I saw that the JS code it outputs is broken. Also the v_content array looks like this:

v_content=[ ];

which means that --> http://www.slougheaz.org/marquee.php doesn't output anything at all except one space symbol. And indeed when you open that file in a browser you can see that it doesn't output anything.

So there is obviously something wrong with those files. :?


Author: 7724

Date: 18 Jul 2005 3:50 am

Hi smartmenus,

Thanks for that. But I'm still having the same problem after fixing the above. If you take a look at:

--> http://www.slougheaz.org/marquee.php

It now outputs the message 'Here is the Marquee text' - so why is that creating a Javascipt error in the page I ask it to call in on --> http://www.slougheaz.org/ticker_test.php ??????

If you look at:

--> http://www.slougheaz.org/v_newsticker_1.php

and view the source it is calling in the text? so why not work?

Thanks

Chris


Author: smartmenus

Date: 18 Jul 2005 5:40 pm

I just checked again and the output from the --> http://www.slougheaz.org/marquee.php file is still the same as before- just one space symbol. :?


Author: 7724

Date: 19 Jul 2005 4:30 am

Thanks - if you check now it will be there! It keeps on disappearing overnight...

If you could take a look that would be grand.

Ta

Chris


Author: smartmenus

Date: 19 Jul 2005 7:38 am

Well, the problem is that your --> http://www.slougheaz.org/marquee.php file outputs only the following string:

Why does this text keep on disappearing??

And an example valid syntax it should output look like this:

['some_link1','some_text1','_self'],['some_link2','some_text2','_self'],['some_link3','some_text3','_self']

This means that in your case your output should looks like this to work (for instance):

['some_link','Why does this text keep on disappearing?? ','_self'],['some_link2','some_text2','_self']

and not just:

Why does this text keep on disappearing??

I hope you will understand it now.


Author: 7724

Date: 20 Jul 2005 6:09 am

THANK YOU!!!!

Yep got it working now.

Just one last question. My newsticker calls in this code;


['http://www.mysite.com','<?php echo $headtwo; ?>','_self']

how do I get it to display an image with the text it gets from the $headtwo variable?

I tried

['http://www.mysite.com','<img src="images/radio_fm.jpg" width="85" height="15"> <br><br>'<?php echo $headtwo; ?>','_self']

but it does not work - any ideas thanks?


Author: smartmenus

Date: 20 Jul 2005 10:18 am

['http://www.mysite.com','<img src="images/radio_fm.jpg" width="85" height="15"> <br><br>'<?php echo $headtwo; ?>','_self']

The bold red quote (after the two <br> tags) should be removed.