|
PHP/MySQL problem driving me insane
|
|
02-07-2007, 04:29 PM
Post: #1
|
|||
|
|||
|
PHP/MySQL problem driving me insane
Ok so I am trying to get in to PHP and MySQL properly, however I have run in to a little problem that I just cannot get my head round.
I have 2 tables h2h_gameids - game_id = Auto incrementing number - name = name of the game (ie BF2, WOW, etc) - img = url for image link h2h_gamesplayed - user_id = user id of the person - 1 = corresponds to game_id in the h2h_gameids table - 2 = corresponds to game_id in the h2h_gameids table - 3 = corresponds to game_id in the h2h_gameids table - etc So new games can be added to the h2h_gameids table, which then adds a new column to the h2h_gamesplayed table with the name of the game_id. This bit works fine. The user can then bring up the list of games with a checkbox next to each one so they can select the games that they play. Again this bit works fine. However the user then clicks submit and it should add a 1 or 0 in to the column corresponding to game_id selected. I just cannot work this bit out at all. Here is the code so far for the selection screen: Code: <?phpAny of you uber coding monkeys know what I can do? If the columns in h2h_gamesplayed were static it would be simple, but I want it to expandable. - Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
11-07-2007, 01:44 PM
Post: #2
|
|||
|
|||
|
Rather than having a column for each game in the h2h_gamesplayed table, can't you just have a row for each game instead?
So the only columns you'd have in the link table would be: user_id - Corresponds to the user id game_id - Corresponds to the game id Then for your checkbox you'd have.. Code: <input type="checkbox" name="gameid[]" value="' . $gameid . '" />Code: <?phpJust a thought.
|
|||
|
12-07-2007, 02:12 PM
Post: #3
|
|||
|
|||
|
Thanks for the help Martin,
I managed get it working in a similar manner to what mentioned (without the array though). Although I then had to scrap the project as I was planning on making a plugin for the H2H site then cadet found one which was far better than anything I had planned, so no point re-inventing the wheel
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
12-07-2007, 02:15 PM
Post: #4
|
|||
|
|||
|
3 cheers for Cadet ?
![]() The Clan http://www.h2hclan.net The Dumping Ground http://www.cadetgfx.co.uk
|
|||
|
12-07-2007, 02:16 PM
Post: #5
|
|||
|
|||
|
cheers? you mean slaps?
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
12-07-2007, 04:53 PM
Post: #6
|
|||
|
|||
|
Can I do it?
|
|||
|
« Next Oldest | Next Newest »
|

Search
Member List
Calendar
Help






![[Image: 5f2kg5.gif]](http://i35.tinypic.com/5f2kg5.gif)


![[Image: riona-VICKY.png]](http://img.photobucket.com/albums/v289/spidrocks/riona-VICKY.png)