webguync Posted October 15, 2012 Share Posted October 15, 2012 I am trying to make a few HTML fields into hyperlinks that are pulling data from MySQL into PHP. My syntax is currently off, so I need some assistance. I have tried this. <td><a href="mailto:<?php echo $record['email_t'];?></a></td> <td><a href="<?php echo $record['url_t'];?></a></td> I am basically just trying to make the email a mailto link and the url field a hyperlink. Any help is greatly appreciated! Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 15, 2012 Share Posted October 15, 2012 Moving this to HTML. You need to have text within the two < a > tags, for the visitor to click on. <a href="http://google.com">This is a link to google.</a> Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 15, 2012 Share Posted October 15, 2012 (edited) <td><a href="mailto:<?php echo $record['email_t'];?></a></td> <td><a href="<?php echo $record['url_t'];?></a></td> Look at the HTML source that is being produced and the problems would be clearly evident. The output would look something like this: <td><a href="mailto:value_of_email_t</a></td> <td><a href="value_of_url_t</a></td> You are opening the href parameter using a quote mark and then adding the dynamic value. But, you never 1) close the href parameter with a quote, 2) close the opening A tag or 3) provide a value to be between the opening/closing A tags (i.e. text to be the actual hyper-link. If you want the same value to be the href location AND the displayed hyperlink, this should work (assuming the values are valid for this purpose) <td><a href="mailto:<?php echo $record['email_t'];?>"><?php echo $record['email_t'];?></a></td> <td><a href="<?php echo $record['url_t'];?>"><?php echo $record['url_t'];?></a></td> Or my preference echo "<td><a href='mailto:{$record['email_t']}'>{$record['email_t']}</a></td>\n"; echo "<td><a href='{$record['url_t']}'>{$record['url_t']}</a></td>\n"; Edited October 15, 2012 by Psycho Quote Link to comment Share on other sites More sharing options...
webguync Posted October 17, 2012 Author Share Posted October 17, 2012 This is probably easy, but I am a little rusty. How would I turn these rows of data into clickable links. Not sure how where to add the <a href="linkURL"></a> part. <td><?php echo $record['email_t'];?></td> <td><?php echo $record['url_t'];?></td> Thanks in advance! Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 17, 2012 Share Posted October 17, 2012 if URL_T is the URL field: <td><a href="<?php echo $record['url_t'];?>">click here</a></td> Quote Link to comment Share on other sites More sharing options...
webguync Posted October 17, 2012 Author Share Posted October 17, 2012 Thanks.What I would prefer, though is whatever is in the url_t field to automatically be the link text. So instead of 'click here' it would be www.mywebsite.com or whatever information is in the MySQL field. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 17, 2012 Share Posted October 17, 2012 Are you seriously confused about how to do that? What are you stuck on? And how is this different from the last time you asked and were given the answer? http://forums.phpfreaks.com/topic/269484-turning-field-display-into-hyperlinks/ I seriously don't understand how you can do MySQL queries, write enough PHP to process the data from those queries (which you've done in other posts), yet you are confused about how to echo text and make a hyperlink, when you've already been given the answer? Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 17, 2012 Share Posted October 17, 2012 (edited) <td><a href="-filename-"><?php ehco $record["url_t"]; ?></a></td> Edited October 17, 2012 by White_Lily Quote Link to comment Share on other sites More sharing options...
webguync Posted October 17, 2012 Author Share Posted October 17, 2012 ok, works now. Thanks. Quote Link to comment Share on other sites More sharing options...
webguync Posted October 17, 2012 Author Share Posted October 17, 2012 sorry, didn't see the answers to my other post. For some reason, I didn't get an email alerting of a response. Sorry for the double post. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 17, 2012 Share Posted October 17, 2012 I'm not really sure how you can get to 900 posts without knowing how to echo. Learning HTML is a very critical step to knowing web development. Quote Link to comment Share on other sites More sharing options...
webguync Posted October 17, 2012 Author Share Posted October 17, 2012 I know HTML just fine, it was the PHP syntax, I was having trouble with, which is why I posted in a PHP forum. Quote Link to comment 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.