Jump to content

Bradley99

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Bradley99's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks for moving Kicken, also thanks for the help, worked perfect
  2. Hi, I have some code, which works, but not the way i wan't it too. The code should take win_points from each user in the BETTING table & Add them up, i.e giving the sum. Then the JOIN would display the username linking to the user_id from the betting table. What it's doing now is just displaying me (Admin - User ID #1) with the SUM of ALL win_points of EVERY user in the BETTING table. ANy idea's? Thanks <? $standing=mysql_query("SELECT username, SUM(b.win_points) as total_points FROM users AS u LEFT JOIN betting AS b ON b.user_id = id ORDER BY total_points"); while($the=mysql_fetch_object($standing)){ echo " <tr><td class='profilerow'>$the->username</td><td class='profilerow'>$the->total_points</td> </tr>"; } ?>
  3. Hi, I'm trying to fetch a number of columns from two different tables in a database. I'm using the following code to fetch the first set of info. . $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewevent' AND id IN (SELECT fight_id FROM betting WHERE user_id='$user->id') ORDER by id ASC"); while($the=mysql_fetch_object($showevent)){ I need to use this code to fetch the second set: $showpick = mysql_query("SELECT * FROM betting WHERE event='$viewevent' AND user_id='$user->id'"); while($pick=mysql_fetch_object($showpick)){ I need the results in a table like so. . Red Corner - Blue Corner - Event - My Pick - Winner $the->f1 - $the->f2 - $viewevent - $pick->fighter_id - $pick->winner I need the results from the first query to MATCH the results from the second query. These can be matched by the fight_id from both tables. I just have no clue how to write the query for it.
  4. So. . if ($_POST['Submit']){ $category = $_POST['selectname']; { mysql_query("INSERT INTO category (`category`) VALUES ("'$category'')") or die (mysql_error()); mysql_query("INSERT INTO linkcategory (`category`) VALUES ("'$category'')") or die (mysql_error());
  5. With your IF Post submit code, I presume you'll have an INSERT INTO category. . . Just add another INSERT INTO underneath that to enter it into the other column.
  6. I've managed to do it a different way now, thanks for the help. Can anyone tell me if the bold part of this code is valid. . . $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewevent' [b]AND id IN (SELECT fight_id FROM betting WHERE user_id='$user->id')[/b] ORDER by id ASC"); while($the=mysql_fetch_object($showevent)){
  7. Sorry, I'm terrible at explaining my problems. My question is basically how do I get them to align, please don't tell me i just add order by fight_id at the end of the second query?
  8. I am selecting from FIGHTS table WHERE the event column is $viewevent (this is determined by which event is selected by user) AND id (of the fight) column is in the BETTING table WHERE the users id is $user->id. Then order it by id. That sorts the first 3 columns in my code ($the-fighter1, $the-fighter2 & $viewevent). The next two i need fetching from the BETTING table. So i would use. . Select from BETTING table WHERE the event column is $viewevent AND the id of the fight is the same id as the corresponding result.
  9. That's because $the-> is used when fetching from the FIGHTS table. . . $viewpick is already determined in above code. The ones without any $the-> atall are the ones i need to be called from the BETTING table, But i Cannot figure out how to call from 2 tables in the same query, as the FIGHTS info needs to coincide with the BETTING info. So - Fighter1 vs Fighter 2 & Event are determined from the fights table, i then need to fetch the pick of which that user chose in the BETTING table (fighter_id) & the winner of that fight, again from the BETTING Table (winner), The two would be aligned by the fight_id.
  10. Hi guys, I'm having some problem with a piece of code, which should be displaying 5 things from 2 different tables. Here's my code: <? $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewpick' AND id IN (SELECT fight_id FROM betting WHERE user_id='$user->id') ORDER by id ASC"); while($the=mysql_fetch_object($showevent)){ echo " <tr><td class='subtableheader' colspan='1'>Red Corner</td> <td class='subtableheader' colspan='1'>Blue Corner</td> <td class='subtableheader' colspan='1'>Event</td> <td class='subtableheader' colspan='1'>My Pick</td> <td class='subtableheader' colspan='1'>Winner</td></tr> <tr><td class='profilerow' colspan='1'>$the-fighter1</td> <td class='profilerow' colspan='1'>$the->fighter2</td> // Above 2 are fetched from the FIGHTS table. . <td class='profilerow' colspan='1'>$viewpick</td> //Below 2 should be fetched from BETTING table, but should coincide with the results from the FIGHTS table. <td class='profilerow' colspan='1'>$fighter_id</td> <td class='profilerow' colspan='1'>$winner</td></tr> </tr>"; } Any help is appreciated.
  11. I've read up quit alot on this but can't seem to get it to work. Basically what I wan't to do with the following code: <? $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewevent' AND id NOT IN (SELECT fight_id FROM betting WHERE user_id='$user->id') ORDER by id ASC"); while($the=mysql_fetch_object($showevent)){ if($user->bonusp == "0") { $msg = "<form action='' method='post'> <tr> <td colspan='100%' class='TableHeading'> <b>$the->fighter1 Vs $the->fighter2</b></td> </tr> <tr><td class='profilerow' colspan='100%'><img src='http://fightclub.mmamount.com/eng/fighters/$the->fighter1.png' alt='$the->fighter1'/><img src='http://fightclub.mmamount.com/eng/fighters/versus.png' alt='VS'/><img src='http://fightclub.mmamount.com/eng/fighters/$the->fighter2.png' alt='$the->fighter2'/></td></tr> <tr><td class='profilerow' colspan='2%' align='left'><input type=radio name=fighter_id value=$the->fighter1> $the->fighter1 </td><td class='profilerow' colspan='20%'> <input type=radio name=fighter_id value=1> Draw</td><td class='profilerow' colspan='78%'> <input type=radio name=fighter_id value=$the->fighter2> $the->fighter2 </td></tr> <tr><td class='profilerow' colspan='3%'>Method:</td> <td class='profilerow' colspan='97%'><select name=method><option value=KO>Knockout</option><option value=TKO>TKO</option><option value=SUB>Submission</option><option value=DEC>Decision</option></select></td></tr> <tr><td class='profilerow' colspan='3%'>Round:</td> <td class='profilerow' colspan='97%'><select name=round><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option></select></td></tr> <tr><td class='profilerow' colspan='3%'>Use Bonus?</td> <td class='profilerow' colspan='97%'>You have 0 Bonus points to use</td> <input type='hidden' name='bonus' value='0'></tr> <input type='hidden' name='fight_id' value='$the->id'> <tr><td class='profilerow' colspan='3%'>Finished?</td> <td class='profilerow' colspan='97%'><input type='Submit' name='Submit2' value='Pick' class='Submit' /> </td></form> </tr>"; Is code it so that if Decision is chosen from Method, Then the Round selection is automated (Unchangeable) to be whatever the amount of rounds in the fights is, which will be determined by the rounds column in my fights table. Thanks
  12. Sorted, I keep wasting posts because 2 minutes later i figure the answers, goddam! I used $newbonus=$user->bonusp-$bonus; Then in query used SET bonusp = '$newbonus' Thanks
  13. Hi, I'm trying to update a table when a form is submitted, so that the column I'm updating is updated by minus one of the values in the form. Here's my update code: mysql_query("UPDATE users SET bonusp = 'bonusp-$bonus' WHERE id='$user->id'") or die (mysql_error()); $bonus has a value of either 0 or 1. When i submit with the code i have, it just sets the bonusp in users table to 0. Thanks
  14. Sorted it, Just added $viewevent=$_GET['viewevent']; $bonusdone = mysql_query("SELECT * FROM betting WHERE user_id='$user->id' AND fight_id='0'"); if ( mysql_num_rows( $bonusdone ) == 1 ) exit(); Right before the html code.
×
×
  • 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.