PDA

View Full Version : How to display the selected checkbox on the new site?


badziol1
08-18-2013, 08:15 AM
Welcome.
I've created a table with downloading users and I want to when you select the check box that you selected userzy shown on a new page. How to do it? Please help me.
* Here is the code

<?php require_once('../Connections/myconn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_myconn, $myconn);
$query_Recordset1 = "SELECT user_id, firstname, lastname, username FROM userlogin";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $myconn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<form action="phplist.php" method="get">
<table width="200" border="1" align="center">
<tr>
<td>Oznacz</td>
<td>ID</td>
<td>Imie</td>
<td>Nazwisko</td>
<td>Nick</td>
</tr>
<?php do { ?>
<tr>
<td><input name="checkbox" type="checkbox" id="checkbox" value="<?php echo $row_Recordset1['user_id']; ?>">
<label for="checkbox"></label></td>
<td><?php echo $row_Recordset1['user_id']; ?></td>
<td><?php echo $row_Recordset1['firstname']; ?></td>
<td><?php echo $row_Recordset1['lastname']; ?></td>
<td><?php echo $row_Recordset1['username']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<input type="submit" name="button" id="button" value="Edit">
<input type="hidden" name="hiddenField" id="hiddenField">
</form>
<?php
mysql_free_result($Recordset1);
?>

edbr
08-20-2013, 02:38 AM
on submit they will be directed in this case to phplist.php.
I would on that page use it to select the correct data.
I would use $_POST rather than get
then use $_POST[' whatever'] (what ever the value is in reality)
match it to your database or redirect to maybe a registration page if not in the database

edbr
08-20-2013, 03:42 AM
another point , using a checkbox like you do , will mean upon need to get in to arrays, so you might want to re think that approach