Pass HTML Value to Jquery to display new table
Hello,
Hopefully this forum can help me. I am new to jQuery. I have a table that displays information from MySQL and I want to have one of the cells (Date) be a clickable link to display another table. This is my table cell
- <td><a href="#" onclick=display() id="astat" value="<?php $player; ?>"><?php echo $d->current()->gamedate; ?></a></td>
display() is my jQuery function. I am trying to use jQuery to process the php variable (table id #) to kick off another mysql query to populate another table. I am at a loss as to what this function should look like or if I am even close?
This is what I have as my function:
- $(function display(){
- <php
- $list = $pdo->query("SELECT player.player_id, game.player_id, game.pposition, game.pgoalsfor, game.pgoalsagainst, game.psog, game.ppk, game.pyellowcards, game.predcards
- FROM game, player
- WHERE game.player_id = '$player'");
- $data = $list->fetchAll(PDO::FETCH_OBJ);
- $aid = new ArrayIterator($data);
- ?>
- });
That function should then populate the below table.
- <tbody>
- <tr>
- <td><?php echo $aid->current()->pposition; ?></td>
- <td><?php echo $aid->current()->pgoalsfor; ?></td>
- <td><?php echo $aid->current()->pgoalsagainst; ?></td>
- <td><?php echo $aid->current()->psog; ?></td>
- <td><?php echo $aid->current()->ppk; ?></td>
- <td><?php echo $aid->current()->pyellowcards; ?></td>
- <td><?php echo $aid->current()->predcards; ?></td>
- <td><?php echo $player; ?></td>
- </tr>
Any help would be greatly appreciated. I have been Googling awhile and can't seem to figure this out. I am assuming there should be ajax in this somewhere but not sure if it can be done without it?