I am working of a musicians volunteer DB. I have a ADD Volunteer page:
<?php
require_once('auth.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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Village Of Hope Worship</title>
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
}
.style3 {
font-size: 12px;
font-weight: bold;
font-style: italic;
}
.style5 {
font-size: 10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #0000FF;
}
-->
</style>
</head>
<body>
<table width="505" border="0" align="center" cellpadding="2" cellspacing="2">
<tr align="center" valign="middle">
<td height="42" colspan="2"><div align="center" class="style1">New Volunteer Entry
</div></td>
</tr>
<tr>
<td width="348"><span class="style3"><a href="volunteers_list.php">Back to LIST</a> </span></td>
<td width="143" align="center" valign="middle"><div align="center">
<form id="form1" name="form1" method="post" action="volunteers_list_add.php">
<input type="reset" name="Reset" value="Reset" />
<input name="Submit" type="submit" id="Submit" value="SAVE" />
</div></td>
</tr>
</table>
<br />
<table width="504" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="91"><div align="right">
<label>First Name: </label>
</div></td>
<td colspan="2"><input name="First_Name" type="text" id="First_Name" maxlength="25" /></td>
</tr>
<tr>
<td><div align="right">
<label>Last Name:</label>
</div></td>
<td colspan="2"><input name="Last_Name" type="text" id="Last_Name" size="42" maxlength="35" /></td>
</tr>
<tr>
<td><div align="right">
<label>Email:</label>
</div></td>
<td colspan="2"><input name="Email" type="text" id="Email" size="42" maxlength="60" /></td>
</tr>
<tr>
<td><div align="right">
<label>Contact Phone:</label>
</div></td>
<td colspan="2"><input name="Contact_Phone" type="text" id="Contact_Phone" maxlength="20" /></td>
</tr>
<tr>
<td><div align="right">
<label>Address:</label>
</div></td>
<td colspan="2"><input name="Address" type="text" id="Address" size="42" maxlength="60" /></td>
</tr>
<tr>
<td><div align="right">
<label>City/St/Zip:</label>
</div></td>
<td colspan="2"><input name="City" type="text" id="City" maxlength="30" />
<input name="State" type="text" id="State" size="3" maxlength="2" />
<input name="Zip" type="text" id="Zip" size="12" maxlength="10" /></td>
</tr>
<tr>
<td> <div align="right">
<label>Username:</label>
</div></td>
<td colspan="2"><input name="Username" type="text" id="Username" maxlength="20" /></td>
</tr>
<tr>
<td><div align="right">Password:</div></td>
<td colspan="2"><input name="Password" type="text" id="Password" maxlength="20" /></td>
</tr>
<tr>
<td><div align="right">ADMIN:</div></td>
<td colspan="2"><input name="ADMIN" type="text" id="ADMIN" maxlength="2" /></td>
</tr>
<tr>
<td><div align="right">Instruments:</div></td>
<td width="116" align="center" valign="middle">
<div align="left">
<select name="Instrument" size="5" multiple="multiple" id="Instrument">
<option>Select from the list below...</option>
<option value="Leader">Leader</option>
<option value="Singer">Singer</option>
<option value="Piano">Piano</option>
<option value="Synth">Synth</option>
<option value="Acoustic Guitar">Acoustic Guitar</option>
<option value="Electric Guitar">Electric Guitar</option>
<option value="Bass Guitar">Bass Guitar</option>
<option value="Drums">Drums</option>
<option value="Percussion">Percussion</option>
<option value="Sax/Horn">Sax/Horn</option>
<option value="Flute">Flute</option>
</select>
</div></td>
<td width="277" align="center" valign="middle"><div align="left"><span class="style5">To select multiple, hold down your <br />
Command Key (MAC) or ALT (PC)</span></div></td>
</tr>
<tr>
<td><div align="right">Special Notes: </div></td>
<td colspan="2"><textarea name="Notes" cols="40" rows="4" id="Notes"></textarea></td>
</tr>
</table>
</form>
</body>
</html>
Then I target a page that does the ADD:
<?php
// -- Add a record --
ServerConnect();
DB_Connect();
// Get values from form.
$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Email=$_POST['Email'];
$Contact_Phone=$_POST['Contact_Phone'];
$Address=$_POST['Address'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip=$_POST['Zip'];
$Username=$_POST['Username'];
$Password=$_POST['Password'];
$ADMIN=$_POST['ADMIN'];
$Instrument=$_POST['Instrument'];
$Notes=$_POST['Notes'];
$sql="INSERT INTO Volunteers (First_Name, Last_Name, Email, Contact_Phone, Address, City, State, Zip, Username, Password, ADMIN, Instrument, Notes) VALUES ('$First_Name','$Last_Name','$Email','$Contact_Phone','$Address','$City','$State','$Zip','$Username','$Password','$ADMIN','$Instrument','$Notes')";
$result = mysql_query($sql) or die(mysql_error());
echo "<span class=\"style2\">Volunteer Added...</span>";
?>
I, also, have a EDIT Volunteer page:
<?php
require_once('auth.php');
?>
<?
include("inc/interface.php");
include("inc/funct.php");
?>
<?php
// -- Add a record --
ServerConnect();
DB_Connect();
$id=$_GET['id'];
$result=mysql_query("select * from Volunteers where id='$id'");
$row=mysql_fetch_assoc($result);
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Village Of Hope Worship</title>
<style type="text/css">
<!--
.style1 {
font-size: 24px;
font-weight: bold;
}
.style3 {
font-size: 12px;
font-weight: bold;
font-style: italic;
}
.style5 {
font-size: 10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #0000FF;
}
-->
</style>
</head>
<body>
<table width="505" border="0" align="center" cellpadding="2" cellspacing="2">
<tr align="center" valign="middle">
<td height="42" colspan="2"><div align="center" class="style1">Edit Volunteer Entry
</div></td>
</tr>
<tr>
<td width="348"><span class="style3"><a href="volunteers_list.php">Back to LIST</a> </span></td>
<td width="143" align="center" valign="middle"><div align="center">
<form id="form1" name="form1" method="post" action="volunteers_list_update.php">
<input type="reset" name="Reset" value="Reset" />
<input name="Submit" type="submit" id="Submit" value="SAVE" />
</div></td>
</tr>
<input type="hidden" name="id" value="<? echo $row['id']; ?>">
</table>
<br />
<table width="504" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="91"><div align="right">
<label>First Name: </label>
</div></td>
<td colspan="2"><input name="First_Name" type="text" id="First_Name" value="<? echo $row['First_Name']; ?>" maxlength="25" /></td>
</tr>
<tr>
<td><div align="right">
<label>Last Name:</label>
</div></td>
<td colspan="2"><input name="Last_Name" type="text" id="Last_Name" size="42" value="<? echo $row['Last_Name']; ?>" maxlength="35" /></td>
</tr>
<tr>
<td><div align="right">
<label>Email:</label>
</div></td>
<td colspan="2"><input name="Email" type="text" id="Email" size="42" value="<? echo $row['Email']; ?>" maxlength="60" /></td>
</tr>
<tr>
<td><div align="right">
<label>Contact Phone:</label>
</div></td>
<td colspan="2"><input name="Contact_Phone" type="text" id="Contact_Phone"value="<? echo $row['Contact_Phone']; ?>" maxlength="20" /></td>
</tr>
<tr>
<td><div align="right">
<label>Address:</label>
</div></td>
<td colspan="2"><input name="Address" type="text" id="Address" value="<? echo $row['Address']; ?>" size="42" maxlength="60" /></td>
</tr>
<tr>
<td><div align="right">
<label>City/St/Zip:</label>
</div></td>
<td colspan="2"><input name="City" type="text" id="City" value="<? echo $row['City']; ?>" maxlength="30" />
<input name="State" type="text" id="State" size="3" value="<? echo $row['State']; ?>" maxlength="2" />
<input name="Zip" type="text" id="Zip" size="12" value="<? echo $row['Zip']; ?>" maxlength="10" /></td>
</tr>
<tr>
<td> <div align="right">
<label>Username:</label>
</div></td>
<td colspan="2"><input name="Username" type="text" id="Username" value="<? echo $row['Username']; ?>" maxlength="20" /></td>
</tr>
<tr>
<td><div align="right">Password:</div></td>
<td colspan="2"><input name="Password" type="text" id="Password" value="<? echo $row['Password']; ?>" maxlength="20" /></td>
</tr>
<tr>
<td><div align="right">ADMIN:</div></td>
<td colspan="2"><input name="ADMIN" type="text" id="ADMIN" value="<? echo $row['ADMIN']; ?>" maxlength="2" /></td>
</tr>
<tr>
<td><div align="right">Instruments:</div></td>
<td width="116" align="center" valign="middle">
<div align="left">
<select name="Instrument" size="5" multiple="multiple" id="Instrument">
<option>Select from the list below...</option>
<option value="Leader">Leader</option>
<option value="Singer">Singer</option>
<option value="Piano">Piano</option>
<option value="Synth">Synth</option>
<option value="Acoustic Guitar">Acoustic Guitar</option>
<option value="Electric Guitar">Electric Guitar</option>
<option value="Bass Guitar">Bass Guitar</option>
<option value="Drums">Drums</option>
<option value="Percussion">Percussion</option>
<option value="Sax/Horn">Sax/Horn</option>
<option value="Flute">Flute</option>
</select>
</div></td>
<td width="277" align="center" valign="middle"><div align="left"><span class="style5">To select multiple, hold down your <br />
Command Key (MAC) or ALT (PC)</span></div></td>
</tr>
<tr>
<td><div align="right">Special Notes: </div></td>
<td colspan="2"><textarea name="Notes" cols="40" rows="4" id="Notes" value="<? echo $row['Notes']; ?>" ></textarea></td>
</tr>
</table>
</form>
</body>
</html>
Then I target a page that does the UPDATE:
<?php
// -- Update a record --
ServerConnect();
DB_Connect();
// Get values from form.
$id=$_POST['id'];
$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Email=$_POST['Email'];
$Contact_Phone=$_POST['Contact_Phone'];
$Address=$_POST['Address'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip=$_POST['Zip'];
$Username=$_POST['Username'];
$Password=$_POST['Password'];
$ADMIN=$_POST['ADMIN'];
$Instrument=$_POST['Instrument'];
$Notes=$_POST['Notes'];
$sql="UPDATE Volunteers SET First_Name='$First_Name', Last_Name='$Last_Name', Email='$Email', Contact_Phone='$Contact_Phone', Address='$Address', City='$City', State='$State', Zip='$Zip', Username='$Username', Password='$Password', ADMIN='$ADMIN', Instrument='$Instrument', Notes='$Notes' WHERE id='$id'";
//echo "$sql";
$result = mysql_query($sql) or die(mysql_error());
echo "<span class=\"style2\">Volunteer Updated...</span>";
?>
Three issues I need help to resolve:
1) When I select more then one choice from my Instrument field, then select the ADD button, the multiple selections do not carry over to my mySQL table record. Only one value does. The field is a varchar type with plenty of characters allowed.
2) Once I get the data into my DB properly, I need to then be able to have it display properly when I retrieve it on my Update Volunteer Entry page.
3) Eventually, I will establish a Performance Date table in which I will assign Volunteers to performances. When I add a Volunteer:
IF they have multiple instruments they play, I would to provide the user a menu of choices for the field, based of the field Volunteer::Instrument
ELSE
Display it this way: Instrument - Piano
END IF
On a personal note, this is a online DB I am working on for the local Rescue Mission (Homeless Shelter Program). This is my first PHP/mySQL project, so I got much to learn. But once I see how things are done, I catch on pretty quickly.
If there is anyone who would like to volunteer their services to assist me in finishing this project for them, I could make sure you get a Letter of Donated Services from the the Non-Profit organization(tax right off). Just give me a PRIVATE message, if you are willing to help.
Thanks and I appreciate any help that can be offered.