Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-17-2006, 03:19 PM   PM User | #1
exact-gaming
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
exact-gaming is an unknown quantity at this point
Match Result Add Script - Help :)

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($valENT_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!
exact-gaming is offline   Reply With Quote
Old 02-17-2006, 03:33 PM   PM User | #2
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
http://www.zend.com/php/beginners/php101-8.php#Heading5

I prefer the mysql_fetch_assoc method.
degsy is offline   Reply With Quote
Old 02-17-2006, 05:26 PM   PM User | #3
exact-gaming
New Coder

 
Join Date: Feb 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
exact-gaming is an unknown quantity at this point
What would be an example code using that way, to display it in a table?
exact-gaming is offline   Reply With Quote
Old 02-21-2006, 02:50 PM   PM User | #4
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
The example shows you how to connect to the database and output the query in a table.
degsy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:29 PM.


Advertisement
Log in to turn off these ads.