Buffmin
09-12-2011, 06:57 PM
I am fairly new here and learning. I'm making a menu for a sub shop. I want to allow the client to edit prices. 1)I know how to pull data date from my table and display it in a form (allowing the price fields to be "editable"). 2)I know how to create a form and submit the entered values to my table in the database (as variables).
My problem is that I do not know how to connect steps 1 & 2. Is there a way to re-assign the form cells (that I am displaying), as variables so I can then re-upload them to the table?
Am I going about this all wrong? Is there a more common way to build a simple interface for the client, or open-source code? I hope I explained myself and I would sincerely appreciate any help or direction.
<html>
<head>
<title>View mymenu</title>
</head>
<body>
<h2>View mymenu</h2>
<?php
//Displays all data 'mymenu' table
//Connect to database
require ('dbstuff.php');
$db = connectDB();
$result = mysql_query("SELECT * FROM mymenu")
or die(mysql_error());
// Display data from mysql table "mymenu"
?>
<form action="" form name="editform" method="post">
<?
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID</th><th>type</th> <th>half</th><th>full</th></tr>";
// loop
$count= 0;
while($row = mysql_fetch_array( $result )) {
++$count;
// echo out the contents of each row into a table
echo "<tr>";
echo '<td name="ID">' . $row['ID'] . '</td>';
echo '<td>' . $row['type'] . '</td>' ;
echo '<td><input type="text" value= ' . $row['half'] . '></td>';
echo '<td><input type="text" value= ' . $row['full'] . '></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
My problem is that I do not know how to connect steps 1 & 2. Is there a way to re-assign the form cells (that I am displaying), as variables so I can then re-upload them to the table?
Am I going about this all wrong? Is there a more common way to build a simple interface for the client, or open-source code? I hope I explained myself and I would sincerely appreciate any help or direction.
<html>
<head>
<title>View mymenu</title>
</head>
<body>
<h2>View mymenu</h2>
<?php
//Displays all data 'mymenu' table
//Connect to database
require ('dbstuff.php');
$db = connectDB();
$result = mysql_query("SELECT * FROM mymenu")
or die(mysql_error());
// Display data from mysql table "mymenu"
?>
<form action="" form name="editform" method="post">
<?
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID</th><th>type</th> <th>half</th><th>full</th></tr>";
// loop
$count= 0;
while($row = mysql_fetch_array( $result )) {
++$count;
// echo out the contents of each row into a table
echo "<tr>";
echo '<td name="ID">' . $row['ID'] . '</td>';
echo '<td>' . $row['type'] . '</td>' ;
echo '<td><input type="text" value= ' . $row['half'] . '></td>';
echo '<td><input type="text" value= ' . $row['full'] . '></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>