SimplePortal

Customization => Custom Coding => Topic started by: vaesir on September 07, 2009, 12:14:59 PM

Title: HTML+PHP in the same block
Post by: vaesir on September 07, 2009, 12:14:59 PM
Hi guys,
I need to put in the same block 2 diffrent things:
This HTML:
Code: [Select]
<center><iframe src="http://free.timeanddate.com/clock/i1o32g5s/n224/tlro32/fn4/fs30/fc00f/tct/pct/ftb/th1/ts1" frameborder="0" width="70" height="38" allowTransparency="true"></iframe>
And this from PHP:
Code: [Select]
  <?php
echo <div align="center">
echo 
$txt="Ziua eRepublik";
$x=16;
echo 
$txt="-";
$x=16;

$luna date("m");
$zi date("d");
$an date("Y");

$ziua1 mktime(0,0,0,11,21,2007);
$timestamp mktime(1,0,0,$luna,$zi,$an);

$zi ceil(($timestamp $ziua1)/86400);

echo 
$zi </div>;

?>


</center>

haw can i do that?
Thanks
Title: Re: HTML+PHP in the same block
Post by: Nathaniel on September 07, 2009, 05:49:11 PM
Use the 'echo' function to display the HTML, or some PHP code like this.

Code: [Select]
//php code
?>
HTML code
<?php
//more php code

So, try this code:
Code: [Select]
?>
<center><iframe src="http://free.timeanddate.com/clock/i1o32g5s/n224/tlro32/fn4/fs30/fc00f/tct/pct/ftb/th1/ts1" frameborder="0" width="70" height="38" allowTransparency="true"></iframe>
<?php
echo $txt="Ziua eRepublik";
$x=16;
echo 
$txt="-";
$x=16;

$luna date("m");
$zi date("d");
$an date("Y");

$ziua1 mktime(0,0,0,11,21,2007);
$timestamp mktime(1,0,0,$luna,$zi,$an);

$zi ceil(($timestamp $ziua1)/86400);

echo 
$zi </div>;
?>

</center>
<?php
Title: Re: HTML+PHP in the same block
Post by: vaesir on September 08, 2009, 11:45:07 AM
Use the 'echo' function to display the HTML, or some PHP code like this.

Code: [Select]
//php code
?>
HTML code
<?php
//more php code

So, try this code:
Code: [Select]
?>
<center><iframe src="http://free.timeanddate.com/clock/i1o32g5s/n224/tlro32/fn4/fs30/fc00f/tct/pct/ftb/th1/ts1" frameborder="0" width="70" height="38" allowTransparency="true"></iframe>
<?php
echo $txt="Ziua eRepublik";
$x=16;
echo 
$txt="-";
$x=16;

$luna date("m");
$zi date("d");
$an date("Y");

$ziua1 mktime(0,0,0,11,21,2007);
$timestamp mktime(1,0,0,$luna,$zi,$an);

$zi ceil(($timestamp $ziua1)/86400);

echo 
$zi </div>;
?>

</center>
<?php
Is not working. If i try to put it into a HTML block i got the clock and that's it. In a php Block is not working at all.
Title: Re: HTML+PHP in the same block
Post by: AngelinaBelle on September 08, 2009, 12:03:57 PM
SMF (and simpleportal) basically use PHP to write HTML (this is dynamic HTML). So that is what you do in a php block.
php code will only work from a PHP block

The php code you started with has problems -- missing semicolons, missing quotes, etc.
And it is not clear what is going on with "$x=16;" -- that value of $x is never used for anything at all. Maybe you wanted the octal 16 and octal 17 "shift-out" and "shift-in" characters to shift character sets?
http://en.wikipedia.org/wiki/Shift_Out_and_Shift_In_characters (http://en.wikipedia.org/wiki/Shift_Out_and_Shift_In_characters)
 
This code might work better than the code you started with. In any case, if you want to build a php block that works, you might find it useful to start with an empty block and add in one line at a time to figure out where your problem is.
Code: [Select]
echo '
<center>
<iframe
src="http://free.timeanddate.com/clock/i1o32g5s/n224/tlro32/fn4/fs30/fc00f/tct/pct/ftb/th1/ts1"
frameborder="0" width="70" height="38" allowTransparency="true"></iframe>
';
echo '<div align="center">';

echo "Ziua eRepublik" .  "-";
 
// Or did you really want
// echo 'Ziua eRepublik' . chr(14)  . "-" . chr(15);

$luna = date("m");
$zi = date("d");
$an = date("Y");

$ziua1 = mktime(0,0,0,11,21,2007);
$timestamp = mktime(1,0,0,$luna,$zi,$an);

$zi = ceil(($timestamp - $ziua1)/86400);

echo $zi . ' </div>
</center>';
Title: Re: HTML+PHP in the same block
Post by: vaesir on September 08, 2009, 12:22:48 PM
@AngelinaBelle Thank you...
The x was for size of the text.
But thank you again for your help...
Title: Re: HTML+PHP in the same block
Post by: AngelinaBelle on September 08, 2009, 12:53:03 PM
Code: [Select]
echo 'Ziua eRepublik <span style="font-size:15px">-</span>';
Good Luck!
You may want to learn a little bit more about php and HTML as you continue to customize things.
http://www.w3schools.com/PHP/DEfaULT.asP (http://www.w3schools.com/PHP/DEfaULT.asP)
and  http://www.php.net/manual/ro/index.php (http://www.php.net/manual/ro/index.php)
 
http://www.w3schools.com/html/html_styles.asp (http://www.w3schools.com/html/html_styles.asp).
SimplePortal 2.3.8 © 2008-2024, SimplePortal