Jump to content

[SOLVED] question about making a table cell a link to a php script


dub_stylee

Recommended Posts

Hello all, I have been trying to make a cell in an HTML table into a link.  Basically, I want to make it so that if I click on an album title, it will run a PHP script called processalbum.php with the album title as input.  I know I will have to use the GET method for this, but I'm not sure how to accomplish such a thing without a FORM.  But I don't need any input from the user, so I don't think I should need a FORM.  Here is the link (which doesn't quite work):

 

<td bgcolor = '#FFFFFF'><a href = 'processalbum.php?'.$album_name><font face = 'arial' size = '2'>$album_name</a></font></td>

Any ideas??  Thanks!

 

Brian

Link to comment
Share on other sites

You're welcome!

 

gevans - I believe your code is wrong because you're using single quotes - that would parse the $album_name as it is without adding the variable content into the equation.

 

He is using single quotes for the href etc, the main echo uses double quotes. It will parse it correctly.

Link to comment
Share on other sites

Didn't notice that - my bad - half 3 in the morning here :(

 

I would have written this though...

<?php
echo '<td style="background-color: #FFFFFF"><a href="processalbum.php?album_name='.$album_name.'"><span style="font: 14px arial">'.$album_name.'</span></a></td>';
?>

Maybe a little overkill but I'm off to bed shortly...

Link to comment
Share on other sites

If it was my code I would've done this;

 

<?php
echo "<td style=\"background-color: #FFFFFF\"><a href=\"processalbum.php?album_name=$album_name\"><span style=\"font: 14px arial\">$album_name</span></a></td>";
?>

 

But, each to their own!!

 

Yea, 3:30 tell me about it!! :)

Link to comment
Share on other sites

I've always wondered why escape the slashes hiding the variables?

 

Can make debugging slightly more tricky when you're scrolling through lines of code and the variables are hidden. Don't know about you but my text editor colors everything differently so the variables stand out - I use Edit+

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.