Jump to content
xisto Community
Sign in to follow this  
candicej

Help Importing Mysql Database Results Need help formatting link

Recommended Posts

I am having trouble formatting my table to display the results of a mySQL query the way I want.

Here is the part of my code:

$result = mysql_query("SELECT * FROM uploads WHERE Category='Drama'")or die(mysql_error()); ?><table cellspacing="2" cellpadding="2"><tr> <th>Title</th> <th>Author</th> <th>File</th></tr><?php// keeps getting the next row until there are no more to getwhile($row = mysql_fetch_array( $result )) {//<!--Print out the contents of each row into a table-->echo "<tr><td>"; echo $row['Title'];echo "</td><td>";echo $row['Author'];echo "</td></tr>";echo $row['File'];echo "</td></tr>";}echo "</table>";

I want to make 'Title' show as a hyperlink to 'File' but am at a loss as to how to do this. I have tried all I know so any help is appreciated. I am very new to php and mySQL.

Thanks in advance,
C

Share this post


Link to post
Share on other sites

The following should help.. though I have not tested it.. as I dont have php configured on my system...


echo "<tr><td><a href=\""; echo $row['File'];echo "\">"echo $row['Title'];echo "</a>"echo "</td><td>";echo $row['Author'];echo "</td></tr>";

Cheers.

Share this post


Link to post
Share on other sites

You have an extra </tr> and are missing a <td>. The corrected code should be:

result = mysql_query("SELECT * FROM uploads WHERE Category='Drama'")or die(mysql_error()); ?><table cellspacing="2" cellpadding="2"><tr> <th>Title</th> <th>Author</th> <th>File</th></tr><?php// keeps getting the next row until there are no more to getwhile($row = mysql_fetch_array( $result )) {//<!--Print out the contents of each row into a table-->echo "<tr><td>";echo $row['Title'];echo "</td><td>";echo $row['Author'];echo "</td><td>";echo $row['File'];echo "</td></tr>";}echo "</table>";

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.