yea i had to change it to <a href="edit.php?RegID='.$u['RegID'].'">Edit</a>
guess it didnt like .qry
Printable View
yea i had to change it to <a href="edit.php?RegID='.$u['RegID'].'">Edit</a>
guess it didnt like .qry
ok, glad its working correctly now :)
Hi mdcloud,
those edit page and delete page u showed on page 2 are not working.
Would you mind posting the working edit page and delete page codes here?
Thanks alot.
What isn't working on it? Do you get an error message or anything like that? The code that was posted should work (syntax wise).
It wont update and delete..
here is the main page:
here is the edit page:Code:<title>Supplier Projects</title>
<?php
require('../Connections/config.php');
require('../Connections/opendb.php');
$result = mysql_query( "SELECT * FROM supplier_projects ORDER BY Supplier ASC " )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
if ($num_rows < 1) {
echo 'There are no products in the database
<br />
<a href="option.php"><<Back</a>';
}
else {
// Start table to display users
echo '
<table border="1" width"800">
<tr>
<td></td><td></td>
<td><b>Supplier</b></td>
<td><b>Project</b></td>
<td><b>Project Name</b></td>
<td><b>Project Code</b></td>
<td><b>sp_pri</b></td>
</tr>';
// For each user found
while($u = mysql_fetch_array($result)) {
// Show data for each user
echo '
<tr>
<td><a href="updateproject2.php?sp_pri='.$u['sp_pri'].'">Edit</a></td>
<td><a href="deleteproject1.php?act=chk_del&id='.$u['sp_pri'].'">Delete</a></td>
<td>'.$u['Supplier'].'</td>
<td>'.$u['Project'].'</td>
<td>'.$u['Project_Name'].'</td>
<td>'.$u['Project_Code'].'</td>
<td>'.$u['sp_pri'].'</td>
</tr>';
}
// End table
echo '
<form method="POST" action="insertproject1.php">
<input type="submit" value="Insert New">
</form>
</table><br><br><a href="bih.html">Back</a>';
}
?>
here is the delete page:Code:<?php
include('../Connections/config.php');
include('../Connections/opendb.php');
// Get the user id
$getid = $_GET['sp_pri'];
echo $getid;
// Get data from user with the specified id
$query="SELECT * FROM supplier_projects WHERE sp_pri ='$getid'";
$result=mysql_query($query) or die ('Error Getting User Data! <br />' .mysql_error());
$chk = mysql_num_rows($result);
$u = mysql_fetch_array($result);
// If edit not hit
if (!$_POST['edit']) {
// If user id returns no results
if ($chk < 1) {
echo 'The supplier project does not exist!';
}
else {
// Edit Form
?>
<!-- Edit Form --><title>Update Project</title>
<form method="post" action="">
<table width="250">
<tr>
<td>Supplier:</td>
<td><input type="text" name="supplier" value="<?php echo $u['Supplier'] ?>" /></td>
</tr>
<tr>
<td>Project:</td>
<td><input type="text" name="project" value="<?php echo $u['Project'] ?>" size="50"/></td>
</tr>
<tr>
<td>Project Name:</td>
<td><input type="text" name="projectname" value="<?php echo $u['Project_Name'] ?>" size="100"/></td>
<tr>
<td>Project Code:</td>
<td><input type="text" name="projectcode" value="<?php echo $u['Project_Code'] ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="edit" value="Update" /></td>
</tr>
</table>
</form>
<!-- /Edit Form -->
<?php
}
// If edit was hit
if ($_POST['edit']) {
$supp = $_POST['Supplier'];
$proj = $_POST['Project'];
$projname = $_POST['Project_Name'];
$projcode = $_POST['Project_Code'];
// Update data
$update = mysql_query("UPDATE supplier_projects SET sp_pri = '$supp$proj', Supplier='$supp', Project = 'proj', Project_Name = 'projname',Project_Code = 'projcode' WHERE sp_pri = '$getid'") or die ('Error Updating Data! <br />' .mysql_error());
echo 'Update successfull';
}
}
?>
Please help me. Thanks a lot !Code:<title>Delete Project</title>
<?php
include('../Connections/config.php');
include('../Connections/opendb.php');
// If delete was hit, ask for confirm
if ($_GET['act'] == 'chk_del') {
$getid = $_GET['sp_pri'];
echo 'Are you sure you want to delete this record?
<br />
<a href="deleteproject1.php?act=delete&sp_pri='.$getid.'">Yes, delete it</a> | <a href="javascript:history.back();">Cancel</a>';
}
// If delete confirmed
elseif ($_GET['act'] == 'delete') {
$getid = $_GET['sp_pri'];
$del = mysql_query("DELETE FROM supplier_projects WHERE sp_pri='$getid'") or die ('Error Deleting User! <br />' .mysql_error());
echo 'The record has been deleted.
<br />
<form method="POST" action="editproject2.php">
<input type="submit" value="Back to Project Forms">
</form>';
}
?>
the delete is working, now working on edit :)
finally fixed the edit problem too..
dam small mistake..
thanks everyone :)
sorry chubcity,
just looked back at this thread. would have posted earlier if i saw it.