PHP Button Problem

Hello, I’m new to the forums figured you guys could help with an issue I’m having.

Basically, put I’m using mysql to fetch games from my database and using the ID’s fetched to let them join the game provided they can.

The Problem is, When the table of games is retrieved, It will only allow the player to click the first button “join” and all the other buttons won’t work.

Here’s some code snippet.
[php]
<?php
echo $row[‘amount’];
?>

<?php
if ($userData[‘username’] != $row[‘player1’]) {
echo ’

                                          <button type="button" id="join_game_submit" class="label label-success">Join </button>
                                        <input type="hidden" id="join_id" name="join_id" value="' . $row['id'] . '" />
                                    ';
                                                }
                                                ?>
                                            <a style="margin-left: 5px" href="game.php?id=<?php echo $row['id'] ?>"><span class="label label-primary">
									Watch
								</span></a>
                                                </form>[/php]

The button having the problem is the one named “Join”.

What is the rest of the code? I would be using links, styled as buttons if necessary, not buttons with hidden values.

Lets see the AJAX script processing the form.
Anyhow I would back [member=72272]astonecipher[/member] with using links instead.

So you would pick the id from the link using an AJAX POST with an id.
Because of this form is necessary anymore.
like so:

[php]

<?php echo $row['amount']; ?>

<?php if ($userData['username'] != $row['player1']) { echo 'Join'; } ?> Watch
[/php]

Join

';

??? Get rid of the hidden input, just add some value to the button itself and read that value, not some extra hidden form field!

More like: Join

NOTE: form fields type=“button” have no VALUE attached to them. Type=“submit” do. Mix the tag with a type of SUBMIT and you should be all set!

Sponsor our Newsletter | Privacy Policy | Terms of Service