Jump to content

select pieces from checkboxess


searls03

Recommended Posts

so I need to know how to make it so that this code

<?php
session_start(); // Must start session first thing
/*
Created By Adam Khoury @ [url='http://www.flashbuilding.com/']www.flashbuilding.com[/url]
-----------------------June 20, 2008-----------------------
*/
// Here we run a login check
if (!isset($_SESSION['id'])) {
echo 'Please <a href="/login.php">log in</a> to access your account';
exit();
}
//Connect to the database through our include
include_once "connect_to_mysql.php";
// Place Session variable 'id' into local variable
$userid = $_SESSION['id'];
if (isset($_POST['submitted'])) {
include('connect1.php');
$category = "name";
$criteria = $_POST['criteria'] ;
setcookie("criteria", $criteria, time()+10);
setcookie("category", $category, time()+10);
$query = ("SELECT name, badges, rank, userid FROM members WHERE $category LIKE '%".$criteria."%'");
$result = mysqli_query($dbcon, $query) or die('error getting data');
setcookie("query12", $query, time()+10);
}
// Process the form if it is submitted
$sql = mysql_query("SELECT * FROM members WHERE userid='$userid'");
while($row = mysql_fetch_array($sql)){
$name = $row["name"];
$phone = $row["phone"];
$username = $row["username"];
$address = $row["address"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];
$cell = $row["cell"];
$email = $row["email"];
$accounttype = $row["accounttype"];
$rank = $row["rank"];
$badges = $row["badges"];
}
?>

 

will select all people from this code that are checked and will still set cookies. 

<?php    
    
    $select = mysql_query("SELECT * FROM members") or die(mysql_error());
    while ($member = mysql_fetch_array($select)) {
        echo '<input type="checkbox" name="criteria" value="'.$member[name].'">'.$member[name].'<br>';
    }
    
?>

 

I have results displaying later on and it only displays the last name checked.  please help.  I can't figure out what to use here :(

Link to comment
https://forums.phpfreaks.com/topic/246384-select-pieces-from-checkboxess/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.