jtwillis Posted April 21, 2009 Share Posted April 21, 2009 I have an idea...my boss wants me to make him a form where his son can enter all of his golf tourny stats. My idea was to make the form in php, then when it's submitted it gets posted to a page, seperated by tourny names. Also, I was needing to have the avg's of all his scores. How exactly would I go about doing this? Link to comment https://forums.phpfreaks.com/topic/155028-is-it-possible-to/ Share on other sites More sharing options...
SWD Posted April 21, 2009 Share Posted April 21, 2009 JT, It's definitely possible in PHP. There are 1001 tutorials on the web which will teach you database connections and display of data from a MySQL database. A great reference is always php.net or here of course! Good luck LP Link to comment https://forums.phpfreaks.com/topic/155028-is-it-possible-to/#findComment-815397 Share on other sites More sharing options...
jtwillis Posted April 21, 2009 Author Share Posted April 21, 2009 which functions should I be looking into? I had the idea that each form have it's own name (of course) and then for the averages have php do the math, which is the easy part, but what functions do I research better, to be able to pull stats from each tourny submited? Link to comment https://forums.phpfreaks.com/topic/155028-is-it-possible-to/#findComment-815398 Share on other sites More sharing options...
Bizty Posted April 21, 2009 Share Posted April 21, 2009 It's probably easier for you if you toy abit with some simple data-pulling and inserting data. Try and look at this: the html: <? //Require the function file so we have acces to the WriteGolf() function. require_once("somefunctionfile.php"); ?> <form method='post' action='somefunctionfile.php'> Tournament: <input type='text' name='tournament' /><br /> Points: <input type='text' name='points' /><br /> <input type='submit' name='submit' /> </form> <br /><br /><br /> <? //Writing out the data-base information. GolfWrite(); ?> Then the php(the file: somefunctionfile.php): if($_POST['submit']) { //Check if either of the form-fields were empty, if any are, then return with an error message and kill the script. if(empty($_POST['tournament']) or empty($_POST['points'])) { print "Error: either the tournament and/or point field was empty."; die; } //Set 2 variables from the posted information $tournament = $_POST['tournament']; $points = $_POST['points']; //Insert the typed information into your database mysql_query("INSERT INTO yourTable (tournament, points) VALUES ('$tournaments', '$points')"); header("location: index.php"); } function GolfWrite() { //Pull the data out from the database $q = mysql_query("SELECT * FROM yourTable"); //Here we have a while loop - while we have rows within the array of $q print the information below while($row = mysql_fetch_array($q)) { //Printing out the data print "In Tournament: <b>". $row['tournament'] ."</b> - Boss' son got: <b>". $row['points'] ."</b> points<br />"; } } probably better or easier ways to do it, but this should give you the basic idea of how input/output from a database works. Link to comment https://forums.phpfreaks.com/topic/155028-is-it-possible-to/#findComment-815404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.