Jump to content


Photo

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


  • Please log in to reply
7 replies to this topic

#1 DarthHate

DarthHate
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 10 April 2006 - 07:04 PM

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



#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 10 April 2006 - 07:58 PM

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.

Info: PHP Manual


#3 DarthHate

DarthHate
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 10 April 2006 - 08:58 PM

<?

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

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 :)


#4 DarthHate

DarthHate
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 12 April 2006 - 03:08 PM

sorry to up this...but i've still not found a solution :(
No-one has any ideas?

#5 Paithar

Paithar
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 12 April 2006 - 09:28 PM

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.

#6 DarthHate

DarthHate
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 April 2006 - 05:12 AM

no reason besides the fact that it's a script that was made this way :)

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 13 April 2006 - 05:35 AM

am i missing something here? seems like all you would have to do is:
.
.
.
$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>

well it seems to me that's all you have to do?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 Paithar

Paithar
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 13 April 2006 - 02:01 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users