hance2105 Posted June 4, 2013 Share Posted June 4, 2013 i have a page where i add products to my database. the products category and subcategory are stored as numbers when added. see attachment 1 below when i query any product by id, numbers instead of names are displayed - attachment 2 i dnt know why it is not displaying the name assigned to the numbers please help here is my code on my php page <!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"> <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> Link to comment https://forums.phpfreaks.com/topic/278768-issue-with-category-and-subcategory-fields-which-are-displaying-numbers-instead-of-names/ Share on other sites More sharing options...
mikosiko Posted June 4, 2013 Share Posted June 4, 2013 well... if you are not looking for a matching record of those category/subcategory numbers in the table that could contain them how are you expecting to get a different result of what you have now? do you have a category/subcategory table or not? Link to comment https://forums.phpfreaks.com/topic/278768-issue-with-category-and-subcategory-fields-which-are-displaying-numbers-instead-of-names/#findComment-1434068 Share on other sites More sharing options...
hance2105 Posted June 5, 2013 Author Share Posted June 5, 2013 i have a category and a subcategory table Link to comment https://forums.phpfreaks.com/topic/278768-issue-with-category-and-subcategory-fields-which-are-displaying-numbers-instead-of-names/#findComment-1434176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.