PDA

View Full Version : Help adding to my excisting database.



WeeGiE
04-11-2008, 12:47 PM
Hi all. I have a submit forum with the following fields you see below. I have the following fields home team, away team, home score and away score..but I want to add more fields of course I know how to do this...but the problem is when they submit the results it stores to my database I have all set up, but I want it so it then display on my website like the home away sections already do. Below I have also posted the other part of my code this is the section of code I'm having problems with I don't know what php code to put to display anyway other fields I wish to make for example Goal scores. Any help will be much appreciated.


<?php
if($user->data['is_registered'])
{
?>
<p class="main_text">
Please use this form to submit results. If you have any issues, please let us know on the forums.
<br /><br />
</p>
<div align="center" id="form">
<form action="insert.php" method="post">
<input name="HomeTeam" type="text" value="home team name" class="input" maxlength="25" />
<input name="AwayTeam" type="text" value="away team name" class="input" maxlength="25" />
<input name="HomeScore" type="text" value="0" class="input" maxlength="2" />
<input name="AwayScore" type="text" value="0" class="input" maxlength="2" />
<input name="League" type="text" value="League Name" class="input" maxlength="30" />
<input name="Submitter" type="hidden" value="<?php echo($user->data['username']);?>" />
<input name="Date" type="hidden" value="<?php $date = date("Y-m-d"); echo($date);?>" />
<div align="center"><input name="submit" type="submit" value="Submit Result" class="submit" /></div>
</form>
</div>
<?php

<?php
$con = mysql_connect("localhost","******","*****");
if (!$con)
{
die('Could not connect, please notify an admin: ' . mysql_error());
}

mysql_select_db("*******", $con);

$query = "SELECT hometeam, awayteam, homescore, awayscore, league, date FROM results ORDER BY id DESC";
$result = mysql_query($query);

?>
<div align="center"><table class="results_table">
<tr>
<td width="25%" class="results_header">Home Team:</td>
<td width="25%" class="results_header">Away Team:</td>
<td width="15%" class="results_header">Home Score:</td>
<td width="15%" class="results_header">Away Score:</td>
<td width="20%" class="results_header">Date:</td>
</tr>
<?php
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
?>
<tr>
<td class="results_data"><?php echo($row['hometeam']);?></td>
<td class="results_data"><?php echo($row['awayteam']);?></td>
<td class="results_data"><strong><?php if($row['homescore'] > $row['awayscore'])
{echo('<font color="green">');} else if($row['homescore'] < $row['awayscore']) { echo('<font color="red">');}
echo($row['homescore']);?>
</font></strong>
</td>
<td class="results_data"><strong><?php if($row['awayscore'] > $row['homescore'])
{ echo('<font color="green">');} else if($row['awayscore'] < $row['homescore']) { echo('<font color="red">');}
echo($row['awayscore']);?>
</font></strong>
</td>
<td class="results_data"><?php echo($row['date']);?></td>
</tr>

<?php
}
?>

Jackboy
04-11-2008, 05:04 PM
Spell existing properly and i will help you :D

WeeGiE
05-11-2008, 08:55 AM
Still looking for some help please. Also once I have this done, I hope to maybe hire someone to add to my script payment will be offered of course.

@Jackboy - Was a mistake -.- also you know I can't edit my post.

Yonder
05-11-2008, 01:01 PM
Cant understand the post.

Do you wish to insert new row(s) into the database
OR
The rows already exist but you do not know how to call them?

Because your post suggests you know how to add fields etc but your post also suggests you do not know how to display them via php, when you clearing have done with the Home/Away/Scores etc.

WeeGiE
05-11-2008, 01:06 PM
Cant understand the post.

Do you wish to insert new row(s) into the database
OR
The rows already exist but you do not know how to call them?

Because your post suggests you know how to add fields etc but your post also suggests you do not know how to display them via php, when you clearing have done with the Home/Away/Scores etc.

I know how to add fields yes. I have the new rows in my database. All it is I'm having problems displaying then on my site the same way the others already do.

Yonder
05-11-2008, 02:57 PM
$query = "SELECT goals, hometeam, awayteam, homescore, awayscore, league, date FROM results ORDER BY id DESC";

Make sure you include the row you are calling e.g. goals

<?php echo($row['goals']);?>

Then insert something like that.

Understand, main thing is remembering to call it in the query.

Want to hide these adverts? Register an account for free!