Page 1 of 1

2 Very stupid questions

Posted: Mon Mar 24, 2003 9:05 am
by Igguana
The result from this code is always 5 (whenever U click over the link)
why it doesn't grow on five to five (10, 15, 20, 25, 30)
How to do it? :oops:
<html>
<body>
<?
$numero=($herencia+$incremento);
echo "$numero";
?>
<a href="suma.php?incremento=5?herencia=<? echo "$numero"; ?>">add</a>
</body>
</html>

Posted: Mon Mar 24, 2003 9:18 am
by twigletmac
Read this:
viewtopic.php?t=511

and try this:

Code: Select all

<html> 
<body> 
<?php 
$herencia = (!empty($_GET['herencia']) && is_numeric($_GET['herencia'])) ? $_GET['herencia'] : 0;
$incremento = (!empty($_GET['incremento'])) ? $_GET['incremento'] : 5;

$numero = $herencia + $incremento; 
echo $numero; 
?> 
<a href="suma.php?incremento=5&herencia=<?php echo $numero; ?>">add</a> 
</body> 
</html>
You may also need to read:
http://www.php.net/empty
http://www.php.net/is_numeric
http://www.php.net/manual/en/language.o ... arison.php

Mac