Forum Moderators: coopster
So typical rows might be:
Wayne Rooney, Manchester Utd, Attacker, 12, 3
Steven Gerrard, Liverpool, Midfielder, 8, 1
David James, Portsmouth, Goalkeeper, 0, 0
What I want is for Wayne Rooney to have his own page though, such as www.mysite.com/wayne-rooney
This is where I'm still confused - would your-script.php be my player template file, but with some extra code in it to output the HTML page?
Then another separate page for Steven Gerrard (www.mysite.com/steven-gerrard
Is that what this line does:
<?php do { ?>
<p><a href="http://localhost:8888/players/<?php echo $row_urls['player_url']; ?>"><?php echo $row_urls['firstname']; ?> <?php echo $row_urls['lastname']; ?></a></p>
<?php } while ($row_urls = mysql_fetch_assoc($urls)); ?> <IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^players\/*.* /your-script.php [R=301,L]
</IfModule> <?php require_once('Connections/connPHP.php'); ?>
<?php
mysql_select_db($database_connPHP, $connPHP);
$query_rsData = "SELECT * FROM player";
$rsData = mysql_query($query_rsData, $connPHP) or die(mysql_error());
$row_rsData = mysql_fetch_assoc($rsData);
$totalRows_rsData = mysql_num_rows($rsData);
?> <?php mysql_free_result($rsData); ?> $path_array = explode('/',$_SERVER{'REQUEST_URI'});
// make sure the first one is not blank. If it is,
// shift it off the array.
if (empty($path_array[0])) { $dump_it = array_shift($path_array; }
// We know index 0 is "players"
$player_url = $path_array[1];
$query = "Select player_id FROM players WHERE player_url='$player_url'";
//Execute that query, if found,
$_GET['player_url'] = $row[0];
if (! isset($_GET['player_url']) or (isset($_GET['player_url']) and ! is_numeric($_GET['player_url']) and ! ($_GET['player_url'] > 0)) {
// do some default here
} $path_array = explode('/',$_SERVER['REQUEST_URI']);
echo "URI is " . $_SERVER['REQUEST_URI'] . " and path_array is " . print_r($path_array) . " <br>\n";
// make sure the first one is not blank. If it is,
// shift it off the array.
if (empty($path_array[0])) { $dump_it = array_shift($path_array); } // NOTE I had an error here
Shouldn't that have produced something like this:
While you're thinking about all of this, how are you going to cope if there are two different players with the same name?
<?php
$path_array = explode('/',$_SERVER['REQUEST_URI']);
echo "URI is " . $_SERVER['REQUEST_URI'] . " and path_array is " . print_r($path_array) . " <br>\n";
?>