parametr

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

parametr

Post by hrubos »

How to do if I back a previous page, I will have a parametr,which was chosen by me.
example here :
file1.php

Code: Select all

echo "<form action='file2.php' method='POST'>";
for($i=0;$i<rows;$i++)
echo "<td><input type='radio' name='id' value='$id'>$id</td>";
echo "<tr><td><input type='submit' name='chose' value='Chose'></td></tr>";
}
file2.php

Code: Select all

$id=$_POST['id'];

if($id){
echo '<table><tr><td>$id<td></tr></table>';
echo "<input type='submit' name='chose' value='Send'></td></tr>";
}
else {
 
 echo '<a href="file1.php">back</a>' ;//  I have problem here, when I back, I have new table but I want a table with chosen button.
}
paresh
Forum Newbie
Posts: 6
Joined: Mon Oct 09, 2006 3:46 am
Contact:

Post by paresh »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


MODIFY your file1.php as this

Code: Select all

echo "<form action='file2.php' method='POST'>";
for($i=0;$i<rows;$i++)
     echo "<td>";
        if( $_GET['idByGetMethod'] == $id ) 
           echo "<input type='radio' name='id' value='$id' checked=\"checked\">$id</td>";
        else 
            echo "<input type='radio' name='id' value='$id'>$id</td>";

     echo "<tr><td><input type='submit' name='chose' value='Chose'></td></tr>";
}

This will your file2.php

Code: Select all

$id=$_POST['id'];

if($id){
echo '<table><tr><td>$id<td></tr></table>';
echo "<input type='submit' name='chose' value='Send'></td></tr>";
}
else {
 
 echo '<a href="file1.php?idByGetMethod=<?= $id ?>">back</a>' ;

Please try out.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply