...

View Full Version : Match Result Add Script - Help :)



exact-gaming
02-17-2006, 03:19 PM
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

<?
$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:

<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
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!

degsy
02-17-2006, 03:33 PM
http://www.zend.com/php/beginners/php101-8.php#Heading5

I prefer the mysql_fetch_assoc method.

exact-gaming
02-17-2006, 05:26 PM
What would be an example code using that way, to display it in a table?

degsy
02-21-2006, 02:50 PM
The example shows you how to connect to the database and output the query in a table.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum