Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 How to do pass value and calculate in PHP?, Help!!!

views
     
TSCGLegacy
post Mar 25 2006, 01:16 AM, updated 17y ago

Buka Sos
*******
Senior Member
2,109 posts

Joined: Jan 2003
From: ~Ipoh Mali, Ipoh, Ipoh Mali~



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...!!!
lokem
post Mar 25 2006, 01:18 AM

Getting Started
**
Junior Member
76 posts

Joined: Jan 2003
I suggest you take a look at this:

http://www.php.net/manual/en/language.variables.php
TSCGLegacy
post Mar 25 2006, 01:48 AM

Buka Sos
*******
Senior Member
2,109 posts

Joined: Jan 2003
From: ~Ipoh Mali, Ipoh, Ipoh Mali~



dont understand a thing lah dude...
hydrowire
post Mar 25 2006, 01:57 AM

Getting Started
**
Junior Member
53 posts

Joined: Oct 2004
From: PJ,KL


use session.
http://www.tizag.com/phpT/phpsessions.php

or 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
post Mar 25 2006, 02:38 AM

Buka Sos
*******
Senior Member
2,109 posts

Joined: Jan 2003
From: ~Ipoh Mali, Ipoh, Ipoh Mali~



may i know where to put that code... before the html tag or inside the html code???
nxfx
post Mar 25 2006, 08:30 AM

Enthusiast
*****
Senior Member
979 posts

Joined: Jan 2003


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
post Mar 25 2006, 09:35 AM

Getting Started
**
Junior Member
135 posts

Joined: Jan 2003


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
post Mar 25 2006, 08:23 PM

Buka Sos
*******
Senior Member
2,109 posts

Joined: Jan 2003
From: ~Ipoh Mali, Ipoh, Ipoh Mali~



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
post Mar 25 2006, 10:23 PM

Getting Started
**
Junior Member
53 posts

Joined: Oct 2004
From: PJ,KL


i doubt any1 will understand wat u trying to do.

i suggest u draw a simple diagram(of text boxes?).
firewire
post Mar 25 2006, 11:40 PM

Enthusiast
*****
Senior Member
785 posts

Joined: Jan 2003
From: http://sewnstitches.blogspot.com/
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 smile.gif

Reference : http://my2.php.net/manual/en/control-structures.for.php
silverhawk
post Mar 26 2006, 01:14 AM

I'm Positively Lustrous
Group Icon
Elite
4,735 posts

Joined: Jan 2003


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
post Mar 26 2006, 07:15 AM

Casual
***
Junior Member
329 posts

Joined: Jan 2006
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
post Mar 27 2006, 10:30 PM

Buka Sos
*******
Senior Member
2,109 posts

Joined: Jan 2003
From: ~Ipoh Mali, Ipoh, Ipoh Mali~



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
post Mar 28 2006, 10:24 AM

1'm n0t @ n00b n0t y3t @ 1337
*******
Senior Member
2,811 posts

Joined: Jan 2003
From: Somewhere in middle earth


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
post Mar 28 2006, 04:31 PM

He's so good i just can't think of a caption
*******
Senior Member
4,637 posts

Joined: Jan 2003
From: Where i come from?



learn regular expression, u will appreaciate it powerfulness tongue.gif
TSCGLegacy
post Mar 28 2006, 04:48 PM

Buka Sos
*******
Senior Member
2,109 posts

Joined: Jan 2003
From: ~Ipoh Mali, Ipoh, Ipoh Mali~



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

 

Change to:
| Lo-Fi Version
0.0146sec    0.43    5 queries    GZIP Disabled
Time is now: 28th March 2024 - 05:43 PM