Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i input multiple values into a db table

Status
Not open for further replies.

breimer

Technical User
Jan 12, 2004
1
US
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:
<?php 

// Set the variables for the database access: 

$Host = &quot;localhost&quot;; 
$DBName = &quot;db_name&quot;; 
$TableName = &quot;accounts&quot;; 
$Link = mysql_connect ($Host, $User, $Password); 

$Query = &quot;SELECT * from $TableName ORDER BY accountname&quot;; 

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


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

// Fetch the results from the database. 

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



} 

print (&quot;<br><br><br><input type=submit name='Add Sales'>&quot;); 
print (&quot;</form>&quot;); 
?>



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
 
are you asking how to do a database insert or update, or is your code broken and not passing any variable to your second page?
 
and you have turned around the name and the value, now everything has the same value. you can better use an array for the name field which also has the appropiate fieldname in it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top