$_POST

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kirke

    #1

    $_POST

    Hi. I'm a real beginner of PHP. So if my question is so stupid, plz
    understand me. Thx.


    I made a file like following :

    <form id="form1" name="form1" method="post" action="step2.p hp">
    <table >
    <tr>
    <select name="EngineTyp e" id="EngineType" >

    <?php
    require('conf.p hp')
    dbconnect();
    $sql = 'SELECT * FROM dbo_EngineType;
    $result = mysql_query($sq l) or die();

    while( $row = mysql_fetch_arr ay($result) )
    {
    echo '<option
    value="'.$row['iID'].'">'.strtouppe r($row['sDescription']).'</option>';
    }
    ?>
    </select>
    </tr </table </form>


    And another file have following code :

    <?php
    $EngineID = (int)$_POST['EngineType'];
    ?>


    At here, How can I combine both file? I mean i want to define $EngineID
    as 'EngineType' selected value(option). I don't know how can i change
    $_POST part.

    Thank you!

  • cendrizzi

    #2
    Re: $_POST

    Please be more specific. Do you mean you want to combine the files so
    it's posts to itself so you can show that the correct option is
    selected?

    On Oct 4, 8:12 pm, "kirke" <hinky...@gmail .comwrote:
    Hi. I'm a real beginner of PHP. So if my question is so stupid, plz
    understand me. Thx.
    >
    I made a file like following :
    >
    <form id="form1" name="form1" method="post" action="step2.p hp">
    <table >
    <tr>
    <select name="EngineTyp e" id="EngineType" >
    >
    <?php
    require('conf.p hp')
    dbconnect();
    $sql = 'SELECT * FROM dbo_EngineType;
    $result = mysql_query($sq l) or die();
    >
    while( $row = mysql_fetch_arr ay($result) )
    {
    echo '<option
    value="'.$row['iID'].'">'.strtouppe r($row['sDescription']).'</option>';
    }
    ?>
    </select>
    </tr </table </form>
    >
    And another file have following code :
    >
    <?php
    $EngineID = (int)$_POST['EngineType'];
    ?>
    >
    At here, How can I combine both file? I mean i want to define $EngineID
    as 'EngineType' selected value(option). I don't know how can i change
    $_POST part.
    >
    Thank you!

    Comment

    • kirke

      #3
      Re: $_POST

      No, I want to receive the Enginetype(sele ct name) as $Enginetype in the
      same file.

      then I can use $sql=' ~~~~ where EngineType=$Eng inetype ';


      cendrizzi wrote:
      Please be more specific. Do you mean you want to combine the files so
      it's posts to itself so you can show that the correct option is
      selected?
      >
      On Oct 4, 8:12 pm, "kirke" <hinky...@gmail .comwrote:
      Hi. I'm a real beginner of PHP. So if my question is so stupid, plz
      understand me. Thx.

      I made a file like following :

      <form id="form1" name="form1" method="post" action="step2.p hp">
      <table >
      <tr>
      <select name="EngineTyp e" id="EngineType" >

      <?php
      require('conf.p hp')
      dbconnect();
      $sql = 'SELECT * FROM dbo_EngineType;
      $result = mysql_query($sq l) or die();

      while( $row = mysql_fetch_arr ay($result) )
      {
      echo '<option
      value="'.$row['iID'].'">'.strtouppe r($row['sDescription']).'</option>';
      }
      ?>
      </select>
      </tr </table </form>

      And another file have following code :

      <?php
      $EngineID = (int)$_POST['EngineType'];
      ?>

      At here, How can I combine both file? I mean i want to define $EngineID
      as 'EngineType' selected value(option). I don't know how can i change
      $_POST part.

      Thank you!

      Comment

      • .:[ ikciu ]:.

        #4
        Re: $_POST

        Hmm kirke <hinkyeol@gmail .comwrote:
        No, I want to receive the Enginetype(sele ct name) as $Enginetype in
        the same file.
        then I can use $sql=' ~~~~ where EngineType=$Eng inetype ';
        wrong idea. if you will get all rows from table then store it in session. no
        sense to do query twice. set action (on form) on the same file
        then make your cast to int and just show $allEngineTypes[$postedID] where
        you will store names

        --
        ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
        Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

        2be || !2be $this =mysql_query();


        Comment

        • Jerry Stuckle

          #5
          Re: $_POST

          ..:[ ikciu ]:. wrote:
          Hmm kirke <hinkyeol@gmail .comwrote:
          >
          >>No, I want to receive the Enginetype(sele ct name) as $Enginetype in
          >>the same file.
          >>then I can use $sql=' ~~~~ where EngineType=$Eng inetype ';
          >
          >
          wrong idea. if you will get all rows from table then store it in session. no
          sense to do query twice. set action (on form) on the same file
          then make your cast to int and just show $allEngineTypes[$postedID] where
          you will store names
          >
          Not a good idea to store what could be thousands of rows in the session!
          A second query would be much better.

          And then if you're just looking for a single row out of thousands, MySQL
          can do it a lot faster than PHP can.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • .:[ ikciu ]:.

            #6
            Re: $_POST

            Hmm Jerry Stuckle <jstucklex@attg lobal.netwrote:
            Not a good idea to store what could be thousands of rows in the
            session! A second query would be much better.
            idea is good but the problem is we don't know how how many rows contain this
            table. this is solution for small tables


            --
            ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
            Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

            2be || !2be $this =mysql_query();


            Comment

            • Jerry Stuckle

              #7
              Re: $_POST

              ..:[ ikciu ]:. wrote:
              Hmm Jerry Stuckle <jstucklex@attg lobal.netwrote:
              >
              >>Not a good idea to store what could be thousands of rows in the
              >session! A second query would be much better.
              >
              >
              idea is good but the problem is we don't know how how many rows contain this
              table. this is solution for small tables
              >
              >
              Even then saving data in the session involves a fair amount of overhead
              serializing the data, writing to disk, etc. Plus, the data is now
              "stale" - it might have changed in the database.

              Making another query is not a significant overhead for small tables, and
              gets fresh data. It really doesn't take a lot before the MySQL query
              becomes more efficient than saving data in the session.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...