If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Horizontal Scrolling Text From DB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-10, 21:26
tlshaheen tlshaheen is offline
Registered User
 
Join Date: Dec 2009
Posts: 20
Horizontal Scrolling Text From DB

Hi guys,
I've been searching around a bit and can't seem to find a script to display text from a database and scroll it across the page, like a news ticker. I'd like to it display horizontally across the page. I assume that it'll be a mixture of Javascript and PHP, and I've found some versions of it in my search, but nothing that seems to work very well. Any ideas?
I'm not stuck on PHP or JS, I just need SOMETHING to take the info from my DB and scroll it across the page like a news ticker.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 01-13-10, 12:08
dgreenhouse dgreenhouse is offline
Registered User
 
Join Date: Mar 2009
Posts: 11
You could use the old tried and still somewhat true: Marquee element. marquee
Note: The marquee element doesn't have complete support across all browsers and I'd normally say not to use it, but for most browsers, it's fully supported.
It also can be a bit jerky.
Flash or Silverlight look the best and of course you can use a JavaScript framework or handcrafted code to good effect.

// Simple use of marquee...
Code:
<html>
<body>
<?php
$dbc = mysql_connect('localhost','user','passwd');
$sql = "select fieldx from database.dbtable where clause = 'somevalue'";
$rs = mysql_query($sql);
?>
<marquee width="200" scrollamount="10" scrolldelay="150"><?php echo mysql_result($rs,0,'fieldx');?></marquee>
</body>
</html>
Reply With Quote
  #3 (permalink)  
Old 01-14-10, 21:52
tlshaheen tlshaheen is offline
Registered User
 
Join Date: Dec 2009
Posts: 20
Thank you for your response. For those interested, after some more searching, I came up with the following. It uses jScroller2 for the scrolling effect (that way, I don't have to worry about the compatability of <marquee> plus I get more styling effects (speed mostly)).
I've got the styling done in a css file. But this returns the list of Vendor names from the DB, and displays them in a random order (so each time someone visits the page, they don't see the same starting Vendors - there are currently over 240, so this way all vendors get displayed at some point).

If anyone's got any suggestions for cleaning up any of the code, please let me know! Thanks!

Code:
<div id="vendorTicker">
<?php
mysql_connect(//CONNECTION INFO) or die(mysql_error());
mysql_select_db(//DATABASE NAME) or die(mysql_error());

$countquery = "SELECT COUNT(Name) FROM Vendors";
$resultSet = mysql_query($countquery) or die(mysql_error());
$row =  mysql_fetch_array($resultSet);
$totalcount =  $row['COUNT(Name)'];

$query = "SELECT Name FROM Vendors ORDER BY RAND() LIMIT " .$totalcount;
$resultSet = mysql_query($query);
?>
<div class="jscroller2_left jscroller2_speed-100 jscroller2_mousemove">
<?php
while($row = mysql_fetch_array($resultSet)) {
?>
<div id="vendorDisplay">
<?php print($row['Name']) ?>[/PHP]
</div>
<?php
}
mysql_close();
?>
</div>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On