| John Burroughs 2005-03-21, 3:55 am |
| Hi everyone,
I've created a database for my poetry that I've written. I have a table
called Titles. It is made up of:
title_id (a different number for every poem title. It's the primary key.)
title (the title of the poem)
title_date (the date I wrote the poem. stored in Date format.)
I want to generate an html page that lists all of the poems that I've
written in descending order by date. I want each title to be in an href
link so my visitors can just click on a link, which will automatically
generate a page to display that poem.
So for example, each finished line would look like . . .
<p><a href="poem.php?titleid=1">Poem Title 1</a> - 1/25/05</p>
<p><a href="poem.php?titleid=2">Poem Title 2</a> - 1/20/05</p>
<p><a href="poem.php?titleid=3">Poem Title 3</a> - 1/15/05</p>
This is my code fragment. This works for printing the Titles and dates
in descending order, but that was as far as I could get.
//Select the poetry database
if (!@mysql_select_db("bdweb320883_poetry")) {
echo("<p>Unable to locate the poetry " . "database at this
time.</p>");
exit();
}
//Result the titles of all of the poems that I've written
$result = @mysql_query("Select title, title_date from titles order by
title_date DESC");
if(!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
//Display the title of each poem
while ($row = mysql_fetch_array($result)) {
$poetrytitle = $row['title'];
$poetrydate = $row['title_date'];
echo("<p>" . $poetrytitle . " - " . $poetrydate .
"</p>");
}
How can I do this. Everytime I tried adding to the above code, I kept
getting error messages in php saying that there was an unexpected
'>'character on line such and such, but I don't know how I could even
check to see which line had the error? (I'm using myphpadmin to manage
my MySQL database.)
Now my connection to my MySQL server for my online hosting company has
been done for 12 hours and I haven't been able to work on it anymore.
Does anyone know an easy way to do this?
Thanks,
John Burroughs
--
John Burroughs
http://johnaburroughs.com
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0511-1, 03/17/2005
Tested on: 3/20/2005 9:28:43 PM
avast! - copyright (c) 1988-2004 ALWIL Software.
http://www.avast.com
|