PDA

View Full Version : getting stuff from a database


djsource
Sun 20th May '01, 3:52pm
This isn't about VB but more about php in general :) (I’ve only been learning php for 24 hours so be gentle with me).

I’ve created a dummy page (nothing works) at http://www.djsource.co.uk/dummy.php and I’m trying to get the information in the DJ News section (middle bottom of screen) to be pulled out of a database.

So far I have created a database “djsource_news” that has a table called “news”. This table has the following columns…

id - unique number for each article
category – a way to group together related news/products (all the turntables or mixers for example)
img – a html link to the small image
intro – a short summary of what the article is about
content – the full article

So, I have just learnt how to connect to the database but what I can’t seem to find/learn is the correct php code to display only the info I want in the front page.

What I’m after then is this…

I would like to be able to display the latest X news stories (where X is a number I haven’t decided on yet, probably 4 or 5). The only information I need on the front page is the img, the intro, and then of course a link to the full article.

Can somebody help or point me in the right direction. Also it might help if you take a look at the dummy page to see what I’m on about. (http://www.djsource.co.uk/dummy.php)

Thanks, Paul.

Alarion
Sun 20th May '01, 5:42pm
I gather you are using mysql?
here is the PHP docs for the mysql functions:
http://www.php.net/manual/en/ref.mysql.php

as well, you might try my data-abstraction lib (DataLib) that you can download from http://www.databound-software.com

I think it is slightly more simple to use than PHP's database calls :)