Web Hosting Talk







View Full Version : Creating webpages when inserting mysql data


saj
03-06-2003, 10:42 AM
Hi all

Quick question

is it possible to Create new webpages if u insert new data in mysql database

for example i have a database containing product details which has things like, description,category,price, etc...etc

each product has its own .php page containing the details of this particular product

What im wondering is each time i want to add a new product to the database i want it to be displayed on a new webpage..its is possible to automatically create this?

Can this be done? if yes how

or has anyone got any better solutions!


thanks
saj

saj
03-06-2003, 01:02 PM
i think i got the solution

create one single page say for exampled called

products.php

and it shud function something like

products.php?prod_id=1

how does one start something off like this
?

bullethead
03-06-2003, 02:24 PM
Maybe something like this:// This adds a product to the product database.

function addProd($name, $cost, $description) {

@mysql_query("
INSERT INTO products SET name = \"$name\", cost = \"$cost\", description = \"$description\"
");
}

// Display Products
function dispProd()
{
echo("
<table>
<tr><td colspan=3><center><b>Products</b></center></td>
</tr>
<tr><td align=center><b>Name</b></td>
<td align=center><b>Cost</b></td>
<td align=center><b>Description</b></td>
</tr>
");
$result = @mysql_query("SELECT * FROM products");
while($row = mysql_fetch_array($result)) {
extract($row);
echo("
<tr><td>$name</td>
<td>$cost</td>
<td>$description</td>
</tr>
");
}
echo("
</table>
");
}