Daney11 Posted March 19, 2009 Share Posted March 19, 2009 Hey guys. I have this peice of code below which creates numbers from 1-99 for each record in my form. Example: Num Name 1 Dane 2 Milk 3 Shake 4 Pig <select name='squad_number[<?php $i; ?>]' class="input"> <?php for ($a=1; $a<=99; $a++) { if($a<10) { $val="$a"; } else { $val=$a; } echo "<option value='$val'"; if ($val==$Squad_PlayerRow['squad_number']) { echo " selected"; } echo ">$val</option>"; } ?> </select> Once submitted, it updates the database setting the relevant fields to the number selected from the form above. However i need to add error checking to it. If, for example: Example: Num Name 1 Dane 2 Milk 1 Shake 4 Pig You will see "Dane" and "Shake" each have the number "1", and i want that to return an error saying that you can not use the same number twice basically. Im using: if (eregi ('^[[:digit:]]{1,2}$', stripslashes(trim($_POST['squad_number'][$i])))) { $squad_number = $_POST['squad_number'][$i]; } else { $squad_number = FALSE; $errors[] = 'Please enter a correct team number.'; } To check if that value in the select menu is actually a number between 1-99, and this works fine. How would i create a error checking to find wether a number has been used twice. Thanks Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 19, 2009 Author Share Posted March 19, 2009 Ok then, is this even possible to do Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 19, 2009 Author Share Posted March 19, 2009 Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 19, 2009 Author Share Posted March 19, 2009 I guess this is not possible. Thanks anyways for all your replys. Quote Link to comment Share on other sites More sharing options...
Daney11 Posted March 20, 2009 Author Share Posted March 20, 2009 If anyone else finds that they dont recieve replys. Goto www.sitepoint.com. They will help you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.