Yomar Urungar: PHP Varialbe in html einbauen?

Hallo,

ich möchte das Attribut width einer Tabelle in einer php variable speichern.
Ich habe das so versucht

<?php
 var $table_Width = 123;
....
?>

<html>....
...
<table width ="<?php $table_Width ?>"....>
</table>

...
</html>

aber das funktioniert nicht. Wenn ich mir den quellcode im browser anschaue bekomme ich:

<table width =""....>
</table>

...
</html>

also für width gar nix.

Wieso?
lg
Yomar

  1. du musst es per echo ausgeben lassen.

    allerdings geht auch folgendes <?=$variable?>

    versuch's mal so

    Hallo,

    ich möchte das Attribut width einer Tabelle in einer php variable speichern.
    Ich habe das so versucht

    <?php
    var $table_Width = 123;
    ....
    ?>

    <html>....
    ...
    <table width ="<?php $table_Width ?>"....>
    </table>

    ...
    </html>

    aber das funktioniert nicht. Wenn ich mir den quellcode im browser anschaue bekomme ich:

    <table width =""....>
    </table>

    ...
    </html>

    also für width gar nix.

    Wieso?
    lg
    Yomar

  2. Hallo,

    ich möchte das Attribut width einer Tabelle in einer php variable speichern.
    Ich habe das so versucht

    <?php
    var $table_Width = 123;
    ....
    ?>

    <html>....
    ...
    <table width ="<?php $table_Width ?>"....>
    </table>

    ...
    </html>

    aber das funktioniert nicht. Wenn ich mir den quellcode im browser anschaue bekomme ich:

    <table width =""....>
    </table>

    ...
    </html>

    also für width gar nix.

    Wieso?
    lg
    Yomar

    versuch mal
    <?php echo $table_Width; ?>
    Das funktioniert auf jedenfall