Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/262838-assigning-ids-to-result-array/
Share on other sites

Sorry for that I was not even sure what is was that I was looking for and finally came across a solution...thanks for your time and I aplogize for the rule violation, I was exhausted when posting that I did not mean to disregard them.

 

Thanks again.

Sorry for that I was not even sure what is was that I was looking for and finally came across a solution...thanks for your time and I aplogize for the rule violation, I was exhausted when posting that I did not mean to disregard them.

 

Thanks again.

Please post your solution.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.