Voodoo Jai Posted December 27, 2007 Share Posted December 27, 2007 I have this code that is HTML with a portion of PHP to display database detail, what I whant to do is convert it to PHP code. I know its probably the wrong place to ask but can anyone help. What I am doing is using an IF statement to show this bit of code to display data from the db. My problem is I dont Know how to show this snippet of code from below. <a href="<?php echo $row_Takeaway['WebSite']; ?>" target="_blank"> <?php echo $row_Takeaway['WebSite']; ?></a> as it already contains PHP code. *************************************** <tr> <td valign="top"> <div align="left"> <strong> Web site: </strong> </div> </td> <td valign="top"> <div align="left"> <a href="<?php echo $row_Takeaway['WebSite']; ?>" target="_blank"> <?php echo $row_Takeaway['WebSite']; ?></a> </div> </td> </tr> ************************************************************* Thanks in advance Jai Quote Link to comment https://forums.phpfreaks.com/topic/83370-solved-converting-html-code-with-a-bit-of-php-code-into-full-blown-php-code/ Share on other sites More sharing options...
revraz Posted December 27, 2007 Share Posted December 27, 2007 There really is nothing wrong with how you are doing it, but if you really wanted to change it, you would have to use echos. <?php echo "<a href=\".$row_Takeaway['WebSite'].\" target=\"_blank\"> .$row_Takeaway['WebSite'].</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83370-solved-converting-html-code-with-a-bit-of-php-code-into-full-blown-php-code/#findComment-424151 Share on other sites More sharing options...
blackcell Posted December 27, 2007 Share Posted December 27, 2007 If your php sections is working fine and you want it all to be php, I would suggest: <?php echo" <tr> <td valign='top'> <div align='left'> <strong> Web site: </strong> </div> </td> <td valign='top'> <div align='left'> "; //$url Sets the URL Queried from db to a variable for ease of implementation $url = $row_Takeaway['WebSite']; <a href='$url' target='_blank'> $url [/url] echo" </div> </td> </tr> "; ?> I don't know if the <?php echo" Put HTML Stuff in here and be sure to replace double quotes( \" ) with single quotes( ' ) "; ?> Is the proper use of incorporating html within php. I know it is easier than <?php echo "<tr>"; echo "<td valign='top'>"; echo "<div align='left'>"; echo "<strong>"; echo "Web site:"; echo "</strong>"; echo "</div>"; ?> doing every line. A more experienced php programmer correct me if there is a proper way of performing such tasks. Quote Link to comment https://forums.phpfreaks.com/topic/83370-solved-converting-html-code-with-a-bit-of-php-code-into-full-blown-php-code/#findComment-424155 Share on other sites More sharing options...
revraz Posted December 27, 2007 Share Posted December 27, 2007 It's all preference and what is easiest for you or your team. I like to keep HTML as itself, and only insert PHP when I have to. Quote Link to comment https://forums.phpfreaks.com/topic/83370-solved-converting-html-code-with-a-bit-of-php-code-into-full-blown-php-code/#findComment-424164 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.