Jump to content

PHP_Idiot

Members
  • Posts

    131
  • Joined

  • Last visited

Everything posted by PHP_Idiot

  1. Awesome thanks a lot, I had looked at the switch method but couldn't work out how best to use it. If I understand your comments correctly I place the function outside the loop and call the function into the cell where I need the result? (and if so how?) Is this correct or should I be placing the function in the cell itself? (agian how?) Thanks so much, sorry for the really noobish questions, but I am a total noob but slowly learning?!
  2. Hi The below code generates a table and a number of rows depending on the user input. for ( $counter = 1; $counter <= $PlayerNo; $counter += 1) { echo "<tr><td align='center' valign='center'>"; echo $counter; echo "</td><td align='center' valign='center'>"; echo '<input name="Score" type="text" size="3" maxlength="3">'; echo "</td><td align='center' valign='center'>"; echo '<input name="MembershipNo" type="text" size="7" maxlength="7">'; echo "</td><td align='center' valign='center'>"; echo '<input name="FirstName" type="text" size="15" maxlength="7">'; echo "</td><td align='center' valign='center'>"; echo '<input name="LastName" type="text" size="15" maxlength="7">'; echo "</td></tr>"; } echo "</table>"; This works but I also need to fill the Points column. To do this I'm think an elseif would do it but I can't get it to work. (The $counter is the finishing postion of each player, the score is dependant on the players finishing postion) the basic idea would be: (and yes I know this syntax is way out but you get the idea...hopefully) If [$counter] = 1, then [Points] = 500 Elseif [$counter] = 2, the [Points] = 350 Elseif [$counter] = 3, then [Points] = 250 and so on 4=200, 5=150, 6=100, 7=75, 8=50. Is an elseif statement the correct one to use, and if so where should I place it (I presume in a $variable then call that in the code I have above already is that right?)
  3. Gevans -your a genius Thanks for spotting that and pointing it out, I'm still very new to this and forgot about the quote marks. Anyway it works as it should now so thanks a lot.
  4. Hi I have a simple web form that I using to collect info, and the the following php t display it: <?php if ($_POST['Day'] == '') { $Day = '<span style="color:red;">Date omitted.</span>'; } else { $Day = $_POST['Day']; } if ($_POST['Month'] == '') { $Month = '<span style="color:red;">Month omitted.</span>'; } else { $Month = $_POST['Month']; } if ($_POST['Year'] == '') { $Year = '<span style="color:red;">Year omitted.</span>'; } else { $Year = $_POST['Year']; } if ($_POST['Venue'] == '') { $Venue = '<span style="color:red;">Venue omitted.</span>'; } else { $Venue = $_POST['Venue']; } ?> <html> <head> <title>Process Employee</title> </head> <body> <h1>Game Details</h1> <ul> <?php //Output the variables as list items. echo "<li><b>Venue:</b> $Venue</li>"; echo "<li><b>Tournament Date:</b> $Day / $Month / $Year</li>"; ?> </ul> </body> </html> The date displays perfectly (1 / Jan / 2009) but the Venue only displays the first word in each name, eg Bar, The. It stops at the space between words! The list of venue names appears in a dropdown list generated from a mySQL db. generated by this code: $query="SELECT VenueName FROM Venue ORDER BY VenueName"; $result = mysql_query ($query); echo "<select name='Venue' id='Venue' value=''>Venue Name</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[VenueName]>$nt[VenueName]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> Once the form is complete a submit button is pressed and the above php comes into play. Should I be saving all the venue names in the DB with underscores instead of spaces! eg The_Pub? Or is there a way to get it to ignor the spaces? Thanks in advance
  5. Ummm... not sure which is best. What i had in mind was a page to enter the inital info, so a drop down of current venues (which I already have working) the date played (also working) and then a text entry field to input the number of players. Then clicking the submit would take you to a form with the correct numbers of rows created. However, I had imagined that the sanity check would run once the membership had been entered, without clicking any further buttons! I tried the following code to create a loop but I can't get it to work, I was kinda hoping I could build it up from here! <? numplayers = 20; for ($i = 1; $i <= $numplayers; $i++ {echo ' <tr><table border="1"> <tr><th>Position</th><th>Membership Number</th><th>First Name</th><th>Last Name</th></tr> <td id="player.'$i'"><label>Position</label><input name="1" type="text" value="1" size="2" maxlength="2"></td> <td><label></label><input name="membership" type="text" size="7"></td> <td><label></label><input type="text" size="15" maxlength="10"></td> <td><input type="text" size="15" maxlength="10"></td> </tr>'; } ?>
  6. Hi as you may of guessed from the screen name I'm new to this. I need to develop a page that records tournament information and feeds it back into my database. I have a drop down list that calls venue names from my database, another to enter the date field and a third to ask how many players results need recording. what I need the form to do then is create the required number form input rows ( same as number of player results that need recording). The form would end up with number of players listed 1,2,3 (these become their finishing positions) etc running top to bottom, next would be an input field for the players membership number, thirdly, a ldisplay box that looks up the membership number and displays the players name as a sanity check. Then when the user submits the form it saves the data to the mysql database. I can make a static form but how do I get it to change the number of form rows available to match the user inputted player results number? Thanks for all advice offered.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.