Jump to content

OutOfInk

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by OutOfInk

  1. I have two tables that relate to each other; tableA has a Columns ID, NAME, BETRESULT tableB has all the users register data; Each user places a bet on a sport for the week and they either win or lose there credits. What i wish to do is take away 20 credits from users that dont place a bet for the week. So anyone that does bet i INSERT a new row into tableA. I need to some how work out what usernames havent bet in tableA and remove 20 credits from tableB; I wrote this query but it ended up taking 20 credits off every user. SELECT bets.name, Register.SNAME FROM bets INNER JOIN Register ON bets.name = Register.SNAME If someone could help thanks in advance!
  2. I want to ORDER my results by the amount of credits a user has so we can see who is on the leaderboard placings. The problem is I need to have an addition as there new bet must be included in the result to make the results true; is there something that works like follows? ORDER BY `tableA.credits` + `tableB.newBet` LIMIT 0,150 using a join with an addition?
  3. Thanks mac_qyver, I've imploded them as so $imp = implode("', '", $llec); But mysql is still saying theirs an error with my array data SELECT `name` , `bet` FROM `table` WHERE `round` = '$round' AND `placed_on` IN ('Richmond','Carlton','Port Adelaide','GWS Giants','Hawthorn','West Coast','North Melbourne','Draw','Draw') I run this as a test and it said theirs a error
  4. I havew populated $llec as an array with nine teams and i need to extract all users who have bet on any of these options, ive tried everything i can think of so far so if someone has a solution would be awesome. Ive tried a for () statement as well with no luck. $i = 0; $puntBets = mysql_fetch_row(mysql_query("SELECT `name` , `bet` FROM `tablebets` WHERE `placed_on` = '$llec[$i]' AND `round` = '$round'")); $i++;
  5. QuickOldCar how about posting something constructive and useful in a php help forum instead of wasting a post being a forum nazi.
  6. Thanks Ch0cu3r, that helped a lot, the only thing im still having trouble with is carrying the ID which i need to relate to the table row for each of those games. $closeselect[0] is important to be carried as that indexs the specific row that $closeselect[1], $closeselect[2] or Draw relate too. At the moment it now gathers the correct option with the radio checked for any of the options but how can i grab that $closeselect[0]
  7. I have multiple checkboxes which im submitting data from and need to retrieve that data. I need to be able to get closewin[$i] and winner[$i] into the same foreach() statement so that it stops defaulting to the first 0 to 8 options; my code is below; I have placed $o++ in there to make all closewin[$i] options different <?php $fuck = $globalRound[0] - 1; // On round 3 if (isset($_POST['subclose'])){ foreach ($_POST['winner'] as $index => $value){ $a = $_POST['closewin']; $b = $value; $q = mysql_fetch_row(mysql_query("SELECT FROM WHERE `` = '$b[$i]'")); if ($a[$i] = $q[0]){ $d = $q[0]; $e = $q[1]; }else{ $d = $q[1]; $e = $q[0]; } mysql_query("UPDATE "); echo "You have selected $a[$i] as the winner!<br />"; echo "---------------------------<br />"; } echo "<b>You have closed Round $fuck, leaderboard is now updated, ppc credited for winners!</b><br />"; } ?> <form action="/p.php" method="post" name="closeg"> <table border='1' cellpadding='2' cellspacing='0' bordercolor='#000000' class='sub2' width="620"> <tr class="innertable"><td align="center" colspan="2"><b>Close Round / Update Leader Board / Credit PPC wins</b></td></tr> <?php $i = 0; $o = 9; $selectclose = mysql_query("SELECT `id` , `Home` , `Away` FROM `` WHERE `Round` = '$fuck'"); while ($closeselect = mysql_fetch_row($selectclose)){ echo " <tr class=innertable> <td> <input type='hidden' name='winner[$i]' value='$closeselect[0]'> <input type='checkbox' class='input' name='closewin[$i]' value='$closeselect[1]'>$closeselect[1] </td><td> <input type='checkbox' class='input' name='closewin[$o]' value='$closeselect[2]'>$closeselect[2]</td> </tr>"; $i++; $o++; } ?> <tr><td align="right" colspan="2"><input type="submit" name="subclose" class="input" value="Close Round" /></td></tr> </table> </form> The html form appears like the following; Close Round / Update Leader Board / Credit PPC wins Pleae double check winners before submitting to close the round as once entered, to undo would be impossible. [checkbox] Hawthorn | [checkbox] Fremantle [checkbox]Western Bulldogs | [checkbox]Richmond [checkbox]Adelaide | [checkbox]Sydney [checkbox]Gold Coast | [checkbox]Brisbane Lions [checkbox]Collingwood | [checkbox]Geelong [checkbox]West Coast | [checkbox]St Kilda [checkbox]GWS Giants | [checkbox]Melbourne [checkbox]North Melbourne | [checkbox]Port Adelaide [checkbox]Essendon | [checkbox] Carlton and when submitted with all the right hand side 9 to 17 checkboxes selected it defaults to the left options; You have selected Hawthorn as the winner! --------------------------- You have selected Western Bulldogs as the winner! --------------------------- You have selected Adelaide as the winner! --------------------------- You have selected Gold Coast as the winner! --------------------------- You have selected Collingwood as the winner! --------------------------- You have selected West Coast as the winner! --------------------------- You have selected GWS Giants as the winner! --------------------------- You have selected North Melbourne as the winner! --------------------------- You have selected Essendon as the winner!
  8. Am i better off using a join or between statement and if possible please leave an example. I want to retrieve the current 'round' from my database. To do this i need to compare the current date and time to the 'gameround' table 'Date' and 'Time'. This is an example of the database im trying to work which round it is; CellID Round Home HODDS Away AODDS Ground Date Time status won lost 1 1 Collingwood 2.40 Fremantle 1.70 Etihad 2014-03-14 19:50:00 Lock None None 2 1 GWS Giants 15 Sydney 1.00 Skoda 2014-03-15 16:40:00 Lock None None 3 1 Gold Coast 2.50 Richmond 1.60 Metricon 2014-03-15 18:40:00 Lock None None Thanks
  9. 2 Western Bulldogs 0.00 North Melbourne 0.00 Etihad 2014-03-30 16:40:00 Open None None 3 1 GWS Giants 15 Sydney 1.00 Skoda 2014-03-15 16:40:00 Open None None Thats an example of the data input.
  10. Their isn't any input, or post data, its a function to work out what round it is from the db so i can compare it to the current date. Is that what you mean by input data?
  11. I want to extract the MIN, MAX AND ROUND from the database. Can i get the result i want through making $count[][][] into a multiple array ? $rouCount = mysql_num_rows(mysql_query("SELECT MIN(Date) , MAX(Date) , `Round` FROM `GameRound`")); for ($i = 0; $i < $rouCount; $i++){ $count = mysql_fetch_row(mysql_query("SELECT MIN(Date) , MAX(Date) , `Round` FROM `GameRound`")); foreach ($count as $k => $lokk){ $a = $lokk; echo "Rounds $a[0] $a[1] $a[2]<br />"; } } Eventually I need it to display; Round 1 2014-03-14 2014-03-23 Round 2 2014-03-24 2014-03-29 Round 3 2014-04-14 2014-04-23 Round 4 2014-05-24 2014-05-29 atm i get; Rounds 2 0 1 Rounds 2 0 1 Rounds 1
  12. By doing this though causes 9 submit buttons instead of just the one though
  13. Perfect; mysql_query("SELECT `Round` FROM `GameRound` WHERE `Date` BETWEEN `` AND ``"); But i still need to work out which dates it will go between
  14. In the database i need to extract the following information; Date, And return which round of game it is. Im sure their is a much better way and easier way than how im going about this, so if someone could improve the way im going about it would be awesome. There are 23 rounds. In each round there are 9 games. $round1 = mysql_fetch_row(mysql_query("SELECT MIN(Date) , MAX(Date) FROM `gamerounds` WHERE `round` = '1'")); $rounddate = date(); round one dates are from say 14th of March to 23rd of March, than round 2 will run from 27th of March to 1 of April if (($round1[0] >= $rounddate) && ($round1[1] <= $rounddate)){ echo "Round 1"; }else{ echo "Not round 1"; } I could do this for all 23 than compare them in a If and else code and eventually return what round it is but it would be like a page and im sure time wasting time and there has to be a better way
  15. Thanks @Ch0cu3r This is the output i get; Round: 1 - Beton: Draw - Pwnow: 1 Round: 1 - Beton: - Pwnow: 2 Round: 1 - Beton: - Pwnow: 3 Round: 1 - Beton: - Pwnow: 4 Round: 1 - Beton: - Pwnow: 5 Round: 1 - Beton: - Pwnow: 6 Round: 1 - Beton: - Pwnow: 7 Round: 1 - Beton: - Pwnow: 8 Round: 1 - Beton: - Pwnow: 9 That makes perfect sense, how would extract that first line as that is the line i need. Its radio option as they can only select on option out of the 9 rounds
  16. I have a while(); statement producing data from the mysql table. But every time I post the data.. It is defaulting to the last value. I'm out of ideas on how to resolve this. When i Check the html source its displaying the data correct but once posted its going to the last value. $start_date = date("Y/m/d", strtotime("- 7 days")); $end_date = date("Y/m/d", strtotime("+ 7 days")); $leader = mysql_query("SELECT information FROM `table` WHERE `Date` > '$start_date' AND `Date` < '$end_date'"); while ($redeal = mysql_fetch_row($leader)){ echo "<input type='hidden' name='round' value='$redeal[6]' />"; echo "<tr class='innertable'>"; echo "<td><input type='radio' name='beton' value='$redeal[0]' /></td>"; echo "<td align=left>$redeal[0]($<b>".number_format($redeal[3], 2)."</b>)</td>"; echo "<td>V</td>"; echo "<td><input type='radio' name='beton' value='$redeal[1]' /></td><td align=left>$redeal[1] ($<b>".number_format($redeal[4], 2)."</b>)</td>"; echo "<td align=left><input type='radio' name='beton' value='Draw' /> $51.00</td>"; echo "<td align=left>$redeal[2]</td>"; echo "<td align=left>$redeal[7]<br />$redeal[8]</td></tr><input type='hidden' name='pwnow' value='$redeal[5]' />"; <- }
  17. OKay that example makes sense, haha really font is no longer a go! It has been about 5 years since ive really done any coding, So I am playing catch up atm Thanks
  18. Also could you clear up how I would resolve the hidden input issue <input type='hidden' name='pwnow' value='$redeal[5]' /> Im gathering my other hidden input has the same issue but i haven't came across it yet since they all share the same value of '1'
  19. Thanks Psycho, worked perfect, == makes perfect sense. Could you give me a very short example of a more simplified approach instead of using multiple ifelse to check user data isn't malicious and correct data is entered that you would take?
  20. For some reason, my variable is changing its value to 'Draw' everytime. Draw is onyl one of 18 possible outcomes echo "[[[[[[[ $arrayTeam / $arrayBet / $arrayRound / $drawwww ]]]]]]]]]]]]]"; <-- At this point all variables are correct and than the below script isnt keeping thoses values. if (($checkBids > 0) && ($arrayTeam = 'Draw')){ mysql_query("UPDATE mysql_query("UPDATE echo "<font color='red'>You have updated your bid that <b>$fdraw[0]</b> and <b>$fdraw[1]</b> will draw round <b>$arrayRound</b>, placing <b>$arrayBet</b> PPC as your bet!</font>"; }elseif (($checkBids > 0) && ($arrayTeam != 'Draw')){ mysql_query("UPDATE mysql_query("UPDATE echo "<font color='red'>You have updated your bid for <b>$arrayTeam</b> to win on round <b>$arrayRound</b>, placing <b>$arrayBet</b> PPC!</font>"; }elseif (($checkBids < 1) && ($arrayTeam = 'Draw')){ mysql_query("UPDATE mysql_query("INSERT INTO echo "<table cellpadding='2' cellspacing='0' border='0' class='innnertable' width='620'>"; echo "<tr class='innertable'><td align='center'>"; echo "<font color='green'>You placed a bet that <b>$fdraw[0]</b> and <b>$fdraw[1]</b> will draw round <b>$arrayRound</b>, placing <b>$arrayBet</b> PPC as your bet!</font>"; echo "</td></tr></table>"; }elseif (($checkBids < 1) && ($arrayTeam != 'Draw')){ mysql_query("UPDATE mysql_query("INSERT INTO echo "<table cellpadding='2' cellspacing='0' border='0' class='innnertable' width='620'>"; echo "<tr class='innertable'><td align='center'>"; echo "<font color='green'>You placed a bet on <b>$arrayTeam</b> to win for round <b>$arrayRound</b>, placing <b>$arrayBet</b> PPC as your bet!</font>"; echo "</td></tr></table>"; Also im using a while statement to pull data from the mysql db, all values are fine except my hidden value keeps defaulting to the last value. $leader = mysql_query("SELECTxxxx while ($redeal = mysql_fetch_row($leader)){ echo "<input type='hidden' name='round' value='$redeal[6]' />"; echo "<tr class='innertable'>"; echo "<td><input type='radio' name='beton' value='$redeal[0]' /></td>"; echo "<td align=left>$redeal[0]($<b>".number_format($redeal[3], 2)."</b>)</td>"; echo "<td>V</td>"; echo "<td><input type='radio' name='beton' value='$redeal[1]' /></td><td align=left>$redeal[1] ($<b>".number_format($redeal[4], 2)."</b>)</td>"; echo "<td align=left><input type='radio' name='beton' value='Draw' /> $51.00</td>"; echo "<td align=left>$redeal[2]</td>"; echo "<td align=left>$redeal[7]<br />$redeal[8]</td></tr><input type='hidden' name='pwnow' value='$redeal[5]' />"; < THIS HIDDEN value displays the correct value but as soon as i post the its not correct. I checked the Html source to ensure the values are correct but in the php script its not recognizing the value and choosing the last value='9' instead of whats selected }
  21. I am attempting to build a football punting website with two teams and an option for a draw. Each week can be anywhere form one team playing or three. I need to catch the data from the checkboxes and the bet amount. Below is my code. I havent coded for a few years now and i cannot find anywhere on how to catch the data and turn it into a array, so i can sort each bet on the team checked and the bet and save the data into a mysql db. Any help thanks in advance <?php if (isset($_POST['beton'])){ $ints = NULL; foreach ($_POST['beton'] as $key => $value) { $ints .= "$value, "; } $ints = substr($ints, 0, -2); $interests = true; }else{ $interests = NULL; echo "No games selected!"; } //////////////////////////// BEt AMOUNT if (isset($_POST['amount'])){ $bet = NULL; foreach ($_POST['amount'] as $key => $value) { $bet .= "$value, "; } $bet = substr($bet, 0, -2); $interes = true; }else{ $interes = NULL; echo "No games selected!"; } if ($interests){ echo "$ints - $bet"; } // THIS SHOWS THE DATA but as one whole string, i need to split and shove it into an array $start_date = date("d/m/Y", strtotime("- 7 days")); $end_date = date("d/m/Y", strtotime("+ 7 days")); echo " $start_date - $end_date"; // Order by current time and date, must make function where if no bet is placed and time and date has passed minus 20 credits $leader = mysql_query("SELECT mysql data... ORDER BY `Date`"); while ($redeal = mysql_fetch_row($leader)){ echo "<tr class=innertable bgcolor=$bgcolor>"; echo "<td align=left>$redeal[0] ($<b>".number_format(0.00)."</b>)</td><td><input type='checkbox' name='beton[]' value='$redeal[0]' /></td>"; echo "<td>V's</td>"; echo "<td align=left>$redeal[1] ($<b>".number_format(0.00)."</b>)</td><td><input type='checkbox' name='beton[]' value='$redeal[1]' /></td>"; echo "<td align=left>$51.00 <input type='checkbox' name='beton[]' value='Draw-$redeal[5]-$redeal[6]' /></td>"; echo "<td align=left>$redeal[2]</td>"; echo "<td class=innertable align=right><input type='text' size='5' class='input' name='amount[]'></td></tr>"; } ?> <input type="submit" name="placebet" class="input" value="Submit my bet!" />
×
×
  • 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.