Hi I have th efollowind code and I dont know how to pass the variable... meaning that when i press the submit1 button, a value is given to $current and I want to reuse it later when I press submit2 but the $current no longer exists... how would i pass the variable ??
thx
<?php
if ($submit1){
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result=mysql_query("SELECT * FROM demande_action WHERE id=$id",$db);
$current = mysql_result($result,0,"id");
}
if($submit2){
$variable = $current +1;
}
Passing of variables... :S
Moderators: egami, macek, gesf
- Joan Garnet
- Moderator
- Posts: 387
- Joined: Sat Aug 03, 2002 2:56 am
- Location: Mars
- Contact:
When you press the submit button you re-send the form, and if there's no data in the field you won't pass anything.
If you want to keep the value use a link and send the variable via GET with a URL.
If you want to keep the value use a link and send the variable via GET with a URL.
Code: Select all
<?php
//this one comes from a form
if ($HTTP_POST_VARS["submit1"]){
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result=mysql_query("SELECT * FROM demande_action WHERE id=$id",$db);
$current = mysql_result($result,0,"id");
echo "<a href='".$php_self."?my_variable=".$current."'>press</a>";
}
//this one comes from the link
if($HTTP_GET_VARS["my_variable"]);
$variable = $HTTP_GET_VARS["my_variable"] +1;
}
?>