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 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']. 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 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... 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 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. 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 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. 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 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!! 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... 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!! 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+ 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+ 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! 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. 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 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
Archived
This topic is now archived and is closed to further replies.