im using looping and yet it wont appear in my dropdown list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • annerhexian
    New Member
    • Jan 2008
    • 14

    im using looping and yet it wont appear in my dropdown list

    how can i appear the number 1,2,3-10. in the drop down menu??

    i need ur advice and help as well.. pls do help me..

    thank you very much for ur time and as well as yout help...

    need it within 1day if its fine with you..
    tankx.....
    Code:
    <html>
    select name="level" id="level">
       <option value="------------">---------------</option>
     <?php 
    	 //$i=$_POST['num'];			 
    	 for($i=1;$i<=10;$i++)
    	{ ?>
     <option<?php $i ?>> <?php printf '$i<br>\n"\'; ?></option>
    		<?php 
    		  } 
    		  ?>
    			 
    </select>
    </html>
  • rpnew
    New Member
    • Aug 2007
    • 189

    #2
    Originally posted by annerhexian
    how can i appear the number 1,2,3-10. in the drop down menu??

    i need ur advice and help as well.. pls do help me..

    thank you very much for ur time and as well as yout help...

    need it within 1day if its fine with you..
    tankx.....
    Code:
    <html>
    select name="level" id="level">
       <option value="------------">---------------</option>
     <?php 
    	 //$i=$_POST['num'];			 
    	 for($i=1;$i<=10;$i++)
    	{ ?>
     <option<?php $i ?>> <?php printf '$i<br>\n"\'; ?></option>
    		<?php 
    		  } 
    		  ?>
    			 
    </select>
    </html>
    Hi,

    Try this .........

    [HTML]
    <html>
    <select name="level" id="level">
    <option value="------------">---------------</option>
    <?php
    for($i=1;$i<=10 ;$i++)
    { ?>
    <option value='<?php echo $i; ?>' > <?php printf ($i,'<br>\n\"') ; ?></option>
    <?php
    }
    ?>
    </select>
    </html>
    [/HTML]

    I've just changed line 2 and line 8 in your code(2 and 7 in mine).

    In line 2 you have missed '<' (check the <select> statement).
    In line 8, made a few changes.

    And use the 'printf' statement accordingly so that you can get it in the format you want.
    However the code which i've changed makes a DROPDOWN list with 1 to 10 starting with '---------------'.

    Regards,
    RP

    Comment

    • rpnew
      New Member
      • Aug 2007
      • 189

      #3
      Hi,

      Try this .........

      [HTML]
      <html>
      <select name="level" id="level">
      <option value="------------">---------------</option>
      <?php
      for($i=1;$i<=10 ;$i++)
      { ?>
      <option value='<?php echo $i; ?>' > <?php printf ($i,'<br>\n\"') ; ?></option>
      <?php
      }
      ?>
      </select>
      </html>
      [/HTML]

      I've just changed line 2 and line 8 in your code(2 and 7 in mine).

      In line 2 you have missed '<' (check the <select> statement).
      In line 8, made a few changes.

      And use the 'printf' statement accordingly so that you can get it in the format you want.
      However the code which i've changed makes a DROPDOWN list with 1 to 10 starting with '---------------'.

      Or anything else get back here.

      Regards,
      RP

      Comment

      • annerhexian
        New Member
        • Jan 2008
        • 14

        #4
        hi!

        thank u so much for ur help..
        it heps a lot on my project..

        Comment

        • annerhexian
          New Member
          • Jan 2008
          • 14

          #5
          hi it was appear already but my problem is when i updated it using this code:
          Code:
          <html>
          <select name="level" id="level">
          			<option value="------------">---------------</option>
          			<?php
          		  for($i=1;$i<=10;$i++){
          		  ?>
          			<option <?php if(!strcmp($row['num'],$i)) echo 'selected="selected"'; ?>><?=$i?></option>
                    <?php 
          		  } 
          		  ?>
          			 </select>
          </html>
          it will just give a blank output on it when i went to the update profile? wats wrong with my code im using? i tried to fetch the code on it.. like for example i tried to get number 2 when i updated it the 2 didnt appear..

          i wish u cud help me on this part....

          tanx for the help as always...

          Comment

          • annerhexian
            New Member
            • Jan 2008
            • 14

            #6
            hi it was appear already but my problem is when i updated it using this code:

            num is the field in a table called faculty which the databse is called ranking.
            Code: ( text )
            <html>
            <select name="level" id="level">
            <option value="------------">---------------</option>
            <?php
            for($i=1;$i<=10 ;$i++)
            {
            ?>
            <option
            <?php if(!strcmp($row['num'],$i)) echo 'selected="sele cted"'; ?> ><?=$i> </option>
            <?php
            }
            ?>
            </select>
            </html>


            it will just give a blank output on it when i went to the update profile? wats wrong with my code im using? i tried to fetch the code on it.. like for example i tried to get number 2 when i updated it the 2 didnt appear..

            i wish u cud help me on this part....

            tanx for the help as always...

            Comment

            • rpnew
              New Member
              • Aug 2007
              • 189

              #7
              Originally posted by annerhexian
              hi it was appear already but my problem is when i updated it using this code:

              num is the field in a table called faculty which the databse is called ranking.
              Code: ( text )
              <html>
              <select name="level" id="level">
              <option value="------------">---------------</option>
              <?php
              for($i=1;$i<=10 ;$i++)
              {
              ?>
              <option
              <?php if(!strcmp($row['num'],$i)) echo 'selected="sele cted"'; ?> ><?=$i> </option>
              <?php
              }
              ?>
              </select>
              </html>


              it will just give a blank output on it when i went to the update profile? wats wrong with my code im using? i tried to fetch the code on it.. like for example i tried to get number 2 when i updated it the 2 didnt appear..

              i wish u cud help me on this part....

              tanx for the help as always...
              Hi,
              Can you explain it further?.... i'm afraid i didnt get you exactly.
              what do you want to do? just explain a bit more.

              Regards,
              RP

              Comment

              • annerhexian
                New Member
                • Jan 2008
                • 14

                #8
                Originally posted by rpnew
                Hi,
                Can you explain it further?.... i'm afraid i didnt get you exactly.
                what do you want to do? just explain a bit more.

                Regards,
                RP
                hi sori about that... my problem here is like from another page to fetch from another page for updating.. for example you already inputted in the textbox1 which is 2 and when it was in the updated page it was not fetch.. pls do help me in that code if whats wrong with that.. why cant i fetch the looping variable to update it in the new page.. could you please give me some suggestions about it..
                take for example like this:
                texbox1 is 2 and i want to update the textbox1 into 4 and i couldnt fetch it and update it as well.

                thank you for your time and as well as your help...

                Comment

                • annerhexian
                  New Member
                  • Jan 2008
                  • 14

                  #9
                  hi sori about that... my problem here is like from another page to fetch from another page for updating.. for example you already inputted in the textbox1 which is 2 and when it was in the updated page it was not fetch.. pls do help me in that code if whats wrong with that.. why cant i fetch the looping variable to update it in the new page.. could you please give me some suggestions about it..
                  take for example like this:
                  texbox1 is 2 and i want to update the textbox1 into 4 and i couldnt fetch it and update it as well.

                  thank you for your time and as well as your help...

                  Comment

                  • annerhexian
                    New Member
                    • Jan 2008
                    • 14

                    #10
                    hi sori about that... my problem here is like from another page to fetch from another page for updating.. for example you already inputted in the textbox1 which is 2 and when it was in the updated page it was not fetch.. pls do help me in that code if whats wrong with that.. why cant i fetch the looping variable to update it in the new page.. could you please give me some suggestions about it..
                    take for example like this:
                    texbox1 is 2 in the page1.php and i want to update the textbox1 into 4 in the updatedpage.php and i couldnt fetch the 2 in the textbox1 in the page1.php so that i could update it to 4 in the textbox1 in the updatedpage.php .

                    What will be the best way?

                    thank you for your time and as well as your help...


                    Take care my friend..

                    Comment

                    • rpnew
                      New Member
                      • Aug 2007
                      • 189

                      #11
                      Originally posted by annerhexian
                      hi sori about that... my problem here is like from another page to fetch from another page for updating.. for example you already inputted in the textbox1 which is 2 and when it was in the updated page it was not fetch.. pls do help me in that code if whats wrong with that.. why cant i fetch the looping variable to update it in the new page.. could you please give me some suggestions about it..
                      take for example like this:
                      texbox1 is 2 in the page1.php and i want to update the textbox1 into 4 in the updatedpage.php and i couldnt fetch the 2 in the textbox1 in the page1.php so that i could update it to 4 in the textbox1 in the updatedpage.php .

                      What will be the best way?

                      thank you for your time and as well as your help...


                      Take care my friend..
                      Hi,

                      Here what i understood from your explanation..

                      *You have one page 'page1.php' and another page 'updatedpage.ph p'
                      *You have one 'textbox' on 'page1.php' and another(or dropdown list in your actual case i assume, correct me if i'm wrong) on 'updatedpage.ph p'
                      *Now you are POSTING values pf 'textbox' from 'page1.php' and want to update accordingly on 'updatedpage.ph p'

                      Is this what you are trying to do?? If no then correct me wherever i'm wrong.
                      In any case provide a PIECE of code from both page wherever you are POSTING from first page and FETCHING on second....

                      Regards,
                      RP

                      P.S. : Going through your earlier piece of code

                      Comment

                      • rpnew
                        New Member
                        • Aug 2007
                        • 189

                        #12
                        Originally posted by annerhexian
                        hi sori about that... my problem here is like from another page to fetch from another page for updating.. for example you already inputted in the textbox1 which is 2 and when it was in the updated page it was not fetch.. pls do help me in that code if whats wrong with that.. why cant i fetch the looping variable to update it in the new page.. could you please give me some suggestions about it..
                        take for example like this:
                        texbox1 is 2 in the page1.php and i want to update the textbox1 into 4 in the updatedpage.php and i couldnt fetch the 2 in the textbox1 in the page1.php so that i could update it to 4 in the textbox1 in the updatedpage.php .
                        What will be the best way?

                        thank you for your time and as well as your help...


                        Take care my friend..
                        Hi
                        Checked your code it works fine...
                        I've checked it like following...

                        [PHP]
                        <?php
                        $row['num']=$_GET['num'];
                        echo $row['num'];
                        ?>
                        <html>

                        <select name="level" id="level">

                        <option value="------------">---------------</option>

                        <?php

                        for($i=1;$i<=10 ;$i++){

                        ?>

                        <option <?php if(!strcmp($row['num'],$i)) echo 'selected="sele cted"'; ?>><?=$i?></option>

                        <?php

                        }

                        ?>

                        </select>

                        </html>
                        [/PHP]

                        When i use URL like following...... ...

                        testme.php?num= 2;
                        It displays 2 in dropdown list.

                        testme.php?num= 3;
                        It displays 3 in dropdown list.

                        So if this is what you are looking for then check your '$row['num']' variable..
                        If your problem is something else. Like from this dropdown box you are not able to get the selected value then change line no 17 in my above code as below...


                        [PHP]
                        <option <?php echo 'value='.$i; if(!strcmp($row['num'],$i)) echo ' selected="selec ted"'; ?>><?=$i?></option>
                        [/PHP]

                        So now whatever value is selected you can use it further.
                        Regards,
                        RP

                        Comment

                        Working...