Jump to content

Archived

This topic is now archived and is closed to further replies.

DarthHate

Trying to add php in html that's in a .php...ouch

Recommended Posts

Actually, I have a php page, that defines a template. Somewhere in there I have $head = <html> etc etc.
So basically, $head defines what my front page looks like. The thing is, I want to insert some user statistics from my database on the front page. The database query is obviously easy. But how do I slip it in there? I started trying something then I realised I had no idea what i was even trying to do...
Cheers

Share this post


Link to post
Share on other sites
That's a little hard to grasp exactly what you're trying to do. Can you post some code? If it's just as simple as displaying HTML along with PHP, you can jump in and out of PHP code as much as you want. And you can store whatever you want to in a PHP variable if that's the problem.

Share this post


Link to post
Share on other sites
[code]
<?

include "../mysqlcon.php";

$admin_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_admin"));
$n = basename($_SERVER['PHP_SELF']);

.
.(this is still php)
.

elseif($page == "admin_broadcast.php") { $b19 = "<b>"; }

$head = "
<html>
<head>
<title>$admin_header1</title>

.
.(this is html in a php variable)
.

<center>
<br>
<img src='../images/bh.gif' border='0' style='margin-left: 6px;'>
</center>"
[/code]

on the last line, where img src is, i want to make table, and have the img on the center, an ad on the left and my php query on the right.

Hope it's a bit more clear now, sry for the initial crappy explanation :)

Share this post


Link to post
Share on other sites
I'm curious. Is there a reason you're putting all of your html inside of a php variable? Like the other poster said, it's very easy to jump in and out of php and therefore have html code integrated there as well.

Share this post


Link to post
Share on other sites
am i missing something here? seems like all you would have to do is:
[code]
.
.
.
$head = "
<html>
<head>
<title>$admin_header1</title>

.
.(this is html in a php variable)
.
.
.
<table><tr>
   <td>
      advertisement stuff
   </td>
   <td>
      <center>
      <br>
       <img src='../images/bh.gif' border='0' style='margin-left: 6px;'>
       </center>"
   </td>
   <td>
      database query stuff
   </td>
</tr></table>
[/code]

well it seems to me that's all you have to do?

Share this post


Link to post
Share on other sites
So is this php variable with all of the html in it going to be displayed later in the script? I guess I'm just not seeing why anyone would want to put all of the html inside of a variable. Maybe if I new more about what you're trying to do with the whole page, I or someone else on here could come up with a better solution to your problem.

Share this post


Link to post
Share on other sites

×

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.