Hi all, i would like to create a php code which allow user insert data to mysql table and save it to a html file.
there are two part of my design,
the first part allow user insert data to mysql.. like this
<html>
<body>
<form action="insert.php" method="post">
<p>size:<input type="text" name="size" /></p>
<p>color: <input type="text" name="color" /></p>
<p>name: <input type="text" name="name" /></p>
<p>Length: <input type="text" name="length" /></p>
<p>heigth: <input type="text" name="heigth" /></p>
<input type="submit" />
</form>
</body>
</html>
this part work fine
the other part is the html template
<TABLE >
<TD width="170" valign=top><p>Item Code</p>
<p> </p>
<p>Color</p>
<p> </p>
<p>Size</p>
<p> </p>
</TD>
<TD width="150" valign=top><p>AC1016</p>
<p> </p>
<p>Length</p>
<p> </p>
<p><?php
mysql_connect(localhost);
@mysql_select_db("testtt") or die( "Unable to select database");
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM example WHERE id IN (3)" )
or die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result);
// Print out the contents of the entry
echo $row['name'];
?>
</p>
<p> </p>
<p>Height</p>
</TD>
</TABLE>
The problem is that i want every column retrieve data from mysql, so according to my method, there will be a lot of php script (start from <?php.............?>) replace to color, size, length, height. This method seems so stupid, i would like to know how does you guys make it.
The second problem is that ("SELECT * FROM example WHERE id IN (3)" ). how can i automate the where id in (y) , i dont want to change every html to display the correct data. Could any body suggest method to me . thanks