I was trying to implement checkboxes, but that seems too difficult.

Here is the code:

session_start(); // Maintain session state
header("Cache-control: private");	// Fixes IE6's back button problem.
$page_title = "Class Information";
$class_id = $_GET['id'];
$enter = $_POST['enter_horse'];
$horse_id = $_POST['horse_id'];
//general show information
$result = @mysql_query("SELECT s.show_id, s.player_id, s.type, s.name, DATEDIFF(s.run_date, NOW()) AS datedif, c.class_id, s.entry_fee FROM classes c, shows s WHERE c.class_id='$class_id' AND c.show_id=s.show_id LIMIT 1")or die("Cannot find class! " . mysql_error());
$row = @mysql_fetch_array($result);
	$show_id = $row['show_id'];
	$show_name = $row['name'];
	$runs_in = $row['datedif'];
	$species = $row['species'];
	$type = $row['type'];
	$owner_id = $row['player_id'];
	if(!$row['class_id']){myError("Invalid class!");include('footer.php');}
	$entry_fee = $row['entry_fee'];
	$num_entries = @mysql_num_rows(@mysql_query("SELECT horse_id FROM horses_entered WHERE class_id='$class_id'"));
	$runs_in = "$runs_in day[s]";
	//ensure horse is eligible to enter
	$good = @mysql_num_rows(@mysql_query("SELECT horse_id FROM horses WHERE horse_id='$horse_id' AND player_id='$player_id' AND age>=4 AND age<=20"));
	$exists = @mysql_num_rows(@mysql_query("SELECT horse_id FROM horses_entered WHERE horse_id='$horse_id' AND class_id='$class_id' LIMIT 1"));
	if($my_money < $entry_fee){myError("You cannot afford the entry fee.", 1);}
	if(!$good){myError("Are you sure you own the horse and it is between 4 and 20 years of age?");
	}elseif($exists){myError("That horse is already entered in this class!");
		@mysql_query("INSERT INTO horses_entered(horse_id, class_id) VALUES('$horse_id', '$class_id')")or die("Cannot create entry!");
		if($type == 1 AND $entry_fee){@mysql_query("UPDATE players SET money=money+'$entry_fee' WHERE player_id='$owner_id' LIMIT 1")or die("Cannot update player money!"); $points=1;
		}elseif($type == 2 AND $entry_fee){@mysql_query("UPDATE clubs SET money=money+'$entry_fee' WHERE president='$owner_id' LIMIT 1")or die("Cannot update player money2!"); $points=2;}
		@mysql_query("UPDATE players SET money=money-'$entry_fee', points=points+'$points' WHERE player_id='$player_id' LIMIT 1")or die("Cannot update player money3! " . @mysql_error());
		@mysql_query("UPDATE horses SET points=points+'$points' WHERE horse_id='$horse_id' LIMIT 1")or die("Cannot update horse points!");
		myError("Class entered!");
//display the show information
echo "<table>
<tr><td><b>Show:</td><td><a href='shows.php?id=$show_id'>$show_name (#$show_id)</a></td></tr>
<tr><td><b>Entry Fee:</td><td>$$entry_fee</td></tr>
<tr><td><b>Total Entrants:</td><td>$num_entries</td></tr>
<tr><td valign=top><b>Your Horses:</td><td>
<form action='classes.php?id=$class_id' method=POST>
<select name='horse_id'>
$result = @mysql_query("SELECT horse_name, breed, horse_id FROM horses WHERE player_id='$player_id' AND age>3 AND age<=20 ORDER BY horse_name ASC")or die("Cannot find horses! " . mysql_error());
while($row = @mysql_fetch_array($result)):
	$horse_id = $row['horse_id'];
	$horse_name = stripslashes($row['horse_name']);
	$breed = $row['breed'];
	echo "<option value='$horse_id'>$horse_name (#$horse_id), $breed</option>\n";
	$prev_species = $species;
if(!$horse_id){echo "<option value=0>No eligible horses!";}
echo "
</select> &nbsp;&nbsp;
<input type=submit name='enter_horse' value='Enter Horse!'></td></tr></form>
<tr><td valign=top><b>Entrants:</td><td>
$query = "SELECT h.horse_name, h.horse_id, h.breed FROM horses_entered he LEFT JOIN horses h ON he.horse_id=h.horse_id WHERE he.class_id='$class_id' ORDER BY h.horse_name ASC";
$result = @mysql_query($query)or die(mysql_error());
while($row = @mysql_fetch_array($result)):
	$name = $row['horse_name'];
	$aid = $row['horse_id'];
	$breed = $row['breed'];
	$page = "horses.php";
	echo "<a href='$page?id=$aid'>$name (#$aid)</a>, $breed<br>\n";
if(!$aid){echo "<i>No entrants.";}
echo "</td></tr>

Now I'm wondering if it is possible to have one submit form button that will send all of the results at once, instead of one at a time like it is set up now. Basically a user submits one horse at a time to be inserted into a class of a show. The horses that show up are the eligible ones - the user selects which one - hits submit - and has to do this for each horse to be put in the show.

Is it possible to get one submit button for all of those eligible horses, i.e. all the results that are showing up in the drop down list? Obviously, there would be no need for the drop down list anymore, they could just be listed normally, with a 'submit all horses' value on the submit button...

Note: I didn't write this code myself, I'm just trying to tweak it for my website. I will need specific instructions, as I'm really horrible with PHP. I am able to debug some of my issues, but this is definitely above my skill level.

Thank you very much in advance.

Member Avatar

We were discussing this in another thread, I can't see why you've started a new one. Ok - I'll leave you to somebody else. Bye.