Jump to content

Print Array from Checkbox


lwaters5

Recommended Posts

HI, I am a newbie using Dreamweaver to create a form that has a checbox next to students's names. Once you select the student's you wish to see, you hit submit and it sends you to anther page where it displays the profiles for each of these students so they can be printed. My form looks like this:

 

<form id="form1" name="form1" method="post" action="test4.php">

<?php do { ?>

<p>

<input name="UID[]" type="checkbox" id="UID" value="<?php echo $row_applicants['UID']; ?>" />

<label for="UID"></label>

<?php echo $row_applicants['FNAME']; ?> <?php echo $row_applicants['LNAME']; ?> </p>

<?php } while ($row_applicants = mysql_fetch_assoc($applicants)); ?>

<p>

<input type="submit" name="button" id="button" value="Submit" />

</p>

</form>

 

My test results page looks like this:

 

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$UID = $_POST['UID'];
$query = "SELECT * FROM users WHERE UID = ('$UID')";
$results = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($results)==1){ // If there is only one row that was returned
$results = mysql_fetch_array($results);
echo $results['UID']; // If the column name is incorrect, just change it to match
}elseif(mysql_num_rows($results)>1){ // If there is more than one row that was returned
while($result=mysql_fetch_array($results)){ // Loop through each row that was returned and display it
echo $result['UID']."
";
}
}else{ //If there were no rows returned, this is just to account for every option and is entirely optional
echo "No matched!";
}

 

I want the end result page to look like the attached file with multiple profiles.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/273193-print-array-from-checkbox/
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.