So let me start by saying I am new to PHP so any extra advice is helpful, working on a large scale personal project hoping to get better with PHP because of it.
Now I have a script that displays my database just as I like, and next to each row is a [edit] link (currently doesn't do anything). My goal is to enable this edit/icon link to enable a popup from; enabled through a .JS file (I've attached). I would like the form to popup pre-filled with the info of that record selected (I suppose using the $result[$id] var).
//This section gathers the field names
// and puts them in the first row of the table
$sql = "SELECT * FROM `vendors` ORDER BY `Company/Name` ASC";
$query = mysql_query($sql);
$fields_nums = mysql_num_fields($query); // Code, Account Info, Ph#, User, PW, Web, Active
$fieldname = array();
for($i=0; $i<$fields_nums; $i++)
{
$fields = mysql_fetch_field($query);
$fieldname[$i] = $fields->name;
echo "<td id='headers'>".$fieldname[$i]."</td>";
}
// This section is pulling the data from the db and populating the
//table accordingly
while($result = mysql_fetch_array($query)) {
$id = $result[0];
$name = $result[1];
$code = $result[2];
$acct = $result[3];
$ph = $result[4];
$username = $result[5];
$pw = $result[6];
$web = $result[7];
$active = $result[8];
echo "<tr id='data'>";
echo "<td>".$id."</td>";
echo "<td>".$name."</td>";
echo "<td>".$code."</td>";
echo "<td>".$acct."</td>";
echo "<td>".$ph."</td>";
echo "<td>".$username."</td>";
echo "<td>".$pw."</td>";
echo "<td><a href='".$web."'>".$web."</a></td>";
echo "<td>".$active."</td>";
echo "<td style='border:none'>[edit]</td>";
echo "</tr>";
}
The popup form is already predefined above this section for when adding an entry:
<!-- ADD PAYEE FORM -->
<div id="button"><input type="Submit" name="addPayee" value="Add Payee" id="popup"></div>
</center>
<div id="popupContact">
<a id="popupContactClose">x</a>
<h1>Add a new Payee here!</h1>
<p id="contactArea">
<form action="payees.php" method="post">
If field is blank please leave blank.
<p>Company/Name: <input type="text" name="name"> Code: <input type="text" name="code" size="4"></p>
<p>Account Info: <input type="text" name="acct" size="36" /></p>
<p>Phone: <input type="text" name="phone"/> xxx.xxx.xxx</p>
<p>Username: <input type="text" name="username" size="15"> Password:<input type="text" name="password" size="15"></p>
<p>Website: <input type="text" name="web" value="http://" size="36"></p>
<p><LABEL>Active Account:<INPUT TYPE="checkbox" NAME="active" VALUE="yes">Yes</LABEL></p>
<p><input type="Submit" name="addPayee" value="Add Payee"></p>
</form>
</p>
</div>
<div id="backgroundPopup"></div> <!-- End payee form pop-up -->
So first question, how do I make the [edit] link (or possible icon in future) active so onClick a new update form pops up with an update button. Even without the pop-up feature I'm not sure how to edit a single-entry.
Thank you so much for any help you can provide, I've looked everywhere so if you can help this will mean so much. Thanks again.