Jump to content

issue with category and subcategory fields which are displaying numbers instead of names


hance2105
Go to solution Solved by hance2105,

Recommended Posts

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">
<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>

 

 

post-156156-0-16919900-1370366937_thumb.png

post-156156-0-81713500-1370367126_thumb.png

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.