|
-
Nov 13th, 2006, 12:03 PM
#1
Thread Starter
Frenzied Member
Passing a value, then updating the DB
Hey everyone.
Thanks for the help on my other problems.
I just cant seem to figure this one out.
What I am trying to do is...
This form gets passed a pasc_id value, I have a query where it takes that value, searched the DB, and displays the results in text box's so the user can change them, then hit "Update" and it will udpate those values in the DB.
For some reason i cant get this to work 
I was trying to make it query the DB, then put the values of the query into selected text boxes, then if they hit "update" it would update the db, based on the pasc_id(they cant change that)
The form displays the first query where i get the pasc_id and its values.
Here is the error i get:
PHP Code:
<?php
//adding header.php
$page_title = "Update Part Information";
include('../php/header.php');
//connection to database
include('../db_conn/mysql_conn.php');
?>
<table cellspacing="2" cellpadding="2" border="0" width="900" height="50">
<tr>
<td rowspan="2">
<fieldset>
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td bgcolor="#c0c0c0" width="100"><b>PASC ID</b></td>
<td bgcolor="#c0c0c0" width="100"><b>Part Number</b></td>
<td bgcolor="#c0c0c0" width="150"><b>PO #</b></td>
<td bgcolor="#c0c0c0" width="150"><b>Date Entered</b></td>
<td bgcolor="#c0c0c0" width="150"><b>Part Notes</b></td>
</tr>
<tr>
<?php
$pasc_id = $_REQUEST['pasc_id'];
//Start Form
echo '<form action="Update_Part.php" method="post">';
?>
<?
$request = "SELECT DISTINCT pasc_id,part_number,return_po,date_entered,part_notes FROM dss_returns where pasc_id = '$pasc_id'";
$query = mysql_query($request);
$num = mysql_num_rows($query);
while($data = mysql_fetch_array($query)){
echo '<td valign="top"><a href="./Update_Part.php?pasc_id=' . $data['pasc_id'] . '">' .' ' . $data['pasc_id'] . '</a>'. '</td>';
//echo '<form action="Update_Part.php" method="post">';
echo '<td valign="top"><input align="top" type="text" name="partnumber" size="20" maxlenght="20" value="'. $data['part_number'] .'"/>' . '</td>';
echo '<td valign="top"><input align="top" type="text" name="return_po" size="20" maxlenght="20" value="'. $data['return_po'] .'"/>' . '</td>';
echo '<td valign="top"><input align="top" type="text" name="date_entered" size="20" maxlenght="20" value="'. $data['date_entered'] .'"/>' . '</td>';
echo '<td valign="top"><textarea name="partcomments" rows="6" cols="40">';
echo $data['part_notes'];
echo '</textarea> </td> </tr>';
echo '<td></td><td></td><td></td><td></td><td align="right"><input type="submit" name="submit" value="Update Record" align="right"/></form>';
}
?>
</table>
</fieldset>
<?php
if(isset($_POST['submitted'])){$errors = array();
}
if(empty($_POST['partnumber'])){$errors[] = 'Part Number';
}else{$partnumber = trim($_POST['partnumber']);
}
if(empty($_POST['return_po'])){$errors[] = 'Return PO';
}else{$return_po = trim($_POST['return_po']);
}
if(empty($_POST['date_entered'])){$errors[] = 'Date Entered';
}else{$date_entered = trim($_POST['date_entered']);
}
if(empty($_POST['partcomments'])){$errors[] = 'Part Comments';
}else{$partcomments = trim($_POST['partcomments']);
}
//below is line 66
$request = "UPDATE dss_returns (part_number,return_po,date_entered,part_notes) VALUES ('$partnumber','$return_po','$date_entered','$partcomments') WHERE pasc_id = '$pasc_id'";
$query = mysql_query($request);
$num = mysql_num_rows($query);
?>
</td>
</tr>
<tr>
</tr>
</table>
<?php
//adding footer.php
include('../php/footer.php');
?>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|