select multiple items from listview

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

kickerfour
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Jul 11, 2013 8:47 am

select multiple items from listview

Postby kickerfour » Thu Jul 11, 2013 8:54 am

Good morning,

I've created a listview table from a MySQL DB. I want to be able to select multiple items from the table and, eventually, save them to another DB table. Right now I'm having trouble figuring out how to create the array from the listview. I'm also not really sure where this bit of code should go. I should mention that I'm very new to PHP and HTML. Any help would be appreciated.

Below is my code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Attendance</title>
<meta name="generator" content="WYSIWYG Web Builder 9 Trial Version - http://www.wysiwygwebbuilder.com">
<style type="text/css">
body
{
   margin: 0;
   padding: 0;
   background-color: #FFFFFF;
   color: #000000;
}
</style>
<style type="text/css">
a
{
   color: #0000FF;
   text-decoration: underline;
}
a:visited
{
   color: #800080;
}
a:active
{
   color: #FF0000;
}
a:hover
{
   color: #0000FF;
   text-decoration: underline;
}
</style>
<style type="text/css">
#wb_Form1
{
   background-color: #FAFAFA;
   border: 0px #000000 solid;
}
#Combobox1
{
   border: 1px #A9A9A9 solid;
   background-color: #FFFFFF;
   color: #000000;
   font-family: Arial;
   font-size: 13px;
}
#Editbox1
{
   border: 1px #A9A9A9 solid;
   background-color: #FFFFFF;
   color :#000000;
   font-family: Arial;
   font-size: 13px;
   text-align: left;
   vertical-align: middle;
}
#Button2
{
   border: 1px #A9A9A9 solid;
   background-color: #F0F0F0;
   color: #000000;
   font-family: Arial;
   font-size: 13px;
}
</style>
</head>
<body>
<a href="http://www.wysiwygwebbuilder.com" target="_blank"><img src="images/builtwithwwb9.png" alt="WYSIWYG Web Builder" style="position:absolute;left:453px;top:735px;width:88px;height:31px;border-width:0;z-index:250"></a>
<div id="wb_Form1" style="position:absolute;left:107px;top:50px;width:269px;height:431px;z-index:4;">

<form name="Form1" method="post" action="" enctype="text/plain" id="Form1">

<input type="text" id="Editbox1" style="position:absolute;left:26px;top:32px;width:89px;height:19px;line-height:19px;z-index:0;" name="Editbox1" value="">
<select name="Listview" multiple size="17" id="Combobox1" style="position:absolute;left:30px;top:111px;width:210px;height:277px;z-index:1;">
<?php
// Create connection
$con=mysqli_connect('127.0.0.1','root','cwvm4510','maestastkd');
// Check connection
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysql_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM student_information WHERE StudentStatus = 'Active' and RankGroup = 'BB'");
  while($row = mysqli_fetch_assoc($result)){
  echo "<option value=\"{$row['StudentID']}\">{$row['StudentID']}, {$row['LastName']}, {$row['FirstName']}</option>";
}
mysqli_close($con);
?>
<input type="submit" id="Button2" name="Submit" value=Submit style="position:absolute;left:27px;top:66px;width:90px;height:25px;z-index:2;">
</form>
</div>
</body>
</html>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: select multiple items from listview

Postby johnj » Thu Jul 11, 2013 10:56 pm

The code for list view should be placed exactly at the place where you want the list view to appear.

I think $_POST['mylistview'] should help you get the listview items as an array


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests