This is a discussion on $_POST within the PHP Language forums, part of the PHP Programming Forums category; Hi. I'm a real beginner of PHP. So if my question is so stupid, plz understand me. Thx. I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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.php"> <table > <tr> <select name="EngineType" id="EngineType"> <?php require('conf.php') dbconnect(); $sql = 'SELECT * FROM dbo_EngineType; $result = mysql_query($sql) or die(); while( $row = mysql_fetch_array($result) ) { echo '<option value="'.$row['iID'].'">'.strtoupper($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! |
|
|||
|
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.com> wrote: > 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.php"> > <table > > <tr> > <select name="EngineType" id="EngineType"> > > <?php > require('conf.php') > dbconnect(); > $sql = 'SELECT * FROM dbo_EngineType; > $result = mysql_query($sql) or die(); > > while( $row = mysql_fetch_array($result) ) > { > echo '<option > value="'.$row['iID'].'">'.strtoupper($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! |
|
|||
|
No, I want to receive the Enginetype(select name) as $Enginetype in the
same file. then I can use $sql=' ~~~~ where EngineType=$Enginetype '; 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.com> wrote: > > 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.php"> > > <table > > > <tr> > > <select name="EngineType" id="EngineType"> > > > > <?php > > require('conf.php') > > dbconnect(); > > $sql = 'SELECT * FROM dbo_EngineType; > > $result = mysql_query($sql) or die(); > > > > while( $row = mysql_fetch_array($result) ) > > { > > echo '<option > > value="'.$row['iID'].'">'.strtoupper($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! |
|
|||
|
Hmm kirke <hinkyeol@gmail.com> wrote:
> No, I want to receive the Enginetype(select name) as $Enginetype in > the same file. > then I can use $sql=' ~~~~ where EngineType=$Enginetype '; 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(); |
|
|||
|
..:[ ikciu ]:. wrote:
> Hmm kirke <hinkyeol@gmail.com> wrote: > >>No, I want to receive the Enginetype(select name) as $Enginetype in >>the same file. >>then I can use $sql=' ~~~~ where EngineType=$Enginetype '; > > > 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@attglobal.net ================== |
|
|||
|
Hmm Jerry Stuckle <jstucklex@attglobal.net> wrote:
> 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(); |
|
|||
|
..:[ ikciu ]:. wrote:
> Hmm Jerry Stuckle <jstucklex@attglobal.net> wrote: > >>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@attglobal.net ================== |