Hi, im writing a script for match result adding for my clan to make it easier for us rather than editing the page each time we play
Im pretty new to using php+sql, so i dont really know how i would display the results in a table after adding them to a database.
This is what i currently have:
Config.php
PHP Code:
<?
$dbh=mysql_connect ("mysql93.secureserver.net", "deansdatabase", "********") or die ('I cannot connect to the
database because: ' . mysql_error());
mysql_select_db ("deansdatabase");
$mysql_table="results";
?>
The Form:
Code:
<html>
<head>
<title>Add a Result</title>
<link rel="stylesheet" type="text/css"
href="style.css">
</head>
<body>
<form name="add" action="form.php" method="POST">
Match Type: <select name="type">
<option value="Enemy Down Official">Enemy Down Official</option>
<option value="Enemy Down Friendly">Enemy Down Friendly</option>
<option value="Scrim">Scrim</option>
</select><br /><br />
Clan Name: <input type="text" name="cname"><br /><br />
Result: <select name="result">
<option value="Win">Win</option>
<option value="Loss">Loss</option>
<option value="Draw">Draw</option>
</select><br /><br />
Score: <input type="text" name="sens" value="6senseuK"> -VS- <input type="text" name="clan" value="Other Clan"><br /><br />
Map: <select name="map">
<option value="de_dust2">de_dust2</option>
<option value="de_train">de_train</option>
<option value="de_dust">de_dust</option>
<option value="de_aztec">de_aztec</option>
<option value="de_inferno">de_inferno</option>
<option value="cs_italy">cs_italy</option>
<option value="cs_office">cs_office</option>
<option value="de_prodigy">de_prodigy</option>
<option value="de_cbble">de_cbble</option>
<option value="de_port">de_port</option>
<option value="de_clan_mill">de_clan_mill</option>
<option value="de_contra">de_contra</option>
<option value="de_cpl_fire">de_cpl_fire</option>
<option value="de_blast_ed">de_blast_ed</option>
</select><br /><br />
Screenshot 1st Half: <input type="text" name="ss" value="Screenshot URL"><br /><br />
Screenshot 2nd Half: <input type="text" name="ss2" value="Screenshot URL"><br /><br />
<input type="submit" value="Add Result!"> <input type="reset" value="Reset Form!">
</form>
</body>
</html>
form.php:
PHP Code:
<?php
include
("config.php");
foreach($_POST as $key => $val) {
$_POST[$key] = htmlspecialchars($val, ENT_QUOTES);
}
$a = date("G:i:S ");
$b = date("d M");
$time = "$b at $a";
$ip = $_SERVER
['REMOTE_ADDR'];
$type=$_POST["type"];
$cname=$_POST["cname"];
$result=$_POST["result"];
$score=$_POST["sens, clan"];
$map=$_POST["map"];
$ss=$POST["ss"];
$sss=$_POST["ss2"];
mysql_query("INSERT INTO `$mysql_table` (type,cname,result,score,map,ss,sss) VALUES
('$type','$cname','$result','$score','$map','$ss','$sss')");
if(mysql_error()) {
die(mysql_error());
}
?>
Result Added
Now this should be all right afaik, but how would i display the results in a table from the database?
Any help greatly appreciated!