Hi guy's looking for some help on a project I have going on-
I am using this code as my query in mysql-
<?php
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$week=$_REQUEST['week'];
$sql=mysql_query("SELECT team
,SUM(team_score) AS total_score
FROM (SELECT away AS team
,score_away AS team_score
FROM $tbl_name
WHERE week='$week'
UNION ALL
SELECT home AS team
,score_home AS team_score
FROM $tbl_name
WHERE week='$week')
AS u GROUP BY team")or die(mysql_error());
?>
<form name="form2" method="post" action="update4.php">
<?php
while($rows=mysql_fetch_array($sql)){
?>
<td><? echo $rows['team']; ?></td>
<td align="center"><input name="totalscore[]" type="text" value="<? echo $rows['total_score']; ?>"></td><br />
<?
}
?>
THE RESULTS ARE:
Angels 12
Astros 15
Athletics 24
Blue Jays 15
Braves 22
Brewers 18
etc....
My question is 2 parts-
1st- How do I assign an ID to either the team or the total_score so I can pass the values over to a processing form?
or
2nd- I already have a table set up in my database that holds the team names called 'teams', How do I pull the pull the column 'tid' from a 'teams' so that when the results from the query above display it will display the 'tid' that corresponds with the teams listed in the away or home columns of the first table 'content'.
The results of the query are exactly what I need but I need to be able to display the info into a table for each team and thats where the headache comes in.
Any thoughts. I've been researching arrays and values all morning and have decided to ask the experts.
Please let me know if you need to see more structure.
Hope everything is clear.
Thanks in advance.