Hi,

I am trying to compile a detail page. Here is the code below:

<?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">
<!--
.style13 {
	font-size: 12px;
	color: #70283C;
	font-weight: bold;
}
.style14 {
	font-size: 12px;
	font-weight: bold;
}
.style15 {
	color: #000000;
	font-weight: bold;
}
.style17 {
	font-size: 12px;
	color: #884D5E;
}
.style18 {
	font-size: 12px;
	color: #000000;
	font-weight: bold;
}
-->
</style>
</head>

<body>

<?php virtual('/VOH/INC/logo.php'); ?>
<br />
<table width="700" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#E7EEF6">
  <tr>
    <td><div align="center" style="color: #70283C"><strong>Service Date Detail </strong></div></td>
  </tr>
</table>
<br />

<table width="700" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
    <td width="593" bgcolor="#FFFFFF"><div align="center" style="color: #000000">
      <div align="left"><strong><a href="/VOH/service_edit_list.php">Return to Date List</a> </strong></div>
    </div></td>
    <td width="93" bgcolor="#FFFFFF"><div align="right"><span class="style18"><a href="#">Delete this date </a></span></div></td>
  </tr>
</table>
<table width="700" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#E7EEF6">
  <tr>
    <td width="343" bgcolor="#FFFFFF"><div align="center" style="color: #70283C; font-size: 12px">
        <div align="center">
          <p>Select a Volunteer and choose<br />
          ADD to make them available on this date:</p>
            Volunteers
           

<select name="SelVol" id="SelVol">
            </select>

          &nbsp;<span class="style15"><a href="#">ADD</a></span>		  
		  &nbsp;<span class="style15"><a href="#">Email</a></span>
          <p>
          </p>
        </div>       
    </div></td>
    <td width="343" bgcolor="#FFFFFF"><div align="center"><span class="style13">ASSIGNED VOLUNTEERS </span></div></td>
  </tr>
  <tr align="center" valign="top" bordercolor="#999999">
    <td height="226" bgcolor="#FFFFFF"> 
      <span class="style17">Volunteers who are AVAILABLE on this date: </span>
      <table width="336" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td width="124" bgcolor="#E7EEF6"><span class="style14">Name</span></td>
          <td width="33" bgcolor="#E7EEF6"><div align="center" class="style14">Note</div></td>
          <td width="36" bgcolor="#E7EEF6"><div align="center" class="style14">Email</div></td>
          <td width="69" bgcolor="#E7EEF6"><div align="center" class="style14">Unavailable</div></td>
          <td width="42" bgcolor="#E7EEF6"><div align="center"><span class="style14">Assign</span></div></td>
        </tr>
      </table></td>
    <td bgcolor="#FFFFFF"><span class="style17">Volunteers who have been ASSIGNED to this date: </span><br />
      <table width="336" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td width="124" bgcolor="#E7EEF6"><span class="style14">Name</span></td>
          <td width="33" bgcolor="#E7EEF6"><div align="center" class="style14">Note</div></td>
          <td width="36" bgcolor="#E7EEF6"><div align="center" class="style14">Email</div></td>
          <td width="69" bgcolor="#E7EEF6"><div align="center" class="style14">Unavailable</div></td>
          <td width="42" bgcolor="#E7EEF6"><div align="center"><span class="style14">Assign</span></div></td>
        </tr>
    </table></td>
  </tr>
</table>
<br><br>



</body>
</html>

I want to display a list of ALL Volunteers (sorted by Last_Name then First_Name (asc)) in the list menu entry field "SelVol". I want to capture the value "id" but display in the drop-down list a concatenation of: Last_Name, a comma, a space, and First_Name. The TABLE name is "Volunteers".

There was a couple examples I searched the archives but I tried to insert them and kept getting errors. Please let me know how I need my code modified to get this to work.

Thanks ;-)

You could hard code them like this

<select name="SelVol" id="SelVol">
<option value = "1">Joe Friendly</option>
<option value = "2">Mary Jackson</option>
            </select>

hard code it like this

<select name="SelVol" id="SelVol">
<?php
$people = array(1=>"Joe Friendly",
2=>"Mary Jackson",
3=>"Harold Balzonia"
);
foreach ($people as $key=>$person)
{
    echo "<option value = \"".$key."\">".$person."</option>\n";
}
?>

or use a database like this:

<select name="SelVol" id="SelVol">
<?php
	$conn = mysql_connect("localhost","user","pass");
        mysql_select_db("yourdb",$conn);
	$query = "select id,firstname,lastname from mytable order by lastname,firstname";
	$result = mysql_query ($query) or die ("select failed : ".mysql_error());
    while($line = mysql_fetch_array($result))
	{
        echo "<option value = \"".$line[0]."\">".$line[2].",".$line[1]."</option>\n";
    } 
?>
            </select>

You could hard code them like this

<select name="SelVol" id="SelVol">
<?php
	$conn = mysql_connect("localhost","user","pass");
        mysql_select_db("yourdb",$conn);
	$query = "select id,firstname,lastname from mytable order by lastname,firstname";
	$result = mysql_query ($query) or die ("select failed : ".mysql_error());
    while($line = mysql_fetch_array($result))
	{
        echo "<option value = \"".$line[0]."\">".$line[2].",".$line[1]."</option>\n";
    } 
?>
            </select>

This worked perfectly. I added a SPACE after the COMMA to get it exactly the way I needed it. Every answer I get - the more I understand and learn ;-) Thanks much!

no prob. programming isnt hard, it just takes time to learn it all. :)

please make sure you click solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.