Tengo que armar un formulario de edicion de acuerdo a esta consulta sql:
Código PHP:
$id_client=$_POST['id_client'];
$sql= "select * from clients left join client_contacts on client_contacts.client_id=clients.id
left join client_phones on client_phones.client_id=clients.id where clients.id='$id_client'";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
el formulario que uso es este:
Código HTML:
<div align="center"> <h3>Edit Client</h3><br> <form action="" method="POST"> <table> <tr> <td class="required">Company Name:</td> <td><input type="text" name="companyname" id="compyname" value="<? echo $row['company_name'];?>"/> </td> <td><input type="hidden" name="id_client" id="id_client" value="<? echo $id_client;?>"/> </td> </tr> <tr> <td class="required">Address:</td> <td><input type="text" name="address" id="address" value="<? echo $row['address'];?>"/></td> </tr> <tr> <td class="required">City:</td> <td><input type="text" name="city" id="city" value="<? echo $row['city'];?>"/></td> </tr> <tr> <td class="required">Zip</td> <td><input type="text" name="zip" id="zip" value="<? echo $row['zip'];?>"/></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website" id="website" value="<? echo $row['website'];?>"/></td> </tr> <tr> <td colspan="2">Instruccions:</td> </tr> <tr> <td colspan="2"><textarea name="instructions" id="instructions" cols="25" rows="5"><? echo $row['instructions'];?></textarea></td> </tr> <tr> <td colspan="2">Comments:</td> </tr> <tr> <td colspan="2"><textarea name="comments" id="comments" cols="45" rows="5"><? echo $row['comments'];?></textarea></td> </tr> <tr> <td>Events preferents:</td> <td><input type="text" name="eventspref" id="eventspref" value="<? echo $row['event_preferences'];?>"/></td> </tr> <tr> <td>Faq:</td> <td><input type="text" name="faq" id="faq" value="<? echo $row['faq'];?>"/></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2">Company Phones</td> </tr> <tr> <td class="required">phone1:</td> <td> <input type="text" name="phone1" id="phone1" value="<? echo $rows['number'];?>"/> <input type="checkbox" name="fax1" id="fax" value="0" <? if($rows['is_fax']){echo "checked='checked'";}?>> is Fax </td> </tr> <tr> <td>phone2:</td> <td> <input type="text" name="phone2" id="phone2" /> <input type="checkbox" name="fax2" id="fax" value="1"> is Fax </td> </tr> <tr> <td>phone3:</td> <td> <input type="text" name="phone3" id="phone3" /> <input type="checkbox" name="fax3" id="fax3" value="1"> is Fax </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2">Contacts</td> </tr> <tr> <td class="required">Name:</td> <td><input type="text" name="contactname1" id="contactname1" value="<? echo $rows['contact_name'];?>"/></td> </tr> <tr> <td class="required">Phone:</td> <td><input type="text" name="phonecontact1" id="phonecontact1" value="<? echo $rows['phone_number'];?>"/></td> </tr> <tr> <td class="required">Email:</td> <td><input type="text" name="emailcontact1" id="emailcontact1" value="<? echo $rows['email'];?>"/></td> </tr> <tr> <td class="required">Type Contacts:</td> <td><input type="text" name="type1" id="type1" value="<? echo $row['type'];?>"/></td> </tr> <tr> <td>Name:</td> <td><input type="text" name="contactname2" id="contactname2" /></td> </tr> <tr> <td>Phone:</td> <td><input type="text" name="phonecontact2" id="phonecontact2" /></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="emailcontact2" id="emailcontact2" /></td> </tr> <tr> <td>Type Contacts:</td> <td><input type="text" name="type2" id="type2" /></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="btneditclient" id="submit" value="submit" /> </div></td> </tr> </table> </form>