So I am new to PHP but I have put forth a lot of effort to research my answer before taking it to the community. So far this what I have:
<?php
$id=$_GET['id'];
include("config.php");
include("openDB.php");
$table = 'vendors';
$sortBy = 'Company/Name';
$query=" SELECT * FROM `$table` WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"Company/Name");
$code=mysql_result($result,$i,"Code");
$acct=mysql_result($result,$i,"Account Info");
$phone=mysql_result($result,$i,"Phone Number");
$user=mysql_result($result,$i,"Username");
$pass=mysql_result($result,$i,"Password");
$web=mysql_result($result,$i,"Website");?>
<form action="updatePayee.php?id=<?php echo $id; ?>" method="post">
<input type="hidden" name="ud_id" value="<? echo $id; ?>">
Company/Name: <input type="text" name="ud_name" value="<? echo $name; ?>"><br>
Code: <input type="text" name="ud_code" value="<? echo $code; ?>"><br>
Account Info: <input type="text" name="ud_acct" value="<? echo $acct; ?>"><br>
Phone Number: <input type="text" name="ud_phone" value="<? echo $phone; ?>"><br>
Username: <input type="text" name="ud_user" value="<? echo $user; ?>"><br>
Password: <input type="text" name="ud_pass" value="<? echo $pass; ?>"><br>
Web Address: <input type="text" name="ud_web" value="<? echo $web; ?>"><br>
<input type="Submit" value="Update">
</form>
<?php
++$i;
}
?>
Here is the updatePayee.php file that is referenced by the form:
<?php
$id=$_GET['id'];
$ud_id=$_POST['ud_id'];
$ud_name=$_POST['ud_name'];
$ud_code=$_POST['ud_code'];
$ud_acct=$_POST['ud_acct'];
$ud_phone=$_POST['ud_phone'];
$ud_user=$_POST['ud_user'];
$ud_pass=$_POST['ud_pass'];
$ud_web=$_POST['ud_web'];
include("config.php");
include("openDB.php");
$table = 'vendors';
$ud_query = "UPDATE `$table` SET Company/Name = '$ud_name', Code = '$ud_code', Account Info = '$ud_acct', Phone Number = '$ud_phone', Username = '$ud_user', Password = '$ud_pass', Website = '$ud_web' WHERE id = '$ud_id'" or die(mysql_error());
mysql_query($ud_query);
$ud_query = mysql_query("SELECT * FROM `$table` WHERE id = '$ud_id'")
or die(mysql_error());
$fields_nums = mysql_num_fields($ud_query); // Code, Account Info, Ph#, User, PW, Web, Active
$fieldname = array();
echo "<table>";
for($i=0; $i<$fields_nums; $i++)
{
$fields = mysql_fetch_field($ud_query);
$fieldname[$i] = $fields->name;
};
$ID=$fieldname[0];
$ACTIVE=$fieldname[8];
unset($fieldname[0]);
unset($fieldname[8]);
echo '<tr><td id="headers">'.implode('</td><td id="headers">',$fieldname).'</td></tr>';
$row = mysql_fetch_array($ud_query);
echo '<div id="updated">Record Updated</div>';
echo '<tr id="data">';
echo '<td>'.$row["Company/Name"].'</td>';
echo '<td>'.$row["Code"].'</td>';
echo '<td>'.$row["Account Info"].'</td>';
echo '<td>'.$row["Phone Number"].'</td>';
echo '<td>'.$row["Username"].'</td>';
echo '<td>'.$row["Password"].'</td>';
echo '<td><a href="'.$row["Website"].'">'.$row["Website"].'</a></td></tr>';
echo '</table>';
mysql_close();
?>
For some reason I've gotten the page to say that it updated the file, and to display the result of the edit, the problem is that the entry was not updated at all. I've checked my variables to see what I'm missing but I'm not seeing it. Any help you can provide would mean a lot, so thanks in advance.