Jump to content

Displaying a record from a table as a link in PHP


nclocl

Recommended Posts

I have the following code:

 

$result = mysql_query("SELECT * FROM ESSAY_QUESTIONS WHERE SUBJECT = 'ENGLISH'")
or die(mysql_error());

while($essay_data=mysql_fetch_array($result)){

$question = $essay_data['QUESTION'];
$id = $essay_data['ID'];

echo "<a href=\"englishessays.php?id=$id>";
echo "$question </a>";
echo "<br><br>";
}

 

It seems to be almost working but it just displays one link and the address is all the rest of the code including </a>"; echo "<br><br>"; and other questions.

 

I presume there's an error with how I've written the echo statements so can anyone see it?  Or can anyone suggest a better way to do this?

 

On the next page, the php will read the ID from the address and display the information form that record.

Link to comment
Share on other sites

Thank you :D

 

I will probably have a few more insanely stupid php questions over this weekend.  I usually work with oracle and java and decided I could do this for a friend and learn php on the way.  I am messing up way more than I anticipated!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.