hance2105 Posted June 1, 2013 Share Posted June 1, 2013 hello all, i have a form named del_prod.php containing a search delete and update button. i want to know how i can perform my search by inserting the product id in the product id field and related record is displayed in the textfields in the form. delete the record from mysql table update the record as well this is my del_prod.php page code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Delete Product</title> <link href="CSS/del_prod.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="stylized" class="myform"> <form id="form" name="del_prod" method="post" action="delprod.php"> <h2 align="center"><b>- Delete / Update Product -</b></h2> <table width="1000" border="0"> <tr> <td><div align="right">Product ID</div></td> <td><input type="text" name="prod_id" id="prod_id"/></td> </tr> <tr> <td><div align="right">Product Name</div></td> <td><input type="text" name="prod_name" id="prod_name" /></td> </tr> <tr> <td><div align="right">Product Brand</div></td> <td><input type="text" name="prod_brand" id="prod_brand"/></td> </tr> <tr> <td><div align="right">Product Description</div></td> <td><textarea name="prod_desc" id="prod_desc" cols="45" rows="5"></textarea></td> </tr> <tr> <td><div align="right">Product Price (MRU)</div></td> <td><input type="text" name="prod_price" id="prod_price"/></td> </tr> <tr> <td><div align="right">Product Category</div></td> <td><input type="text" name="cat" id="cat"/></td> </tr> <tr> <td><div align="right">Product Subcategory</div></td> <td><input type="text" name="subcat" id="subcat"/></td> </tr> <tr> <td><div align="right">Product Weight/Capacity</div></td> <td><input type="text" name="prod_w_c" id="prod_w_c"/></td> </tr> <tr> <td><div align="right">Uploaded Photo Path</div></td> <td><input type="text" name="prod_photo" id="prod_photo"/></td> </tr> </table> <p align="center"> <input type="submit" class="button" name="search" id="search" value="<-- Search -->" /> <input type="submit" class="button" name="delete" id="delete" value="<-- Delete product -->" /> <input type="submit" class="button" name="update" id="update" value="<-- Update product -->" /> </p> </form> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
hance2105 Posted June 1, 2013 Author Share Posted June 1, 2013 my database table is tbl_product where the records are stored when added with database name buysmart Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 1, 2013 Share Posted June 1, 2013 this is a very common activity/task/assignment. there are 100's of thousands of examples posted on the Internet to find and examine to see how others have done this. where exactly are you stuck at in your attempt do do this? Quote Link to comment Share on other sites More sharing options...
hance2105 Posted June 1, 2013 Author Share Posted June 1, 2013 i know it is a common activity...am stuck at the query where i insert the product id to retrieve the data but the fields is not populated at all Quote Link to comment Share on other sites More sharing options...
hance2105 Posted June 1, 2013 Author Share Posted June 1, 2013 i managed to sort out the search issue by using below code....but now can i hv the codes to delete the record or update it? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Delete Product</title> <link href="CSS/del_prod.css" rel="stylesheet" type="text/css" /> <SCRIPT language=JavaScript> function reload(form) { var val=form.prod_id.options[form.prod_id.options.selectedIndex].value; //var description1=form.description.value; self.location='del_upd_prod.php?prod_id=' + val; //+'&description=' +description1; } </script> </head> <body> <?php include('db_connect.php'); @$prod_id=$_GET['prod_id']; //@$description=$_GET['description']; //$id = rtrim($_GET['id']); $query=mysql_query("select prod_id from tbl_product"); $query1=mysql_query("select prod_name, prod_brand, prod_desc, prod_price, cat, subcat, prod_w_c, prod_photo from tbl_product where prod_id='$prod_id'"); $row=mysql_fetch_array($query1); ?> <div id="stylized" class="myform"> <form id="form" name="del_prod" method="post" action="delupdprod.php"> <h2 align="center"><b>- Delete / Update Product -</b></h2> <table width="1000" border="0"> <tr> <td><div align="right">Product ID</div></td> <td> <?PHP echo "<select name='prod_id' onchange=\"reload(this.form)\"><option value=''>select one</option>"; while($row1 = mysql_fetch_array ($query)) { if($row1['0']==@$prod_id){echo "<option selected value='".$row1['0']."'>".$row1['0']."</option>";} else{echo "<option value=\"".$row1['0']."\">".$row1['0']."</option>";} } echo "</select>"; ?> </td> </tr> <tr> <td><div align="right">Product Name</div></td> <td><input type="text" name="prod_name" id="prod_name" value = "<?PHP print $row['prod_name']; ?>"/></td> </tr> <tr> <td><div align="right">Product Brand</div></td> <td><input type="text" name="prod_brand" id="prod_brand" value = "<?PHP print $row['prod_brand']; ?>"/></td> </tr> <tr> <td><div align="right">Product Description</div></td> <td><textarea name="prod_desc" id="prod_desc" cols="45" rows="5"><?PHP print $row['prod_desc']; ?></textarea></td> </tr> <tr> <td><div align="right">Product Price (MRU)</div></td> <td><input type="text" name="prod_price" id="prod_price" value = "<?PHP print $row['prod_price'] ?>"/></td> </tr> <tr> <td><div align="right">Product Category</div></td> <td><input type="text" name="cat" id="cat" value = "<?PHP print $row['cat']; ?>"/></td> </tr> <tr> <td><div align="right">Product Subcategory</div></td> <td><input type="text" name="subcat" id="subcat" value = "<?PHP print $row['subcat']; ?>"/></td> </tr> <tr> <td><div align="right">Product Weight/Capacity</div></td> <td><input type="text" name="prod_w_c" id="prod_w_c" value = "<?PHP print $row['prod_w_c']; ?>"/></td> </tr> <tr> <td><div align="right">Uploaded Photo Path</div></td> <td><input type="text" name="prod_photo" id="prod_photo" value = "<?PHP print $row['prod_photo']; ?>"/></td> </tr> </table> <p align="center"> <input type="submit" class="button" name="delete" id="delete" value="<-- Delete product -->" /> <input type="submit" class="button" name="update" id="update" value="<-- Update product -->" /> </p> </form> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Solution hance2105 Posted June 4, 2013 Author Solution Share Posted June 4, 2013 any help? Quote Link to comment 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.