Bluehost.com Web Hosting $6.95

$_POST

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-05-2006
kirke
 
Posts: n/a
Default $_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.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!

Reply With Quote
  #2 (permalink)  
Old 10-05-2006
cendrizzi
 
Posts: n/a
Default 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.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!


Reply With Quote
  #3 (permalink)  
Old 10-05-2006
kirke
 
Posts: n/a
Default Re: $_POST

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!


Reply With Quote
  #4 (permalink)  
Old 10-05-2006
.:[ ikciu ]:.
 
Posts: n/a
Default Re: $_POST

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();


Reply With Quote
  #5 (permalink)  
Old 10-05-2006
Jerry Stuckle
 
Posts: n/a
Default Re: $_POST

..:[ 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
==================
Reply With Quote
  #6 (permalink)  
Old 10-05-2006
.:[ ikciu ]:.
 
Posts: n/a
Default Re: $_POST

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();


Reply With Quote
  #7 (permalink)  
Old 10-05-2006
Jerry Stuckle
 
Posts: n/a
Default Re: $_POST

..:[ 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
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:29 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0