Jump to content

[SOLVED] Converting HTML code with a bit of PHP code into full blown PHP code


Voodoo Jai

Recommended Posts

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

 

Link to comment
Share on other sites

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>";
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.