Insert multiple records to a db table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
breimer
Forum Newbie
Posts: 1
Joined: Mon Jan 12, 2004 12:06 pm

Insert multiple records to a db table

Post by breimer »

I am trying to insert multiple variables into a database and am not real sure what I am doing wrong......here is some background to what I am doing.

I am trying to write a page that will allow me to enter sales values for a multiple number of accounts. Following is the code that I use on my input page.....

Code: Select all

<?php

// Set the variables for the database access:

$Host = "localhost";
$DBName = "avi";
$TableName = "accounts";
$Link = mysql_connect ($Host, $User, $Password);

$Query = "SELECT * from $TableName ORDER BY accountname";

$Result = mysql_db_query ($DBName, $Query, $Link);


print ("<form name=sales action=processSales.php method=POST>");

// Fetch the results from the database.

while ($Row = mysql_fetch_array ($Result)) {
echo "<br><b>$Row[accountname]</b>";
print ("<input type=hidden name='$Row[accountname]account' value='$Row[accountname]'>");
print ("     <input type=text name='$Row[accountname]salesvalue' value='Input Sales'>");
print ("     <input type=text name='$Row[accountname]waste' value='Input Waste'>");
print ("     <input type=text name='$Row[accountname]inv' value='Input Inventory'>");
print ("     <input type=text name='$Row[accountname]hours' value='Input Hours'>");
print ("     <input type=text name='$Row[accountname]salesdate' value='Input Sales Date'>");



}

print ("<br><br><br><input type=submit name='Add Sales'>");
print ("</form>");
?>
On my second page, processSales.php, how do I input all of the values of these variables that are posted to that page........

thanks for your help
Post Reply