Here it is with some comments:
CODE
<?php
$xname= array ("Jim", "Bob" , "John");
$Jimjob=array("Jim's Option One","Jim's Option Two","Jim's Option Three","Jim's Option Four");
$Bobjob=array("Bob's Option One","Bob's Option Two","Bob's Option Three","Bob's Option Four");
$Johnjob=array("John's Option One","John's Option Two","John's Option Three","John's Option Four");
// This sets up the array to contain the second button's options: Row 0 contains Jim's, row 1 contains Bob's, and row 2 contains John's.
for ($j = 0; $j <= 3; $j++) {
$opt[0][$j] = $Jimjob[$j];
$opt[1][$j] = $Bobjob[$j];
$opt[2][$j] = $Johnjob[$j];
}
if (isset($_POST['name'])) {
$name = $_POST['name'];
}
?>
<form action="<?php echo $php_self ?>" method="post">
<select name="name" >
<?php
// loop through each of the three names for the first button.
for ($i = 0; $i <= 2; $i++) {
unset($ch1); // This sets $ch1 to be a null string.
// if $name =0, then the first name is to be selected, =1, then second name, =2, the third.
if ($name==$i){
$ch1="selected=\"selected\""; // This sets $ch1 to be: selected="selected"
}
?>
<option name="name" value="<?php print $i; ?>" <?php print $ch1 ?> ><?php echo $xname[$i];?>
<?php
//Still looping through the three names, we set each of the three options, only checking off the currently selected name.
}
// After looping, we add the hidden value of the currently selected job option # to the post.
?>
</select>
<input type="hidden" name="job" value="<?php print $job ?>" />
<input type="submit" />
</form>
<?php
// We do basically the same thing as above for the second button.
if (isset($_POST['job'])) {
$job = $_POST['job'];
}
?>
<form action="<?php echo $php_self ?>" method="post">
<select name="job" >
<?php
for ($j = 0; $j <= 3; $j++) {
unset($ch1);
if ($job==$j){
$ch1="selected=\"selected\"";
}
?>
<option name="job" value="<?php print $j; ?>" <?php print $ch1 ?> ><?php echo $opt[$name][$j];?>
<?php
}
?>
</select>
<input type="hidden" name="name" value="<?php print $name ?>" />
<input type="submit" />
</form>