dub_stylee Posted December 8, 2008 Share Posted December 8, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/ Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 <td bgcolor = '#FFFFFF'><a href = 'processalbum.php?album='.$album_name><font face = 'arial' size = '2'>$album_name</a></font></td> Accessed by $_GET['album']. Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709104 Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 <?php echo "<td bgcolor='#FFFFFF'><a href='processalbum.php?album_name=$album_name'><font face = 'arial' size = '2'>$album_name</a></font></td>"; ?> on the next page echo $_GET['album_name'] will show the album name Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709106 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 Correction... <td bgcolor = '#FFFFFF'><a href = 'processalbum.php?album='.$album_name><font face = 'arial' size = '2'>$album_name</font></a></td> You opened and closed the FONT and A tags in the wrong order... Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709107 Share on other sites More sharing options...
dub_stylee Posted December 8, 2008 Author Share Posted December 8, 2008 I got it to work finally and it was my fault about having </a></font> backwards in my original post. Woohoo! Now I think I am ready to begin populating my database. Thanks for your help everyone! Brian Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709113 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709114 Share on other sites More sharing options...
dub_stylee Posted December 8, 2008 Author Share Posted December 8, 2008 Yesideez, don't we have to use single quotes, since it is inside of an echo " "; ??? Brian Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709115 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709116 Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 Try it Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709119 Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 Cheers guys, got beaten to it!! Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709121 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709124 Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 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!! Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709132 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 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+ Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709139 Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 Notepad++ here, never tried edit+ Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709144 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 I've taken a look at that and nearly switched to it when I was making a website in Polish because Edit+ seemed to not want to encode the files properly - most of the Polish characters came out as something else! Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709146 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 Notepad++ is great for just coding. For projects I would highly recommend eclipse with the php plugin. It shows syntax errors etc without having to run the code. Great software. Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709150 Share on other sites More sharing options...
Yesideez Posted December 8, 2008 Share Posted December 8, 2008 When I was taking a look at Notepad++ the one thing that very nearly almost swayed me to buy it was the brace coloring for chunks of code like if() statements. Edit+ doesn't have it and it really looks handy! http://notepad-plus.sourceforge.net/commun/screenshots/scrsh_braceIndentGuideHiLiting.gif Quote Link to comment https://forums.phpfreaks.com/topic/136006-solved-question-about-making-a-table-cell-a-link-to-a-php-script/#findComment-709151 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.