Forum Moderators: coopster

Message Too Old, No Replies

Pulling specific content from database

A lil help?

         

wonderboy

8:07 pm on May 1, 2004 (gmt 0)

10+ Year Member



Hello,

I have a table in my MySQL database called "images", within this are the fields

id, name, pic, categ, ss, desc.

I have a page called content.php, when you call:

content.php?categ=people&display=1

I want the page to display the first 5 lines of the database, specifically: ss, desc and name, with ss and name both linking to: show.php?id=$id

So far I have managed to displayevery row of ss, desc and name with no formatting or linking. I have 5 tables created in dreamweaver with things like:

<img src="<? echo $ss?>" width="100" height="68">

This works for the first picture, but not for the remaining 4, will I have to put the table code into the loop echo?

Hope you understand my problem, just need to know the most efficient way of dealing with it,

Thanks,

W.

venelin13

4:08 pm on May 2, 2004 (gmt 0)

10+ Year Member




CREATE TABLE content (
id int(10) not null primary key auto_increment,
name varchar(255) not null,
pic varchar(255) not null,
categ int(10) not null,
ss varchar(50) not null,
desc text);

Now we should build the database query:


$query = "select * from content limit 0,5";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<tr>\n\t<td><a href=\"show.php?id=$row[id]\">$row[name]</a></td>\n</tr>\n";
}