Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. inserting the id of data in the second dropdown menu(this second drop down menu depends on the first drop down menu) in to my database 2.please can anyone teach me how to mantain the userid of some one who logs in so that i can use it later

inserting the id of data in the second dropdown menu(this second drop down menu depends on the first drop down menu) in to my database 2.please can anyone teach me how to mantain the userid of some one who logs in so that i can use it later

Scheduled Pinned Locked Moved Web Development
helpdatabasetutorialquestionphp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nahelna
    wrote on last edited by
    #1

    for the first question: pliz help me, i keep getting the error [i]Notice: Undefined index: cat in c:\program files\easyphp1-8\www\myhelpdesk\postqueryagain.php on line 40[/i] if i remove the line $cat=$_GET['cat']; the second drop down menu doesnt function well thanx guys [code] include('connect_db.php'); $quer2=mysql_query("SELECT DISTINCT typename,probtypeid FROM probtype order by typename"); $cat=$_GET['cat'];//This line is added to take care if your global variable is off if(isset($cat) and strlen($cat) > 0) { $quer=mysql_query("SELECT DISTINCT catname FROM category where probtypeid=$cat order by catname"); } else { $quer=mysql_query("SELECT DISTINCT catname FROM category order by catname"); } echo "

    "; //Add your form processing page address to action in above line. Example action=dd-check.php // Starting of first drop downlist echo "select problem type"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['probtypeid']==@$cat) { echo "$noticia2[typename]".""; } else { echo "$noticia2[typename]"; } } echo ""; //Starting of second drop downlist echo "Select problem category"; while($noticia = mysql_fetch_array($quer)) { echo "$noticia[catname]"; } echo ""; //This will end the second drop down list echo "

    "; ?> [/code] i want to insert the id of the catname.thanx guys nahelna

    J 1 Reply Last reply
    0
    • N nahelna

      for the first question: pliz help me, i keep getting the error [i]Notice: Undefined index: cat in c:\program files\easyphp1-8\www\myhelpdesk\postqueryagain.php on line 40[/i] if i remove the line $cat=$_GET['cat']; the second drop down menu doesnt function well thanx guys [code] include('connect_db.php'); $quer2=mysql_query("SELECT DISTINCT typename,probtypeid FROM probtype order by typename"); $cat=$_GET['cat'];//This line is added to take care if your global variable is off if(isset($cat) and strlen($cat) > 0) { $quer=mysql_query("SELECT DISTINCT catname FROM category where probtypeid=$cat order by catname"); } else { $quer=mysql_query("SELECT DISTINCT catname FROM category order by catname"); } echo "

      "; //Add your form processing page address to action in above line. Example action=dd-check.php // Starting of first drop downlist echo "select problem type"; while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['probtypeid']==@$cat) { echo "$noticia2[typename]".""; } else { echo "$noticia2[typename]"; } } echo ""; //Starting of second drop downlist echo "Select problem category"; while($noticia = mysql_fetch_array($quer)) { echo "$noticia[catname]"; } echo ""; //This will end the second drop down list echo "

      "; ?> [/code] i want to insert the id of the catname.thanx guys nahelna

      J Offline
      J Offline
      Johnny
      wrote on last edited by
      #2

      If you're wondering why your question got marked down it's probably because of essay-sized title and ugly code-dump. Without paying any attention to your code or what you are trying to do, the error message tells you everything you need to know. On line 40 of the code (whichever that is, I'm not figuring it out from here) something is trying to access the 'cat' element of an array. This element doesn't exist, hence the error.

      N 2 Replies Last reply
      0
      • J Johnny

        If you're wondering why your question got marked down it's probably because of essay-sized title and ugly code-dump. Without paying any attention to your code or what you are trying to do, the error message tells you everything you need to know. On line 40 of the code (whichever that is, I'm not figuring it out from here) something is trying to access the 'cat' element of an array. This element doesn't exist, hence the error.

        N Offline
        N Offline
        nahelna
        wrote on last edited by
        #3

        sorry guess am just confused,forgot to use the tags, i tried to remove it but when i do that the second dropdown menu stops depending on the first dropdown menu. ok, is there anyway i can generate two dropdown menus one depending on the other the error is Notice: Undefined index: cat in c:\program files\easyphp1-8\www\myhelpdesk\dropdown2.php on line 13 this line reads $cat = $_GET['cat'];//

        <?php

        //include('connect_db.php');
        $quer2 = mysql_query("SELECT DISTINCT typename,probtypeid FROM probtype order by typename");
        $cat = $_GET['cat'];//This line is added to take care if your global variable is off

        if(!empty($cat))
        {
        $quer=mysql_query('SELECT DISTINCT `catname` FROM `category` WHERE`probtypeid`= \''.mysql_escape_string($cat).'\' ORDER BY `catname`');
        }
        else
        {
        $quer=mysql_query('SELECT DISTINCT `catname` FROM `category` OREER BY `catname`');
        }

        echo '<form method="post" name="f1" action="postquery.php">';

        //Add your form processing page address to action in above line. Example action=dd-check.php
        // Starting of first drop downlist
        echo '<select name="cat" onchange="reload(this.form)">
        <option value="">select problem type</option>';

        while($noticia2 = mysql_fetch_assoc($quer2))
        {
        if($noticia2['probtypeid']==@$cat)
        {
        echo ' <option selected value="',mysql_escape_string($noticia2['probtypeid']),'">',$noticia2['typename'],'</option>',"\n";
        }
        else
        {
        echo ' <option value="',$noticia2['probtypeid'],'">',$noticia2['typename'],'</option>',"\n";
        }
        }
        echo '</select>';

        //Starting of second drop downlist
        echo '<select name="subcat"><option value="">Select problem category</option>',"\n";

        while($noticia = mysql_fetch_array($quer))
        {
        echo ' <option value="',$noticia['catname'],'">',$noticia['catname'],'</option>',"\n";
        }

        echo '</select>';

        //This will end the second drop down list
        echo '</form>';
        ?>

        1 Reply Last reply
        0
        • J Johnny

          If you're wondering why your question got marked down it's probably because of essay-sized title and ugly code-dump. Without paying any attention to your code or what you are trying to do, the error message tells you everything you need to know. On line 40 of the code (whichever that is, I'm not figuring it out from here) something is trying to access the 'cat' element of an array. This element doesn't exist, hence the error.

          N Offline
          N Offline
          nahelna
          wrote on last edited by
          #4

          by the way when i select a value from a drop down main categoryn the error disappears, why?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups