Current location: Hot Scripts Forums » Programming Languages » PHP » Help with updating db on multi row php

Help with updating db on multi row php

Reply
  #1 (permalink)  
Old
New Member
 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Help with updating db on multi row php

I have created a simple little set of pages and a small mysql db that i use on my home server. I am having trouble creating a page that will allow me to update rows in my database. I can get the text areas to fill in but not update.

here is code for the page
PHP Code:

<?

include('header.php');
$dbname 'supplies';
$con=mysql_connect("localhost","xxxx","xxxx");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

$boxes=$_POST['boxsel2'];

mysql_select_db($dbname,$con) or die(mysql_error());
$fquery "SELECT * From generalitems WHERE boxnum ='$boxes'ORDER BY itemtype";
$result mysql_query($fquery) or die(mysql_error());

$count=mysql_num_rows($result);
 
if(
mysql_num_rows($result) == 0){
echo(
"no records found");
} ELSE {
?>
<form action='' method='post' name='updatebox'><table border='1'>
<tr>
<th></th>
<th> Box </th>
<th> Category </th>
<th> Item </th>
<th> Quantity </th>
<th> Purchase Date </th>
<th> Expiration Date </th>
<th> Description </th>
<th> Notes </th>
</tr>

<?
while($row mysql_fetch_array($result))
{
?>
  <tr>
  <td><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td>
  <td><? echo $row['boxnum'];  ?></td>
  <td><input name='itemtype[]' type='text' value="<? echo $row['itemtype']; ?> "></td>
  <td><input name='item[]' type='text' value="<? echo $row['item']; ?>"></td>
  <td><input name='quantity[]' type='text' value="<? echo $row['quantity']; ?> " size="6"></td>
  <td><input name='datepurchased[]' type='text' value="<? echo $row['datepurchased']; ?> "></td>
  <td><input name='expiredate[]' type='text' value="<? echo $row['expiredate']; ?> "></td>
  <td><textarea name='description[]'><? echo $row["description"]; ?> </textarea></td>
  <td><textarea name='notes[]'><? echo $row["notes"]; ?> </textarea></td>

<?
}
?>

</table>
      <input type="submit" name="Submit" value="Submit">
  
</form>
<?


// Check if button name "Submit" is active, do this
if($Submit){
for(
$i=0;$i<$count;$i++){
$sql1mysql_query("UPDATE generalitems SET itemtype='$itemtype[$i]', item='$item[$i]', quantity='$quantity[$i]', datepurchased='$datepurchased[$i]', expiredate='$expiredate[$i]', description='$description[$i]', notes='$notes[$i]' WHERE id='$id[$i]'");
$result1=mysql_query($sql1);
}
}

if(
$result1){
header("location:boxmod.php");
}


mysql_close($con);
?>
I am not very concerned with security as this will not be hosted on the web. But any security problems noticed would also help. I havn't done any of this in about 4 years and its definatly not like riding a bike lol.
Thanks for any and all help.
Reply With Quote

Featured Marketplace Scripts (view more)

Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem creating Two related drop down list in php pulling data from oracle db Majdoleen PHP 0 10-14-12 04:42 AM
Sports Pick Em racingboy20 Script Requests 3 06-18-10 03:12 AM
Error Updating Access DB daint ASP 2 12-05-05 08:32 AM
Can anyone help me ? (problem using php variables in html db insert code) chronic_ PHP 2 06-13-04 11:19 AM
question about updating a page or database for an, php and mysql updating mikewooten PHP 1 02-12-04 12:11 AM


All times are GMT -5. The time now is 05:08 AM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.