fbm Posted March 2, 2009 Share Posted March 2, 2009 Hi Again I am now trying to edit data already stored in my DB. My data is populated on a page called client_list.php and code looks like this <table width="860" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="id">ID</td> <td class="company">Company</td> <td class="contact">Contact Name</td> <td class="email">Email</td> <td class="phone">Phone</td> <td class="actions">Actions</td> </tr> <?php $result = mysql_query("SELECT * FROM clients ORDER BY id ASC"); while($row = mysql_fetch_array($result)) { echo "<tr>\n"; echo "<td class='row_id'>".$row['id']."</td>\n"; echo "<td class='row'>".$row['company']."</td>\n"; echo "<td class='row'>".$row['primary_contact']."</td>\n"; echo "<td class='row'><a href='mailto:".$row['primary_email']."'>".$row['primary_email']."</a></td>\n"; echo "<td class='row'>".$row['primary_phone']."</td>\n"; echo "<td class='row'>\n"; echo "<ul>\n"; echo "<li class='view'><a href='clients_view.php?id=".$row['id']."'><span>view</span></a></li>\n"; echo "<li class='edit'><a href='clients_edit.php?id=".$row['id']."'><span>edit</span></a></li>\n"; echo "<li class='delete'><a href='process_delete_client.php?id=".$row['id']."'><span>delete</span></a></li>\n"; echo "</ul>\n"; echo "</td>\n"; echo "</tr>\n"; } ?> </table> Using the edit button which you can see at the bottom of the above code it links me to http://localhost/fbmcrm/manage/clients_edit.php?id=4 clients_edit.php looks like this <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Add Clients</h1> <?php $result = mysql_query("SELECT * FROM clients WHERE `id` = '".$_GET['id']."'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <form name="form" method="POST" action="process_edit_client.php"> <div id="add_client_box"> <h1>Account Details</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Company : </td> <td class="right"><input class="field" type="text" name="company" value="<?php echo $row['company'];?>" /></td> </tr> <tr> <td class="left">Account No : </td> <td class="right"><input class="field" type="text" name="account_number" value="<?php echo $row['account_number'];?>"/></td> </tr> <tr> <td class="left">Website : </td> <td class="right"><input class="field" type="text" name="website" value="<?php echo $row['website'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>Company Address</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Building Number : </td> <td class="right"><input class="field" type="text" name="building_number" value="<?php echo $row['building_number'];?>" /></td> </tr> <tr> <td class="left">Street : </td> <td class="right"><input class="field" type="text" name="street" value="<?php echo $row['street'];?>" /></td> </tr> <tr> <td class="left">City : </td> <td class="right"><input class="field" type="text" name="city" value="<?php echo $row['city'];?>" /></td> </tr> <tr> <td class="left">County : </td> <td class="right"><input class="field" type="text" name="county" value="<?php echo $row['county'];?>" /></td> </tr> <tr> <td class="left">Post Code : </td> <td class="right"><input class="field" type="text" name="post_code" value="<?php echo $row['post_code'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>Primary Contact</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Primary Contact : </td> <td class="right"><input class="field" type="text" name="primary_contact" value="<?php echo $row['primary_contact'];?>" /></td> </tr> <tr> <td class="left">Primary Email : </td> <td class="right"><input class="field" type="text" name="primary_email" value="<?php echo $row['primary_email'];?>" /></td> </tr> <tr> <td class="left">Primary Phone : </td> <td class="right"><input class="field" type="text" name="primary_phone" value="<?php echo $row['primary_phone'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>Billing Contact</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Billing Contact : </td> <td class="right"><input class="field" type="text" name="billing_contact" value="<?php echo $row['billing_contact'];?>" /></td> </tr> <tr> <td class="left">Billing Email : </td> <td class="right"><input class="field" type="text" name="billing_email" value="<?php echo $row['billing_email'];?>" /></td> </tr> <tr> <td class="left">Billing Phone : </td> <td class="right"><input class="field" type="text" name="billing_phone" value="<?php echo $row['billing_phone'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>User Credentials</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Username : </td> <td class="right"><input class="field" type="text" name="username" value="<?php echo $row['username'];?>" /></td> </tr> <tr> <td class="left">Password : </td> <td class="right"><input class="field" type="text" name="password" value="<?php echo $row['password'];?>" /></td> </tr> </table> </div> <div id="add_account_box"><input class="button" value="UPDATE" type="submit" /></div> </form> </div> </div> <?php include "includes/footer.php"; ?> I basically copied the form i use to add a client but grabbed the ID and give the form fields the value set to populate the form. the form action is set to go too process_edit_client.php and this page contains <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <?php $id = $_GET['id']; $company = $_POST['company']; $account_number = $_POST['account_number']; $website = $_POST['website']; $building_number = $_POST['building_number']; $street = $_POST['street']; $city = $_POST['city']; $county = $_POST['county']; $post_code = $_POST['post_code']; $primary_contact = $_POST['primary_contact']; $primary_email = $_POST['primary_email']; $primary_phone = $_POST['primary_phone']; $billing_contact = $_POST['billing_contact']; $billing_email = $_POST['billing_email']; $billing_phone = $_POST['billing_phone']; $username = $_POST['username']; $password = $_POST['password']; $query = "UPDATE `clients` SET `company` = '$company', `account_number` = '$account_number', `website` = '$website', `building_number` = '$building_number', `street` = '$street', `city` = '$city', `county` = '$county', `post_code` = '$post_code', `primary_contact` = '$primary_contact', `primary_email` = '$primary_email', `primary_phone` = '$primary_phone', `billing_contact` = '$billing_contact', `billing_email` = '$billing_email', `billing_phone` = '$billing_phone', `username` = '$username', `password` = '$password' WHERE `id` = '$id'"; mysql_query($query) or die(mysql_error()); } echo "<center>"; echo "<h1>Updating Client Details, Please Wait</h1>"; echo "<META HTTP-EQUIV=Refresh CONTENT='5; URL=clients_list.php'> "; echo "</center>"; ?> </div> <?php include "includes/footer.php"; ?> So now when i click the edit button from my table list of clients i get a parse error Parse error: parse error in C:\wamp\www\fbmcrm\manage\clients_edit.php on line 107 Line 107 was the include footer line but when i remove this the line number just goes to the previous line so not sure where i'm going wrong. Quote Link to comment https://forums.phpfreaks.com/topic/147563-solved-how-to-edit-db-data-and-update-db/ Share on other sites More sharing options...
Yesideez Posted March 2, 2009 Share Posted March 2, 2009 Which line is 107? Not being funny, but not wanting to count 107 line in to find the line Quote Link to comment https://forums.phpfreaks.com/topic/147563-solved-how-to-edit-db-data-and-update-db/#findComment-774626 Share on other sites More sharing options...
HuggieBear Posted March 2, 2009 Share Posted March 2, 2009 Add a closing curly bracket before the footer. It's needed to close your while loop. </form> </div> </div> <?php } // <-- Added this ?> <?php include "includes/footer.php"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/147563-solved-how-to-edit-db-data-and-update-db/#findComment-774627 Share on other sites More sharing options...
fbm Posted March 2, 2009 Author Share Posted March 2, 2009 Another outstanding and fast response which has solved the issue. woohoo view, edit and delete buttons now all works wonderfully. Hmm now the easy bit is all sorted need to move onto more advanced stuff, yikes!!! Thanks for the fix guys. Anyone use Skype and interested in working with me on a small CRM system. I really want to build the system myself and learn alot abotu PHP but small questions liek above will always pop up which it would be good to have a contact available to me who is interested in challenges. The CRM system is not a commercial product. I am building it for my own customers and am hoping to offer it as an open source system once its all finished. Quote Link to comment https://forums.phpfreaks.com/topic/147563-solved-how-to-edit-db-data-and-update-db/#findComment-774631 Share on other sites More sharing options...
Yesideez Posted March 2, 2009 Share Posted March 2, 2009 Your best bet will be to keep coming back here for help. There are quite a few here who help others and we all have our own areas where we excell at. I'm great with some stuff but classes (for example) I can't do well. Post here and you'll get the collective expertise rather than selective. EDIT: Edited a typo - why can't I type no more? :'( Quote Link to comment https://forums.phpfreaks.com/topic/147563-solved-how-to-edit-db-data-and-update-db/#findComment-774635 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.