Jump to content

Multiple inserts based on a table number


Justafriend

Recommended Posts

Player

Name

Total
Ballots Regular
Ballots Bonus
Ballots Singles
Games Pards
Games Single's
Pawns Single's
Scores Pards
Pawns Pards
Scores Singles
4s Pards
7s Total
Games Total
Pawns Total
Score

xtaz2002x 2 2 0 0 0 2 220 3 291 0 0 2 5 511

Woman 3 3 0 0 0 4 288 4 405 1 0 2 8 693

 

 

the ballot numbers will be generated at end of event but what i need to know if there is anyway that with
this data i can  either in a php page or a mysql query set it up so that for each player  will insert the number of ballots on multiple rows in my ballot table which will have 

id  playername  BallotNumber

 

what my desired output is  from the data above

 

1    xtaz2002x    10000

2    xtaz2002x    10001

3    xtaz2002x    10002

4    Woman        10003

5    Woman        10004

Just need to know where i can start with if this is even possible

Link to comment
Share on other sites

If you're asking whether you can insert 3 times for someone that has 3 ballots, that sounds like a bad idea. If it's not, then I don't understand the question.

yes i am i need  to do a final  and will be done on a  page i upload or in a sql script i run once 

The reason to be more clear is i need one entry  for each ballot  in ballot table 

The regular ballots i could do easily but the bonus Ballots gets a little more trickier 

They are calculated by 

1 Ballot for Every 5 Games in Singles with a 4 score

1 Ballot for every 3 Games in Pards with a team score of 7

1 Ballot for Every 500 pts Combined in Single games

1 Ballot for Every 1000 pts Combined team score in Pards Games

if i did a  insert for every 5 games where  score = 4  at  game 5 6 7 8 9 it would insert a total of 5 when it should be 1

i included a link to the table its based on so you can see  a better idea of what i am doing

http://whambamgames.com/teststuff/pawn/players.php

 

the issue with writing code to start is i have no clue where to even start if its even possible 

Link to comment
Share on other sites

Just thinking about it further even if i could get  it to echo out into html text where it would show it i could then put into a excel sheet  then save it as a csv and import 

the select statement i  have in my php  is

   $sql = "SELECT PlayerName, COUNT(*) AS TG, SUM(sg) AS SG, SUM(pg) AS PG, SUM(PlayerPawn) AS PP, SUM(PlayerScore) AS PS, SUM(PPlayerPawn) AS PPP,
   SUM(PPlayerScore) AS PPS, SUM(PPlayerPawn + PlayerPawn) AS TP, SUM(PPlayerScore + PlayerScore) AS TS, SUM(S4) AS SS4, SUM(P7) AS PP7, 
  floor(SUM(PlayerScore /500)) + floor(SUM(PPlayerScore /1000)) + floor(SUM(S4 /5)) +  floor(Sum(P7 /3)) + SUM(prereg) AS BB,  floor(SUM(PlayerScore /500)) + floor(SUM(PPlayerScore /1000)) +  floor(SUM(S4 /5)) +  floor(Sum(P7 /3)) + SUM(PlayerBallots) + SUM(prereg) AS TB,
   SUM(PlayerBallots) AS PB FROM player GROUP BY PlayerName ";

what i need is that whatever Tb is to echo out the player name  that many times  so if TB is 5 for player woman it would echo on a page

woman

woman

woman

woman

woman

Link to comment
Share on other sites

I have tried to see if i can get it to output to a webpage so i can bring it into excel before importing it to avoid dangerous results

with the code below i am getting

Parse error: syntax error, unexpected 'str_repeat' (T_STRING) in /home2/whambamg/public_html/teststuff/pawn/test.php on line 20

<!DOCTYPE html>
<html>

<?php
   include("config.php");
   $sql = "SELECT PlayerName, 
   floor(SUM(PlayerScore /500)) + 
   floor(SUM(PPlayerScore /1000)) +  
   floor(SUM(S4 /5)) +  floor(Sum(P7 /3)) + 
   SUM(PlayerBallots) + 
   SUM(prereg) AS TB,
   SUM(PlayerBallots) AS PB FROM player GROUP BY PlayerName ";
if($result = mysqli_query($con, $sql)){
   
$input = $row['PlayerName'];
  
$multiplier = $row['TB'];
   
   
string str_repeat ( string $input , int $multiplier );


 
// Close connection
mysqli_close($con);



?>

	</html>

I believe this will give you a better idea of what i am trying to do

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.