To the best of my current abilities, I've produced the attached form within a table that displays database values on my site. I'm trying to have the 4 numerical values - Quantity, Price, Shipping, SD Price - editable in the input fields on the right. When I have only minor changes, i.e. to one row, I want to click on the Send button for that row. When I have a large number of changes to make I want to click the Send All which will submit the whole table to the database.
At present the form handler doesn't exist because I'm not confident in where I'm heading next. I believe I need each row's Send button associated with the product ID and the values - see highlights in blue, then in the handler I'll distinguish between the Send All and Send Row buttons, remove the non-null elements and submit these to the database.
First of all, is this the right thing to do? If not, can someone please point me in the right direction eg a tutorials, threads, similar scripts
Any help really is very much appreciated.
Many thanks, Steve
function display_db_table($tablename)
{
$query_string = "SELECT products.products_id, products.products_model, products_name, stock_quantity, seller_stock.products_price, shipping_price, seller_sameday_price
FROM products_description, seller_stock, products
WHERE products_description.products_id = products.products_id
AND products.products_model = seller_stock.products_model
AND seller_id = 2
ORDER BY products_name";
$result_id = mysql_query($query_string);
$column_count = mysql_num_fields($result_id);
print("<form action='".$_SERVER['PHP_SELF']."' method='post'>");
print("<TABLE ALIGN=center VALIGN=TOP width='875' BORDER=1>\n");
print("<TR align=center><TH>Prod ID</TH><TH>Supplier Ref</TH><TH>Title</TH><TH>Qty</TH><TH>Price</TH><TH>Shipping</TH><TH>SD Price</TH><TH>Qty</TH><TH>Price</TH><TH>Shipping</TH><TH>SD Price</TH><TH><input SIZE='5' type='submit' name='SubmitForm' value='Send All'></TH></TR>");
while ($row = mysql_fetch_row($result_id))
{
print("<TR ALIGN=LEFT VALIGN=TOP>");
for ($column_num = 0;
$column_num < $column_count;
$column_num++)
print("<TD>  $row[$column_num]   </TD>\n");
print "<TD><input SIZE='5' type='text' name= ".$quantity."id='quantity' VALUE = ''></TD>";
print "<TD><input SIZE='5' type='text' name= ".$price."id='price' VALUE = ''></TD>";
print "<TD><input SIZE='5' type='text' name= ".$shipping."id='shipping' VALUE = ''></TD>";
print "<TD><input SIZE='5' type='text' name= ".$sdprice."id='sdprice' VALUE = ''></TD>";
print "<TD align = center><input SIZE='5' type='submit' name='SubmitForm' value='Send Row'></TD></TR>";
}
print("</TABLE>\n");}
print("</form>");
?>