Re: values from text boxes

From: Date: Sat, 24 Mar 2001 00:53:27 +0000
Subject: Re: values from text boxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45385@lists.php.net to get a copy of this message
> do I have to cast values from text boxes into ints? Not usually, because PHP and MySQL take care of converting for you, 99.9999% of the time. But what you get from a FORM (or a GET URL) are all strings. The HTTP spec doesn't have any way to distinguish one data type from another. It's all strings. > If so, it's wierd, because I have taken the values from text inputs > before > and just put them into insert string statements for mysql. It turned > them > into ints just fine. Actually, PHP didn't turn them into ints in that case -- MySQL did. > I use the following code to MAKE a table of input boxes on the screen, > and the exact > same thing to READ it after submission. > > the value $$vent_flow_identifier comes back with the entered value, but > as a string. I'm not finding the actual problem here... Can you pin-point it for us? > and example of the names of the INPUT boxes out and comes back is: > Vent1MinFlow > Vent1MaxFlow > Vent2FixedFlow > The '1' and the 'xxxFlow' are from columns in a set of tables. > > <code> > //$room_vent_values are a two colomn result in an array of length2 > arrays > //for the vents in a room, numbered 1..vents_in_the_room > //functions of vents are supply, return, exhaust > //A supply vent has a MaxFlow, and a MinFlow, Returns and Exhausts have > a Fixed Flow > //Those allowable flows are in $allowed_ventflowtype_values, indexed by > the > //Vent functionID > > > > while ( list( $this_vent_num, $this_vent_functionID) = each( > $room_vent_values )){ > $alt_bgcolor=""; > if ( $this_vent_num % 2 ) $alt_bgcolor = "bgcolor=\"#E69B9F\""; > // causes alternating colors in odd/even vent numbers > echo("<br>\n"); > reset( $allowed_ventflowtype_values ); > while ( $vent_function_flow_array = each( > $allowed_ventflowtype_values )){ > $flow_type_vent_functionID = $vent_function_flow_array[1][0]; > $flow_type = $vent_function_flow_array[1][1]; > if ( $this_vent_functionID == $flow_type_vent_functionID ){ > $vent_function_name = > $vent_function_values[$this_vent_functionID]; > $vent_flow_identifier = "Vent" . $this_vent_num . > $flow_type; > //start of row for output table, only the <input ...> is > entered by user > // the rest is from a database retrieval and fill in. > $flow_entry_table .= " <tr $alt_bgcolor>\n"; > $flow_entry_table .= " <td > align=\"center\">&nbsp;$this_vent_num&nbsp;</td>\n"; > $flow_entry_table .= " <td > align=\"center\">&nbsp;$vent_function_name&nbsp;</td>\n"; > $flow_entry_table .= " <td > align=\"center\">&nbsp;$flow_type&nbsp;</td>\n"; > $flow_entry_table .= " <td > align=\"center\">&nbsp;<INPUT > type=\"text\" name =\"$vent_flow_identifier\" > size=\"5\">&nbsp;</td>\n"; > $flow_entry_table .= " </tr>\n"; > } > } > } > </end_code> > > The form that this makes, and later tests the results of looks like: > <html out>------------ > <form name="Entry" > action="FlowReadingsEntryTable.php" > method="POST"> > <INPUT type="hidden" name="FlowDataSubmitted" value="1"> > <!--name of > event submission of this table results in--> > <INPUT type="hidden" name="PurvineRoomID" value="1"> > <!--relevant room > passed through from prevouos form--> > <INPUT type="submit" value="Send This Puppy"> > <table BORDER="0" CELLSPACING="0" COLS="4" > width="100" > BGCOLOR="#FF5c5c"> > <tr><!-- THIS ROW sets column widths --> > <td WIDTH="85" height="0"></td> > <td WIDTH="85" height="0"></td> > <td WIDTH="85" height="0"></td> > <td WIDTH="85" height="0"></td> > </tr> > <!-- Heading Row --> > <tr> > <td colspan="4" align="center" nowrap><b><b>Enter > Flow For Each > Vent<br>And Appropriate Flow Type<br>Date will be The Current > Date/Time</b><br>&nbsp;</td> > </tr> > <tr> > <td align="left" > colspan="4">PurvineRoom<br>Designation&nbsp;</td> > </tr> > <tr> > <td align="left" colspan="4"> > <b>101</b><br>&nbsp; </td> > </tr> > <tr valign"bottom"> > <td align="center">&nbsp;Vent<br>Num&nbsp;</td> > <td align="center">&nbsp;Vent<br>Function&nbsp;</td> > <td align="center">&nbsp;Flow<br>Type&nbsp;</td> > <td align="center">&nbsp;Flow<br>Value&nbsp;</td> > </tr> > <tr bgcolor="#E69B9F"> > <td align="center">&nbsp;1&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MinFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent1MinFlow" > size="5">&nbsp;</td> > </tr> > <tr bgcolor="#E69B9F"> > <td align="center">&nbsp;1&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MaxFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent1MaxFlow" > size="5">&nbsp;</td> > </tr> > <tr > > <td align="center">&nbsp;2&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MinFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent2MinFlow" > size="5">&nbsp;</td> > </tr> > <tr > > <td align="center">&nbsp;2&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MaxFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent2MaxFlow" > size="5">&nbsp;</td> > </tr> > <tr bgcolor="#E69B9F"> > <td align="center">&nbsp;3&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MinFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent3MinFlow" > size="5">&nbsp;</td> > </tr> > <tr bgcolor="#E69B9F"> > <td align="center">&nbsp;3&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MaxFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent3MaxFlow" > size="5">&nbsp;</td> > </tr> > <tr > > <td align="center">&nbsp;4&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MinFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent4MinFlow" > size="5">&nbsp;</td> > </tr> > <tr > > <td align="center">&nbsp;4&nbsp;</td> > <td align="center">&nbsp;Supply&nbsp;</td> > <td align="center">&nbsp;MaxFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent4MaxFlow" > size="5">&nbsp;</td> > </tr> > <tr bgcolor="#E69B9F"> > <td align="center">&nbsp;5&nbsp;</td> > <td align="center">&nbsp;Return&nbsp;</td> > <td align="center">&nbsp;FixedFlow&nbsp;</td> > <td align="center">&nbsp;<INPUT type="text" name > ="Vent5FixedFlow" > size="5">&nbsp;</td> > </tr> > > </table> > </form> > </html out>----------- > -- > ________________________________________________________________ > Sites by friends of mine: http://www.myhiddentreasures.com/ > ________________________________________________________________ > WARNING personal propaganda signature > TAKE WHAT YOU LIKE AND LEAVE THE REST > > SINCE OUR GOVERNMENT WON'T PRESERVE OUR CLIMATE, IT'S UP TO US! > Imagine ** yourself ** and your kids now an endangered species > <1>Inflate automobile tires to near maximum in summer, -2psi in winter > <2>add insulation to house and hot water heater, and refrigerator, > <3>combine trips in cars, make less of them <4>buy cars, sports > vehicles and recreational vehicles with good if not best mileage > <4>put awnings over windows is summer, remove in winter. <5> add > solar hot water heating. <6>Push for energy recycling clothes > dryers <7> walk more, play outside with your kids! <8> let your > grass grow to 3-4 inches, chokes weeds, saves water and energy, > keeps house cooler <9> Put WHITE or REFLECTIVE materials on > roofs to send energy back into space. <10> Vote for burial of > logging slash onsite in logging areas for better watersheds > and less burned vegetation. <11> compost your leaves and grass, > bury in flower beds, lawns, gardens, or give away. <12> VOTE > for energy and CO2 ratings on ALL products and foods. KNOW how > much damage your purchases do to the climate. <13> Give your kids > less stuff and more of you. <14> recycle everything you can <15> > limit your children to an average 1 per adult between all your > marriages. (Only REPLACE yourself, not expand the population) > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#45385) next »