Outline ·
[ Standard ] ·
Linear+
How to do pass value and calculate in PHP?, Help!!!
TSCGLegacy
|
Mar 25 2006, 01:16 AM, updated 17y ago
|
|
hi... how to pass value... let's say number or string from one php page to another??? like.. when i press the submit button... the value which i inserted will be passed to the second page to continue with the operation let's say... calculate the number with certain formula??? plez... pros help...!!!
|
|
|
|
TSCGLegacy
|
Mar 25 2006, 01:48 AM
|
|
dont understand a thing lah dude...
|
|
|
|
hydrowire
|
Mar 25 2006, 01:57 AM
|
Getting Started
|
use session. http://www.tizag.com/phpT/phpsessions.phpor use post n get if you are using form. CODE $myvar = $_POST['mynum']; or CODE $myvar = $_GET['mynum']; gd luck. This post has been edited by hydrowire: Mar 25 2006, 01:57 AM
|
|
|
|
TSCGLegacy
|
Mar 25 2006, 02:38 AM
|
|
may i know where to put that code... before the html tag or inside the html code???
|
|
|
|
nxfx
|
Mar 25 2006, 08:30 AM
|
|
You can easily pass value tru form. But if you dont understand how php or scripting works then you have to learn about it first.
|
|
|
|
phantomd
|
Mar 25 2006, 09:35 AM
|
Getting Started
|
Few methods, 1. Use Hidden forms 2. Use Cookies 3. Use Session Words for you, if you really want to be a developer/programmer/se: RTFM
|
|
|
|
TSCGLegacy
|
Mar 25 2006, 08:23 PM
|
|
ok... i already got the pass value and math solved.... now i have a new problem...
how to loop a text box according to what i want using phpcode.... for example i can loop how many rows i want to loop in a table... let's say i want to loop it 4 times... so there will be four rows generated.... now... what i want is... i want to insert input boxes.... (text boxes) into those rows.... so how am i supposed to do it...??? thanks in advance...
|
|
|
|
hydrowire
|
Mar 25 2006, 10:23 PM
|
Getting Started
|
i doubt any1 will understand wat u trying to do.
i suggest u draw a simple diagram(of text boxes?).
|
|
|
|
firewire
|
Mar 25 2006, 11:40 PM
|
|
QUOTE(CGLegacy @ Mar 25 2006, 08:23 PM) how to loop a text box according to what i want using phpcode.... for example i can loop how many rows i want to loop in a table... let's say i want to loop it 4 times... so there will be four rows generated.... now... what i want is... i want to insert input boxes.... (text boxes) into those rows.... so how am i supposed to do it...??? thanks in advance... use the for loop Reference : http://my2.php.net/manual/en/control-structures.for.php
|
|
|
|
silverhawk
|
Mar 26 2006, 01:14 AM
|
I'm Positively Lustrous
|
QUOTE(CGLegacy @ Mar 25 2006, 08:23 PM) ok... i already got the pass value and math solved.... now i have a new problem... how to loop a text box according to what i want using phpcode.... for example i can loop how many rows i want to loop in a table... let's say i want to loop it 4 times... so there will be four rows generated.... now... what i want is... i want to insert input boxes.... (text boxes) into those rows.... so how am i supposed to do it...??? thanks in advance... Use an array... you can do this by naming the inputs like so CODE <input type="text" name="message[]" />
notice the "[]" at the end of the name. That denotes an array. Then you can loop through it in PHP
|
|
|
|
virtual
|
Mar 26 2006, 07:15 AM
|
|
QUOTE(CGLegacy @ Mar 25 2006, 08:23 PM) ok... i already got the pass value and math solved.... now i have a new problem... how to loop a text box according to what i want using phpcode.... for example i can loop how many rows i want to loop in a table... let's say i want to loop it 4 times... so there will be four rows generated.... now... what i want is... i want to insert input boxes.... (text boxes) into those rows.... so how am i supposed to do it...??? thanks in advance... Boy.. i understand what you wanna do but please read a book lah. Anyway, i'll give a hint. Let's say, you want to create a dynamic number of options of a selection box. Your code should be like this... CODE <select ...> <?php for () { echo "<option>$blabla</option><br>\r\n"; } ?> </select> How many options presented in your html depends on your for loop now.
|
|
|
|
TSCGLegacy
|
Mar 27 2006, 10:30 PM
|
|
hmmm... guys thanks for all the help till now.... i succeded using the POST method... now... for example i get a value of 12345678... how can i just choose the 4 middle numbers which is 3456 and use it too calculate my next step??? and if the previous number is only 7 digits, how can i insert a "Zero" in front of the numbers (for example: 04455667)... so that there will be always be 8 digits in a group of numbers....???
This post has been edited by CGLegacy: Mar 27 2006, 11:10 PM
|
|
|
|
crynobone
|
Mar 28 2006, 10:24 AM
|
|
QUOTE(CGLegacy @ Mar 27 2006, 10:30 PM) hmmm... guys thanks for all the help till now.... i succeded using the POST method... now... for example i get a value of 12345678... how can i just choose the 4 middle numbers which is 3456 and use it too calculate my next step??? and if the previous number is only 7 digits, how can i insert a "Zero" in front of the numbers (for example: 04455667)... so that there will be always be 8 digits in a group of numbers....??? Learn this code CODE <?php $the_var = 12345678; $the_var .= ""; //convert to str. $x = (8 - strlen($the_var)); for(;$x > 0;$x--) : $the_var = "0".$the_var; endfor; print $the_var; $new_var = substr($the_var, 2, 4); print "<br />".$new_var; ?>
|
|
|
|
tcs
|
Mar 28 2006, 04:31 PM
|
|
learn regular expression, u will appreaciate it powerfulness
|
|
|
|
TSCGLegacy
|
Mar 28 2006, 04:48 PM
|
|
thanks a lot man.... wow... that code has really helped me a lot.... my simulation project is almost done now....
Added on October 31, 2007, 2:12 pmthanks... now ive done my final year project also using php... thank you all after more than 1 year....
This post has been edited by CGLegacy: Oct 31 2007, 02:12 PM
|
|
|
|