Hi All,
Im currently having difficulties trying to echo certain data from a database.
I have a dropdown list which consist of 4 items from my database, i added these to the dropdown using the following code:
<td align = "right">Product Category: </td>
<td>
<select name = "product_category">
<option> Select a category </option>
<?php
$get_cats = "select * from categories";
$run_cats = mysqli_query($con, $get_cats);
while ($row_cats=mysqli_fetch_array($run_cats)){
$cat_id = $row_cats['cat_ids'];
$cat_title = $row_cats['cat_title'];
echo "<option value = '$cat_id'>$cat_title</option>";
}
This part is fine as the dropdown loads the list from the database. the next step is echoing what ever is selected in the dropdown. i do this using the following code:
<?php if (isset($_POST['insert_post'])) { //Retrieving data from input fields from above. $product_title = $_POST['product_title']; $product_cat = $_POST['product_cat']; $product_course = $_POST['product_course']; $product_price = $_POST['product_price']; $product_desc = $_POST['product_desc']; $product_keywords = $_POST['product_keywords']; echo $insert_product = "insert into products (product_course, product_cat, product_title,product_price,product_desc,product_keywords) values ('$product_course','$product_cat','$product_title','$product_price','$product_desc','$product_keywords')"; } This is partially fine which is where i come to my issue. [b]nothing is echoed for product_cat.[/b] it just appears as to quotation marks. product_course is identical to category but different items and works fine. if i select the third option from the dropdown for course it will echo a 3 on the page. This is the echoed result. insert into products (product_course, product_cat, product_title,product_price,product_desc,product_keywords) values ('5','','Example','3.00',' Example ','Example') as you can see above there is a '' displayed which should contain a value between 1-4 depending on the selected item. Any help will be greatly appreciated.