Jump to content
  • Advertisement
Sign in to follow this  

[web] Read from mysql

This topic is 4687 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.
$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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!