cheechm Posted May 22, 2007 Share Posted May 22, 2007 Hi, I am new to MySQL so bare with me a bit please. I am trying to create a "house points system" for our school. Literally, people are awarded house points for events they do. At 6 points they get a house tie. I want a teacher to be able to create people in the database (which I think I have done correctly: <form action="housepoints.php" method="post"> Firstname: <input type="text" name="firstname" /> Lastname: <input type="text" name="lastname" /> Tutor: <input type="text" name="tutor" /> <input type="submit" /> </form> <?php $con = mysql_connect("private"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("LPS", $con); $sql="INSERT INTO points (FirstName, LastName, Tutor) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[tutor]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "New person added"; mysql_close($con) ?> ) and then be able to select the person, and add a house point, and define what event they have done. Lastly, I want there to be an automatic message when the amount of points comes to 6, which can then be acknowledged and stopped. Thank you for the help. Quote Link to comment https://forums.phpfreaks.com/topic/52520-mysql-and-php/ Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Sorry, but what exactly is your question? Quote Link to comment https://forums.phpfreaks.com/topic/52520-mysql-and-php/#findComment-259157 Share on other sites More sharing options...
cheechm Posted May 22, 2007 Author Share Posted May 22, 2007 How would I go about: Being able to select a person from the database, and then add a house point and which event they did to their name? EG. There is the database LPS with the table points inside it. The columns in points are FirstName, LastName, Tutor, Events, Points. I want to be able to click on a name and add: a house point and event. Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/52520-mysql-and-php/#findComment-259164 Share on other sites More sharing options...
cheechm Posted May 22, 2007 Author Share Posted May 22, 2007 I have actually solved this far, but for some reason when I do this: <form action="addpoints.php" method="post"> Firstname: <input type="text" name="firstname" /> Lastname: <input type="text" name="lastname" /> Points: <input type="text" name="points" /> <input type="submit" /> </form> addpoints.php: <?php $con = mysql_connect("private"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("LPS", $con); mysql_query("UPDATE points SET Points = '$_POST[points]' WHERE FirstName = '$_POST[firstname]' AND LastName = '$_POST[lastname]'"); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 point added"; mysql_close($con) ?> I get "Error: Query was empty" How can I stop this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/52520-mysql-and-php/#findComment-259264 Share on other sites More sharing options...
taith Posted May 22, 2007 Share Posted May 22, 2007 i'm just going to not that if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } does squat... as the querys are already ran, and $sql is empty... Quote Link to comment https://forums.phpfreaks.com/topic/52520-mysql-and-php/#findComment-259271 Share on other sites More sharing options...
cheechm Posted May 22, 2007 Author Share Posted May 22, 2007 Nice one thanks. Is there any way of when a name is added, there is the word "add points" next to their name, and when clicked it goes to a page address which is something like addpoints.php?firstname=xyz&lastname=xyz&addpoints=1 . Because there is going to be about 100 entries in this table. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/52520-mysql-and-php/#findComment-259282 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.