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.

my first guess would be a sql error and I am suspicious of your column name "Company/Name". I have never seen this done and am guessing that you may have to escape that "/" so it would be "Company\/Name".

I would try to change the column name in the future to an _ or - to prevent future issues.


[EDIT]
you also have some spaces in your column names and would have to surround them with ``.

$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());

you could also try this but my bet is on the first:

$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());

or die(mysql_error()) should not be on line 16 but 17

SWEET! So I figured it out. You were on the right track and for future reference I will make a habit of your suggested naming conventions. I went ahead into the phpAdmin and manually made the edit to see the SQL code that got generated from the edit. From this I noticed that the column names had a ` surrounding them so I tried that and it worked. Thanks for the help I'm sure I'll have more questions cause now I have to take my project to the next step.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.