Plamph Posted January 25, 2012 Share Posted January 25, 2012 Hi, I am new to the boards and php and mysql. I have created a database and can add entries via a form. I can query the database with another form and get the results to display in a table. All good so far as that is what I was hoping to achieve but one of the fields I want to display as a hyperlink but I am having problems with the syntax as I keep getting errors when I try to wrap the variables in <a href > tag. <tr> <td><?php echo $fquery['prefix']; echo $fquery['website']; ?><?php echo $fquery['website']; ?></td> </tr> now that displays e.g. http://www.example.comwww.example.com. so I feel I am nearly there I just need advice as to how to construct a hyperlink from the fields queried. Quote Link to comment https://forums.phpfreaks.com/topic/255787-getting-a-query-field-to-display-as-a-hyperlink/ Share on other sites More sharing options...
wigpip Posted January 25, 2012 Share Posted January 25, 2012 Hi like normal HTML but when you need to break into the php variable to break the html with apostrophe + comma then after the variable back into the HTML with comma + apostrophe echo'<a href="',$fquery['website'],'">',$fquery['website'],'<a/>'; Quote Link to comment https://forums.phpfreaks.com/topic/255787-getting-a-query-field-to-display-as-a-hyperlink/#findComment-1311217 Share on other sites More sharing options...
scootstah Posted January 25, 2012 Share Posted January 25, 2012 Hi like normal HTML but when you need to break into the php variable to break the html with apostrophe + comma then after the variable back into the HTML with comma + apostrophe echo'<a href="',$fquery['website'],'">',$fquery['website'],'<a/>'; Except you use periods not commas. Quote Link to comment https://forums.phpfreaks.com/topic/255787-getting-a-query-field-to-display-as-a-hyperlink/#findComment-1311226 Share on other sites More sharing options...
AyKay47 Posted January 25, 2012 Share Posted January 25, 2012 Hi like normal HTML but when you need to break into the php variable to break the html with apostrophe + comma then after the variable back into the HTML with comma + apostrophe echo'<a href="',$fquery['website'],'">',$fquery['website'],'<a/>'; Except you use periods not commas. commas are fine. Quote Link to comment https://forums.phpfreaks.com/topic/255787-getting-a-query-field-to-display-as-a-hyperlink/#findComment-1311232 Share on other sites More sharing options...
Plamph Posted January 25, 2012 Author Share Posted January 25, 2012 cheers wigpig, been at this for hours I did have similar code to yours and checking over it I was missing a , . deleted and entered again from scratch making sure I was paying attention to my ,'and; . Life save. Quote Link to comment https://forums.phpfreaks.com/topic/255787-getting-a-query-field-to-display-as-a-hyperlink/#findComment-1311240 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.