Jump to content

Recommended Posts

I am not sure if this is the correct forum to post this on.  If not, I apologize.  I am still pretty new to PHP.  I am editing a website for a friend.  He had a news headlines section on his home page, but wants to change it to a news bar that scrolls through the most recent news on their database.  I have been searching for help online for this and have felt like I was close, but never quite found what I needed (especially since I am new to this). 

 

I found this tutorial (http://www.dynamicdrive.com/dynamicindex2/crosstick.htm), which is what I want... except that I don't want to use an Array for the headlines, but I want it to pull from my database.  Is there an easy way for me to do this?  I already have a php file from the previous news headlines section, but am not sure how to get that to work with this new code.

 

Here is the code for the previous headlines...

<div id="news"> 

<?php

getHeadlines();
/*
include("admin/nCMS/nSQL.php");
$db = new nSQL("local");
$q = "SELECT nDate, nTitle FROM `gtt_news` ORDER BY nDate DESC LIMIT 5;"
$r = $db->select($q);

while($data = $db->get_row()) {
echo "<div class=\"newsitem\">";
    echo "<p class=\"text\"><a href=\"#\">.$data['nTitle'].</a></p>";
echo "</div>"; 
}
*/
?>
</div>

 

Please let me know if any other code is needed.

 

Thanks so much for your help.

Link to comment
https://forums.phpfreaks.com/topic/178700-scrolling-news-bar-and-mysql/
Share on other sites

Hi

 

If you want a scrolling news bar then you need to have the news items listed. Probably in an array in Javascript. You can use similar code to the stuff you posted to populate the array. However this will just provide a single list on the page.

 

If you want the list to change then you need to refresh it. For this you need to use Ajax to call a php script and return data to update the array.

 

Sorry, doesn't really answer your question, but I think we need more details to help you. The SQL is the easy bit.

 

All the best

 

Keith

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.