iGoD ReLeNtLeS
20-11-10, 16:46
Im currently making an attendance type script which can be used in the staff forums which will display a users ForumName, GameName and the Count. However i've got that far and have also coded a form to allow anyone who has access to the script to add records into the database, but i currently have no way of increasing the count. I would like to use a + and - button that simply adds 1 or removes 1 from the count. But have yet to discover any method :o What would be the best way.
I currently have this:
the form:
<html>
<head>
<title>Forum</title>
<head>
<body>
<form action="eventscount.php" method="get">
Forum Name: <input type="text" name="fname" />
GameName: <input type="text" name="gamename" />
<input type="submit" />
</form>
</body>
</html>
and this which adds the data into the MySQL database from the form
<html>
<head>
<title>Basic</title>
<head>
<body>
<?php
$fname = $_GET["fname"];
$gamename = $_GET["gamename"];
$con = mysql_connect("","","");
if (!con)
{
die('There Was An Error Connecting To The MySQL Database. Reason: ' . mysql_error());
}
mysql_select_db("event_attendance", $con);
$sql="INSERT INTO counter (ForumName, GameName, Count)
VALUES ('$fname', '$gamename', '0')";
if (!mysql_query($sql,$con)) {
die('There Was An Error Writing The Record To The MySQL Database. Reason: ' . '<br />' . mysql_error());
}
else {
echo 'Success! The Record Of Forum Name: <b>' . $fname . '</b> And GameName: <b>' . $gamename . '</b> Were Added To The Database! <br />';
echo 'Click <a href="">Here</a> To Add Another Record!';
}
mysql_close($con);
?>
</body>
</html>
then here i have the MySQL data display into a table
<html>
<head>
<title>Test</title>
<head>
<body>
<?php
$con = mysql_connect("","","");
if (!con) {
die ('Error Connecting To The Database! Reason: ' . mysql_error());
}
mysql_select_db("event_attendance", $con);
$result = mysql_query("SELECT * FROM counter");
echo '<table style="width:"300px", border="1">';
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['ForumName'];
echo "</td><td>";
echo $row['GameName'];
echo "</td><td>";
echo $row['count'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
as you can see there is no way to add or subtract from the count. I would like there to be a + and - button which simply add or subtracts 1 which is independent from each record.
So i could have something like this:
iGoD_ReLeNtLeS iGoD 29 + -
Example_2 Mr.Example 9 + -
within a table, however what im confused about is how to make the buttons add or subtract because it would need to be a different line of code for each record :confused:
side note: im planning to have all the scripts linked on 1 page using iframes.
Any help is appreciated
~iGod
I currently have this:
the form:
<html>
<head>
<title>Forum</title>
<head>
<body>
<form action="eventscount.php" method="get">
Forum Name: <input type="text" name="fname" />
GameName: <input type="text" name="gamename" />
<input type="submit" />
</form>
</body>
</html>
and this which adds the data into the MySQL database from the form
<html>
<head>
<title>Basic</title>
<head>
<body>
<?php
$fname = $_GET["fname"];
$gamename = $_GET["gamename"];
$con = mysql_connect("","","");
if (!con)
{
die('There Was An Error Connecting To The MySQL Database. Reason: ' . mysql_error());
}
mysql_select_db("event_attendance", $con);
$sql="INSERT INTO counter (ForumName, GameName, Count)
VALUES ('$fname', '$gamename', '0')";
if (!mysql_query($sql,$con)) {
die('There Was An Error Writing The Record To The MySQL Database. Reason: ' . '<br />' . mysql_error());
}
else {
echo 'Success! The Record Of Forum Name: <b>' . $fname . '</b> And GameName: <b>' . $gamename . '</b> Were Added To The Database! <br />';
echo 'Click <a href="">Here</a> To Add Another Record!';
}
mysql_close($con);
?>
</body>
</html>
then here i have the MySQL data display into a table
<html>
<head>
<title>Test</title>
<head>
<body>
<?php
$con = mysql_connect("","","");
if (!con) {
die ('Error Connecting To The Database! Reason: ' . mysql_error());
}
mysql_select_db("event_attendance", $con);
$result = mysql_query("SELECT * FROM counter");
echo '<table style="width:"300px", border="1">';
while($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['ForumName'];
echo "</td><td>";
echo $row['GameName'];
echo "</td><td>";
echo $row['count'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
as you can see there is no way to add or subtract from the count. I would like there to be a + and - button which simply add or subtracts 1 which is independent from each record.
So i could have something like this:
iGoD_ReLeNtLeS iGoD 29 + -
Example_2 Mr.Example 9 + -
within a table, however what im confused about is how to make the buttons add or subtract because it would need to be a different line of code for each record :confused:
side note: im planning to have all the scripts linked on 1 page using iframes.
Any help is appreciated
~iGod