Hi everyone,
I am looking for some assistance to accomplish the following task. I want to be able to have a list of poems on my website with a link to that specific poems page (I have managed to accomplish listing and link).
I also want to be able to have it so that when someone clicks on a poem, the poem shows up in “normal” poem formatting with stanzas and such. As of now, I have no idea how to get my poems to format properly. Right now my poems come out looking like this:
“Bells Rang
As you pull out of the driveway and you look to your right Your buddy has a wet face and the most intense look of fright Finished cranking the wheel and aiming the rig straight You lift your head and feel for a better view down the street in the day light The sights can only paralyze your thoughts as you were not trained for this No one is ever trained for loss and you can’t help but seeing it Your buddies aren’t saying anything and this has to be the most empty feeling As you drive in the wrong direction…”
Obviously this is unformatted and what I would like is for it to look like this:
Bells Rang
“As you pull out of the driveway and you look to your right
Your buddy has a wet face and the most intense look of fright
Finished cranking the wheel and aiming the rig straight
You lift your head and feel for a better view down the street in the day light
The sights can only paralyze your thoughts as you were not trained for this
No one is ever trained for loss and you can’t help but seeing it
Your buddies aren’t saying anything and this has to be the most empty feeling
As you drive in the wrong direction…”
So far, I have this coding established. The first script is to list my poems and the second script is supposed to do the listing of each poem and so on as I would like it to actually look. I have been tinkering based on internet searches and books I own. I realize the second script is completely off base, but I wanted to show what I have thrown together.
In advance, I greatly appreciate any of your time you can lend a stranger.
Thanks,
Randy
In case this is needed:
the table structure of my MySQL database:
id,
letter,
title,
poem
Script one: Poemindex.php
[CODE]
<?php
//LIST POEMS WITH LINKS
// database connection
// variable setting
$db_hostname = “localhost”; //Host
$db_username = “”; //Username
$db_pass = “”; //Password
$db_name = “”; //Database Name
/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
————————————–*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die (‘I am unable to connect to the database because of: ‘ . mysql_error());
mysql_select_db ($db_name);
// select data from the database to use
$result = mysql_query(“SELECT * FROM poems ORDER BY title LIMIT 100”) or die(‘mysql_error()’ . ‘Error: ‘ . mysql_error() );
while($row = mysql_fetch_array($result))
{
echo “<a href=”poemview.php?title=”.$row[‘title’].”” target=”_blank”>”.$row[‘title’].”</a><br/>n”;
}
?>
[CODE]
<?php//This page retrieves the name of the contact via $_GET() method. The value of $_GET is then processed by the query:
$db_hostname = “localhost”; //Host
$db_username = “@@@@”; //Username
$db_pass = “@@@@”; //Password
$db_name = “@@@@”; //Database Name
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die (‘I am unable to connect to the database because of: ‘ . mysql_error());
mysql_select_db ($db_name);
$result=mysql_query(“SELECT * FROM poems WHERE title = ‘”.$_GET[“title”].”‘”) or die(“Could not connect to database!”);
while($row=mysql_fetch_row($result))
{
//echo $row[1].”<br/>n”;
echo $row[2].”<br/>n”;
echo $row[3].”<br/>n”;
echo $row[4].”<br/>n”;
echo $row[5].”<br/>n”;
echo $row[6].”<br/>n”;
//Poem Title: echo $row[3]; <br /><br />
//Poem: echo $row[4];
// Write the data of the poem
//echo “<dt>Title:</dt><dd>” . $row[“title”] .”</dd>”;
//echo “<dt>Poem:</dt><dd>” . $row[“Poem”] . “</dd>”;
}
?>
[/CODE]