Sign in to follow this  

[web] Read from mysql

This topic is 4381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

now this is the code for displaying a piece of news
<h2>November 22nd</h2>
<h3><?php echo( $row ); ?></h3>
<p>this is just a bunch text for displaying purpose</p>

Now I need the date to been in between the <h2, and the title in between <h3 and the summary in between <p becuase I am using a .css file to display the news in a certian way. Now this is how I am connecting to me db and is is working fine.
<?php
$database = "kaizendigital";
$dbloginname = "root";
$dbpassword = "";
$host = "localhost";

$link = mysql_connect( $host, $dbloginname, $dbpassword ) or die( 'could not connect' . mysql_error() . '.') ;
$selecteddb = mysql_select_db( $database ) or die( 'could not connect to ' . $database . ' please check to make sure it exists.' );
							
$query = 'SELECT * FROM `news`';
$result = mysql_query( $query ) or die('could not perform ' . $query . ' query.' );
?>

I need there are a few thing I need some help on. First how can I extract certain data for the db into a php variable like how cna i make $title = title in the mysql db The second thing I need help on is how only run the process for only to 30 newest news. I was thinging of doing something like:
for( $i = 0; $i < 30; $i++ )
{
	//php code to print out news
}

but I dont know how to prin the newest news becuase I was thinking of id but the id goes forward. The third thing i need help on is how do I know which news item is the newest and how do i select that. Any help would be great, thanks.

Share this post


Link to post
Share on other sites

This topic is 4381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this