Hello to everyone, Could you help me or suggest how to do it: my idea is to show data on other page after clicking the button. Till now i have done is printing a table which has data taken from database. Every row in the end has a button, then this button is pressed i want to take all information in this row and show it in other page. Example: if i choose row number 3, all data from that row has to be printed in other page. Can you suggest or show how to do it? This is my code: <? session_start(); include ("db.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untiteled</title> <link href="style.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <table width="900" border="0" cellpadding="0" cellspacing="0" class="rem"> <tr> <td> <?php if ($_SESSION['username']) echo "Hello, ".$_SESSION['username']."!<br><a href='logout'>Logout</a>"; else echo "You have to <a href='index.php'>log in</a>"; $result = mysql_query("select * from user"); $myrow = mysql_fetch_array ($result); do { printf("<table width='900' border='0' cellpadding='0' cellspacing='0' class='rem'> <tr> <td> </td> </tr> <tr> <td> <table class='tam' width='900' border='0' cellspacing='0' cellpadding='0'> <tr> <td>Number</td> <td>Name</td> <td>Last Name</td> <td>Email</td> </tr> </table></td> </tr> <tr> <td><table width='900' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='92'>%s</td> <td width='342'>%s</td> <td width='157'>%s</td> <td width='179'>%s</td> <td><input type='submit' value='Send' action='' ></td> </tr> </table></td>", $myrow['id'],$myrow['name'],$myrow['lname'],$myrow['mail']); } while ($myrow = mysql_fetch_array ($result)); ?> </tr> </table> </body> </html> Code (markup): Thanks for help
The easy way is to pass id to the next page, for example, the button can linked to send.php?id=xx where the id is the selected user unique id. Then the page retrieve the id and select the correct user database.
<input type="hidden" name="first_name" value="<?php echo $myrow['first_name']; ?>" > You'd be putting the values of each row into hidden fields that dont show on HTML page. Make your button so that its active as an HTML form, use action="post" on the form's action attribute. On your next page convert to variables. example: $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; etc .. You'll be passing the variables in all those rows on your table page .. through hiddden fields because the data will be echoed as those hidden field values in php.