Hello guys, I have a PHP where I show results in a table and this table codes are used in a echo function as below, but I can't run other PHP codes there, how can I solve it? I need to publish results like name, date and time. Thanks echo"<table> <tr> <td width='50%'> <h3>Contact Details:</h3> <table> <tr> <td id='header' width='35%'>Name:</td> <td id='data' width='65%' style='text-transform: uppercase;'><?php echo $name ;?></td> </tr> <tr> <td id='header' width='35%'>Date:</td> <td id='data' width='65%'><?php echo $date ;?></td> </tr> <tr> <td id='header' width='35%'>Time:</td> <td id='data' width='65%'><?php echo $time ;?></td> </tr> </table>"; PHP:
The problem is that you are using echo inside the echo. So the right code is: <?php echo"<table> <tr> <td width='50%'> <h3>Contact Details:</h3> <table> <tr> <td id='header' width='35%'>Name:</td> <td id='data' width='65%' style='text-transform: uppercase;'>".$name."</td> </tr> <tr> <td id='header' width='35%'>Date:</td> <td id='data' width='65%'>".$date."</td> </tr> <tr> <td id='header' width='35%'>Time:</td> <td id='data' width='65%'>".$time."</td> </tr> </table>"; PHP:
Yeah, that's right, I didn't know how to use it when html code is added... But then I figured out that I should only end php code and start after the html code again so it would be like; <?php echo $mycode; ?> <table> <tr> <td width='50%'> <h3>Contact Details:</h3> <table> <tr> <td id='header' width='35%'>Name:</td> <td id='data' width='65%' style='text-transform: uppercase;'><?php echo $name ;?></td> </tr> <tr> <td id='header' width='35%'>Date:</td> <td id='data' width='65%'><?php echo $date ;?></td> </tr> <tr> <td id='header' width='35%'>Time:</td> <td id='data' width='65%'><?php echo $time ;?></td> </tr> </table> <?php echo $rest; ?> PHP:
Your first code you pasted could of worked, because you didn't specify if your using the .html extension or .php