Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Scrolling News Panel

Posted on 2005-04-19
5
Medium Priority
?
411 Views
Last Modified: 2008-03-04
Hi:

I'm looking to create a news panel that will scroll news items that are entered into it. I want the news to stop when you put your mouse over it, but continue when the mouse is off the box.

The second part, I want people to be able to log in and update or remove the news items in the news panel. I wanted to use PHP and MySQL for this.

I believe most of the javascript code is done here:
http://www.devarticles.com/c/a/JavaScript/Creating-a-Scrolling-News-Panel/1/

However, I could't get it running. I think the main problem is just setting something up with PHP to display the news.

Can anyone help me to get this going?

Thanks!
0
Comment
Question by:gregca80
  • 3
5 Comments
 
LVL 7

Expert Comment

by:Promethyl
ID: 13817214
Define "Couldn't get it running".

Did it scroll? Start here.

Did it not scroll: Start in Javascript help.

Generically speaking, it should be a matter of pulling data from the database and properly escaping it in JS.
\1ds
0
 
LVL 7

Expert Comment

by:Promethyl
ID: 13817254
$c= mysql_connect('locahost','you','yourpassword');
mysql_select_db('yourdb',$c);

$news = mysql_query("select * from news order by id desc",$c);

if ($news=mysql_fetch_assoc($news)) {
echo "<div id=\"news\">
<h1>$news[head]</h1>

$news[body]
</div>
";
} else { echo mysql_error(); }

// OK, so this is really sloppy code, and squinky is going to roe-sham-bo me for it. But this illustrates the point. I'm standing in front of a server rack, and my feet hurt.



0
 
LVL 3

Expert Comment

by:designbai
ID: 13823062
start here.

$con = mysql_connect("localhost","username","password");
mysql_select_db("yourdb",$con);

$sql = "SELECT newsTitle from News";
$result = mysql_query($sql);

   while ($row = mysql_fetch_array($result)) {
    $newsitem .=$row['newsTitle']."<br>";      
   }

Html tag to scroll

<marquee onmouseover="this.stop()" onmouseout="this.start()" scrollAmount="4" scrollDelay="150" direction="up" height="100"><?=$newsitem?></marquee>

Hope this helps.
0
 

Author Comment

by:gregca80
ID: 13880004
I ended up doing this:

<?
             $db= mysql_connect('localhost','un','pw');                    
             
                 mysql_select_db("web",$db);
             
             $result = mysql_query("select msg_text from message",$db);
             
             while ($myrow = mysql_fetch_array($result)){
             
             printf($myrow[0]);
             }
?>

Is there any reason that this code wouldn't be good?

I only have one row, so I just printed the array position of 0.

Seems to be doing a fine job for me.

Thanks.
0
 
LVL 7

Accepted Solution

by:
Promethyl earned 450 total points
ID: 13882149
Well, if you want to be that way about it, do it this way:

<?       $db= mysql_connect('localhost','un','pw');                  
          mysql_select_db("web",$db);
          echo mysql_result(mysql_query("select msg_text from message",$db),0);
?>


0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month20 days, 18 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question