Hiii

I have two tables
1.category_sub
sub_id
category_id
category_name
description
event
image

2.category
category_id
category_name

my query is that how can i get both values category_id and category_name in category_submy code is that like

<?php

include("connection.php");

 $query_1 = "SELECT distinct(category_name) from `category` ";  
        $result_1 = mysql_query($query_1);

$category_name="";
$subcategory_name="";
$description="";
$event="";
$file ="";

if(isset($_POST['submit2']))
  {
 $category_name=$_POST['category_name'];
 $subcategory_name=$_POST['subcategory_name'];
 $description=$_POST['description'];
 $event=$_POST['event'];
 $file=$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"],"cat_image"."_".$_FILES["file"]["name"]);

$insert_subcategory="INSERT INTO `category_sub`(`sub_id`, `category_id`, `category_name`, `subcatogory_name`, `description`, `event`, `image`) VALUES (null,'$category_id','$category_name','$description','$event','$file')";

 $result_subcat=mysql_query($insert_subcategory);
  //echo $result;
  if(!$result_subcat) 
            {
                 "<br>".die('Error: ' . mysql_error());

            }


}

mysql_close();


?>

<!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>Intrade sub category</title>
<link href="rule.css"rel="stylesheet" type="text/css" />
</head>

<body style=" background:none;">
<form method="post" action="">
<!--wrapper start-->
<div class="wrapper">

    <!--header start-->
  <div class="header">

        <!--header_top start-->
        <!--<div class="header_top">
            <div class="logo">
            Logo
            </div>

            <div class="navigation">

              <div class="links"> <a href="#"> Home </a></div>
                <div class="links"> <a href="#">How it work</a></div>
                <div class="links"> <a href="#">Market</a></div>
                <div class="links"><a href="#">Contact us</a></div>
                <div class="links1"><img src="img/search_icon.png"><input type="search" style="float:right; margin-top:-10px;"></div>
            </div>
        </div>-->
        <!--header_top end-->

        <!--header_bottom star-->



<div class="signup_wrapper clearfix">





              <!--  <div class="right_navigation">
                <div class="heading">
             <!--  About Intrade-->
             <!-- </div>
                    <ul>
                    <li><a href="#"  class="curent">Intrade Category</a></li>
                     <li><a href="#">Intrade Sub Category</a></li>
                    </ul>



                </div>-->


                <div class="left_deshboard">
                  <!--<div class="heading">
            Intrade category
                </div>-->

              <div class="money clearfix">
              <ul >
             <li style="list-style-type:none; float:left; margin:20px; font:16px calibri; clear:both; width:200px;"> <label>Category Type:</label></li>
             <li style="list-style-type:none; float:left; margin:20px;">
             <select name="category_name">
             <option value=""> --- Please Select --- </option>

             <?php
                    while($row = mysql_fetch_array($result_1))
                         {?> 

                         <option value="<?php echo $row['category_name'];?>"><?php echo $row['category_name'];?></option>
                                <?php }?>
             </select> </li>


               <li style="list-style-type:none; float:left; margin:20px; font:16px calibri; clear:both; width:200px;"> <label>Insert sub Category :</label></li>
             <li style="list-style-type:none; float:left; margin:20px;">
             <input type="text" name="subcategory_name"/></li>

              <li style="list-style-type:none; float:left; margin:20px; font:16px calibri; clear:both; width:200px;"><label>Category description:</label></li>
             <li style="list-style-type:none; float:left; margin:20px;">
             <textarea cols="20" name="description">
              </textarea></li>


               <li style="list-style-type:none; float:left; margin:20px; font:16px calibri; clear:both; width:200px;"> <label>Insert Event :</label></li>
             <li style="list-style-type:none; float:left; margin:20px;">
             <textarea cols="20" name="event">
              </textarea> </li>


               <li style="list-style-type:none; float:left; margin:20px; font:16px calibri; clear:both; width:200px;"> <label>Upload image :</label></li>
             <li style="list-style-type:none; float:left;margin:20px;">
             <input type="file" name="file"/></li>



               <li style="list-style-type:none; float:left; margin:20px; font:16px calibri; clear:both;"> 
                <input type="submit" name="submit2" value="" style="background-image:url(img/submit.png); width:100px; height:40px; border:none;
               background-color:transparent; margin:20px;"/></li>

              </ul>
                </div>


</div>


            </div>



         <!--header_bottom end-->



    </div>
    <!--header end-->


<div style="clear:both;"></div>



</div>

<!-- <div class="footer" > 
  <div class="footer_wrapper" >
     <div class="foo_box">
        <ul >
        <li class="lihead">About Intrade</li>
        <li><a href="#">What Intrade all about</a></li>
        <li><a href="#">contact Intrade</a></li>
        <li class="lihead"><a href="#">Follow us</a></li>
        <li><a href="#"><img src="img/fb.png"></a> <a href="#"><img src="img/tw.png"></a></li>
        </ul>
     </div>

     <div class="foo_box">
        <ul>
        <li class="lihead"> Intrade Terms & condition</li>
        <li><a href="#">Intrade Rules</a></li>
        <li><a href="#">Market Rules</a></li>
        <li><a href="#">Privacy Policy</a></li>
        <li><a href="#">Data Protection Consent</a></li>
        <li><a href="#">Trading Disclaimer</a></li>
        <li><a href="#">T&Cs for Posting Content</a></li>
        </ul>
     </div>

      <div class="foo_box">
        <ul>
        <li class="lihead">How Intrade Works</li>
        <li><a href="#">The Basics</a></li>
        <li><a href="#">Intrade Fees</a></li>
        <li ><a href="#">Documentation Requirement</a></li>
        <li><a href="#">Customer support</a></li>
        </ul>
     </div>

      <div class="foo_box">
        <ul>
        <li class="lihead">Report & Market Data</li>
        <li><a href="#">Intrade Platform Status</a></li>
        <li><a href="#">Intrade Data</a></li>
        <li ><a href="#">Working with students</a></li>

        </ul>
     </div>

      <div class="foo_box">
        <ul>
        <li class="lihead">Platform & interface</li>
        <li><a href="#">New interface</a></li>
        <li><a href="#">Mobile</a></li>
        <li ><a href="#">Intrade Practice</a></li>

        <li><a href="#">API</a></li>
         <li ><a href="#">Old Interface</a></li>
        </ul>
     </div>

 </div>
 </div>-->
<!--wrapper end-->
</form>
<script type="text/javascript">
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
</script>
</body>
</html>

can you please explain your problem clearly?

Member Avatar for diafol

I'm assuming:

sub_id
category_id
category_name *
description
event
image

* = category_sub_name ?

Thanks for reply to all..my problem is solved n sorry next time i ll be clear to ask my query..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.