Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tables - help pllleeeaasssee!!

Status
Not open for further replies.

7724

Programmer
Feb 25, 2005
28
GB
Hi,

I have a reports page and on the reports I have a team line up:

PHP:
<input name="shirtone" type="text" size="35" maxlength="128" value="<?php echo $shirtone?>">
                      <select name="shirtone_quickpick" onChange="window.document.reportform.shirtone.value = this.options[this.selectedIndex].value";>
                        <option>Quick pick name...</option>
                        <option value="Allaway"<? if ($shirtone == 'Allaway') echo ' selected' ?>>Allaway 
                        <option value="Parkin"<? if ($shirtone == 'Parkin') echo ' selected' ?>>Parkin 
                        <option value="Whincup"<? if ($shirtone == 'Whincup') echo ' selected' ?>>Whincup 
                      </select>


When I hit submit the data I select from the dropdown either ‘Allaway’, ‘Parkin’ or
‘Whincup’ is then recorded in the $shirtone variable in that record in a ‘reports’ table.

So When I add 5 reports records with different id’s and for example have picked ‘Allaway’ five times I want that information that he has made 5 appearances to appear in a different table called ‘players’ in an input box with the value ‘5’

PHP:
<input name="allaway" type="text" id="allaway" value="<?php echo $allaway?>" size="36">


Then when I add another report again in the ‘report’ table and he is picked his appearances goes up to ‘6’ automatically in the ‘players’ table and appears in the above input box.

And so on…

How do I go about doing this – can anyone provide me with a code example.

Thanks

Chris
 
it sounds like you are wanting a javascript solution.
 
Not using Javascript, but tried making a COUNT of how many times 'Allaway' has been selected in the reports table and outputs it in a variable called appearances....

But it does not work - any idea?



<?php

// login stuff

include("../login.php");;

$sql = "SELECT COUNT(*) FROM reports WHERE shirtone = 'Allaway' AS appearances ";
$result = mysql_query($sql) or die(mysql_error());
$i = mysql_fetch_array($result);

echo $i['appearances'];

?>
 
Your SQL is malformed.
What you want is:
Code:
SELECT COUNT(*) AS appearances FROM reports WHERE .....
[/count]

Have a look at the row that is returned in your case:
[code]
print_r($i);
That should be it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top