Difficulty Updating My Database
Posted: Tue Mar 14, 2006 12:29 pm
feyd | Please use
-----------------------
That's it.
Thankyou.
H.
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hello to everyone reading this.
Im a beginner of PHP and MySQL, and i'm having a little difficulty updating one of my databases.
Basically, i have a single page consisting of a table, where i echo some information from the database. This echoing occurs without fail.
I also have x3 drop down menus, one for a Comment, another for Progress and the last for confirming whether the job is Complete or not.
When i make my selections and press submit, it looks as though it updates the database, but it does not. Although the clear button works.
My initial thoughts were, are you able to echo information and update information in a single form? I'm not sure, although i don't see why not, and thats why i have made this such attempt.
If anyone can help, i'd be glad to hear.
Heres my code:
---------------------------Code: Select all
<?
session_start();
?>
<?
include "conn.inc.php";
$query ="SELECT * FROM admin WHERE AdminID= '" . $_SESSION['admin_logged']."'
AND password =(password('" . $_SESSION['admin_password'] . "'));";
$result = mysql_query($query) or die(mysql_error());
$new = mysql_fetch_array($result);
?>
<html>
<head>
<title>Fault Reporting System : : Complete A Call</title>
<body background="h.gif">
<body>
<br>
<div align="center"><h2>Welcome <? echo $new['First_Name']; ?>.<br> Please Select A Call You Would Like To Complete</h2></div>
<br>
<?
include "conn1.inc.php";
$q1 = "SELECT FaultID, AdminID, StaffID, Location, Problem_Desc,
Date, Technician_Comment, Progress, Complete
FROM FAULT
WHERE AdminID= '" . $_SESSION['admin_logged']."'
AND Progress = 'Ongoing'";
$result = mysql_query($q1) or die(mysql_error());
$ans= mysql_num_rows($result);
?>
<?
// updating the database
include "conn1.inc.php";
if ($_POST['submit'] == "Update")
{
if ($_POST['AdminID'] != "" && $_POST['Technician_Comment'] != "" && $_POST['Complete'] != ""
&& $_POST['Progress'] != "")
$q8 = "INSERT INTO Fault(Technician_Comment, Progress, Complete)
VALUES('" . $_POST['Technician_Comment'] . "', '" . $_POST['Progress'] . "', '" . $_POST['Complete'] . "');";
$result = mysql_query($q8) or die(mysql_error());
$_SESSION['admin_logged'] = $_POST['AdminID'];
$_SESSION['admin_password'] = $_POST['password'];
}
?>
<?
//EOD, all table variables held between EOD statements;
$progress_table=<<<EOD
<div align="center"><h4>Here Are Your Outstanding Calls</h4></div>
<form action="Fault_All_My_Completed_Calls.php" method="post">
<table width="100%" border="5" cellpadding="1" cellspacing="1" align="center">
<tr>
<th>FaultID</th>
<th>AdminID</th>
<th>StaffID</th>
<th>Location</th>
<th>Problem Description</th>
<th>Technician Comment</th>
<th>Date</th>
<th>Progress</th>
<th>Complete</th>
</tr>
EOD;
while($row = mysql_fetch_array($result))
{
$FaultID = $row['FaultID'];
$AdminID = $row['AdminID'];
$StaffID = $row['StaffID'];
$Location = $row['Location'];
$Problem_Desc = $row['Problem_Desc'];
$Technician_Comment = $row['Technician_Comment'];
$Date = $row['Date'];
$Progress = $row['Progress'];
$Complete = $row['Complete'];
$progress_table_info .=<<<EOD
<tr>
<td>$FaultID</td>
<td>$AdminID</td>
<td>$StaffID</td>
<td>$Location</td>
<td>$Problem_Desc</td>
<td><select name="Technician_Comment">
<option value="" SELECTED>Select Comment...</option>
<option value="Working fine now">Working fine now</option>
<option value="Sent back to manufacturer">Sent back to manufacturer</option>
<option value="3rd party coming in to look at it">3rd party coming in to look at it</option>
<option value="Need more time">Need more time</option>
</select></td>
<td>$Date</td>
<td><select name="Progress">
<option value="" SELECTED>Select Progress...</option>
<option value="Ongoing">Ongoing</option>
<option value="Complete">Complete</option>
</select></td>
<td><select name="Complete">
<option value="" SELECTED>Complete...</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select></td>
</tr>
EOD;
}
$progress_table_info .=<<<EOD
<tr>
<td> </td>
EOD;
$progress_table_end ="</table>";
$progress =<<<PROGRESS
$progress_table
$progress_table_info
$progress_table_end
PROGRESS;
echo $progress;
?>
<br>
<br>
<input type="submit" name="submit" value="Submit">
<input type="reset" value="Clear">
</body>
</html>-----------------------
That's it.
Thankyou.
H.
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]