Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Includes & MySQL into webpage w/ Dynamic Variables

Tags:

html

php

I Have a standard HTML table saved into a PHP file which I am putting on many webpages, but each webpage is about a different item.

So in my HTML table (in the blanktable.php file, which I include on the webpages) I've put in undefined PHP variables like so:

    <table>
<tr>
    <td>Item Name:</td>
    <td><?php echo "$name"; ?></td>
</tr>
<tr>
    <td>Price:</td>
    <td><?php echo "$price"; ?></td>
</tr>
<tr>
    </table>

What would be the best way to dynamically create my webpages, so all I would have to do is define the variables instead of hardcoding the HTML each time?

like image 466
user1104233 Avatar asked Apr 09 '26 19:04

user1104233


1 Answers

You can load $name and $price from your database and then include your blanktable.php. By this, the table will be filled with the actual values.

like image 56
Alex Avatar answered Apr 12 '26 07:04

Alex