I am trying to make a list of players and display them on a page, then I want to show their scores on a new page when a players name is clicked, how can i do this, this is a wordpress plugin. functions.php function bowling_players_list() { include('shortcodeplayers.php'); } add_shortcode('bowlingplayers', 'bowling_players_list'); PHP: shortcodeplayers.php <?php //Browse the results global $wpdb; $table = $wpdb->prefix . "bowling_plus_players"; $req = "SELECT * from $table order by player_name;"; //TODO Test variable $res = mysql_query($req); $number = mysql_num_rows($res); if ($number == 0) { _e('No results for the moment', 'Bowling_Plus'); } else { while ($games = mysql_fetch_array($res)) { echo '<table border="1"><tr><td>'; echo '<a href="template.php?playerid=' . urlencode( $games['player_id'] ) . '">'; echo $games['player_name'] . $games['player_lname'] . '</a>'; echo '</td></tr></table>'; } } ?> PHP:
Assuming there's a 'score' field in the table [COLOR=#b1b100]while[/COLOR] [COLOR=#009900]([/COLOR][COLOR=#000088]$games[/COLOR] [COLOR=#339933]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"][COLOR=#990000]mysql_fetch_array[/COLOR][/URL][COLOR=#009900]([/COLOR][COLOR=#000088]$res[/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR] [COLOR=#b1b100]echo[/COLOR] [COLOR=#0000ff]'<table border="1"><tr><td>'[/COLOR][COLOR=#339933];[/COLOR] [COLOR=#b1b100]echo[/COLOR] [COLOR=#0000ff]'<a href="template.php?playerid='[/COLOR] [COLOR=#339933].[/COLOR] [URL="http://www.php.net/urlencode"][COLOR=#990000]urlencode[/COLOR][/URL][COLOR=#009900]([/COLOR] [COLOR=#000088]$games[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'player_id'[/COLOR][COLOR=#009900]][/COLOR] [COLOR=#009900])[/COLOR] [COLOR=#339933].[/COLOR] [COLOR=#0000ff]'">'[/COLOR][COLOR=#339933];[/COLOR] [COLOR=#b1b100]echo[/COLOR] [COLOR=#000088]$games[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'player_name'[/COLOR][COLOR=#009900]][/COLOR] [COLOR=#339933].[/COLOR] [COLOR=#000088]$games[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'player_lname'[/COLOR][COLOR=#009900]][/COLOR] [U][COLOR=#339933].[/COLOR] ' '.[COLOR=#000088]$games[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'player_score'[/COLOR][COLOR=#009900]][/COLOR][/U]. [COLOR=#0000ff]'</a>'[/COLOR][COLOR=#339933];[/COLOR] [COLOR=#b1b100]echo[/COLOR] [COLOR=#0000ff]'</td></tr></table>'[/COLOR][COLOR=#339933];[/COLOR] [COLOR=#009900]} [/COLOR] Code (markup): or whatever the score field is called.
Thanks, but I want it to go to a new page that only shows scores, I have not created template.php yet since I dont know what to put in it or if thats even the right way to go. The current page is http://127.0.0.1/?page_id=1 how to i generate a new page with only the scores when the link is clicked?
You'd have to write a whole PHP file, opening the database, selecting the data you want and displaying it in the browser. The same way this page works, but only for scores. BTW, giving us a link to your computer doesn't help us much - we can't connect to it.
I know, and I know. My problem is I want to keep this file in the plugin folder and still use the wordpress theme, I dont know how to do this part. The link I used was just to show how I was calling the page, not show the site, sorry.
Just put the new file in the plugin folder and redirect to it when the user presses the "show me the scores" link or button. As far as the theme, if this file uses the theme, and the new one is a copy of this one that you just change the SQL statement and display on, it'll use the theme.