Jump to content

How to make news bar?


Recommended Posts


If you just want to add the news to your html source files your can use this:

<marquee>This is news item 1 ** This is news item 2 ** This is news item3</marquee>

If you want to show news from items in a database you first have to connect to the database and fetch the items from the database. Using PHP and MySQL it would be something like this:

mysqlconnection.php:

<?php
function MySQL_connection()
{
$host = "hostname";
$user = "username";
$pass = "password";

$connection = mysql_connect($host, $user, $pass);
mysql_select_db ("databasename", $connection);
}
?>

newsbar.php

<?php
include("mysqlconnection.php");
MySQL_connection();
$qsqlnews = mysql_query("SELECT * FROM news");

While($row = @mysql_fetch_array($qsqlnews))
{
$title = $row["title"];
$message = $row["message"];
$date = $row["date"];
}

echo "<marquee><b>($date) $title</b> - $message ";
?>

Edit:

Ofcourse you have to edit $host, $user, $pass and databasename according to your situation

Edited by Darude1234
Link to comment
Share on other sites

Why did you open a new topic? What was wrong with my solution?

If you want to show news from items in a database you first have to connect to the database and fetch the items from the database. Using PHP and MySQL it would be something like this:

mysqlconnection.php:

<?php
function MySQL_connection()
{
$host = "hostname";
$user = "username";
$pass = "password";

$connection = mysql_connect($host, $user, $pass);
mysql_select_db ("databasename", $connection);
}
?>

newsbar.php

<?php
include("mysqlconnection.php");
MySQL_connection();
$qsqlnews = mysql_query("SELECT * FROM news");

While($row = @mysql_fetch_array($qsqlnews))
{
$title = $row["title"];
$message = $row["message"];
$date = $row["date"];
}

echo "<marquee><b>($date) $title</b> - $message ";
?>

Ofcourse you have to edit $host, $user, $pass and databasename according to your situation

Edited by Darude1234
Link to comment
Share on other sites

i don't wanna to make this new bar my self using marquee

That is all

Remove the marquee quotes <marquee> and </marquee> :rolleyes:

Try to tell exactly what you want.

I think there are 3 options and I showed you these options:

Option 1. Put the news directly in the source code

Option 2. Getting the news from a database and show it to the user

Option 3. Put news lines, line by line in a text file and read every line in the text file using a script.

But the last option is almost the same as option 1.

Link to comment
Share on other sites

So you're basically asking for a new bars that gets news from RSS news feeds? Just trying to help clarify what you want - I have no experience in dealing with RSS.

Edited by Chozo4
Link to comment
Share on other sites

@Chozo4,

1st thanks for ur reoly

i don't wanna RSS news

i wanna a news bar which show the last news and update its contain automatically without modify its marquee every new news

Well, in that case, what's wrong with my solution in post #7?

I still don't know what you want. If you want to change the contents automatically, try to understand that you need a source to get the news from like a database or text file, can't find another solution right now

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...