A strange php question.

Discussion in 'PHP' started by x0x, Sep 6, 2008.

  1. #1
    I have a thing here.

    The page prints out a message that has many php queries and other stuff in it.

    Example:

    php:
    
    <?=commas($somestuff[5]+$somestuff[26]+$somestuff[27]/*$lol1+$lol2+$lol3+$lol4+$lol5*/)?>
     </font>
     went and knocked out (
    
      <? if($somestuff[5]>0){?>
      <font color="#FFFFFF">
      <?=commas($result[5])?>
      </font>  guys
      <? } ?>
    
      <? if($somestuff[26]>0){?>
      <font color="#FFFFFF">
      <?=commas($result[26])?>
      </font>  girls
      <? } ?>
    etc etc etc
    
    PHP:
    While the HTML message that would be printed on the screen would look like:
     xx went and knocked out xx guys xx girls etc... 
    HTML:
    So that said. My question is the following:
    Can I make the HTML a variable and put into the database? Not the php, only the html. Example: 145 went and knocked out 34 guys 22 girls.
    (those examples were just part of the long long code)
    If that can't be done I will have to make a nother text and pull each variable separately and insert to db..

    Thanks.
     
    x0x, Sep 6, 2008 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Yes:

    
    <?php
    ob_start();
    ?>
    <?=commas($somestuff[5]+$somestuff[26]+$somestuff[27]/*$lol1+$lol2+$lol3+$lol4+$lol5*/)?>
     </font>
     went and knocked out (
    
      <? if($somestuff[5]>0){?>
      <font color="#FFFFFF">
      <?=commas($result[5])?>
      </font>  guys
      <? } ?>
    
      <? if($somestuff[26]>0){?>
      <font color="#FFFFFF">
      <?=commas($result[26])?>
      </font>  girls
      <? } ?>
    etc etc etc
    <?php
    $variable = ob_get_contents();
    ob_end_clean();
    
    PHP:
    $variable will contain the info.

    Peace,
     
    Barti1987, Sep 6, 2008 IP
  3. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks!!!!
     
    x0x, Sep 6, 2008 IP
  4. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #4
    I have a weird issue.

    <?php
    ob_start();
    ?>
    *my php stuff*
    <?php
    $variable = ob_get_contents();
    ?>
    
    PHP:

    It works when I try to echo $variable but when i use a mysql insert command nothing but blank will go into the database...
     
    x0x, Sep 6, 2008 IP