Hi all, recently had a thread discussing surrogate and natural keys in the database. Anyway I've got to the point now were I'm using a natural key and querying my database by 'venue name' and using str_replace, but my problem is I dont know how to switch it back to display correctly on my page?
I have two bit's of code:
Show venue and details
PHP Code:
<?php
require_once('includes/mysql_connect.inc.php');
$sql = "SELECT venue,comments,address FROM venues WHERE venue=" . mysql_real_escape_string($_GET['venue']);
$result = @mysql_query($sql) or die('Error: ' . mysql_error());
while ($row = mysql_fetch_array ($result)) {
echo '<h5>' . $row['venue'] . '</h5><h4><strong>' . $row['comments'] . '</strong></h4><p></p><h3>Location: ' . $row['address'] .'</h3>';
}
?>
Show venue links
PHP Code:
<?php
$query = "SELECT venue FROM venues WHERE category=1";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res))
echo "<a href=\"venue/".str_replace(" ", "-", $row['venue'])."\">{$row['venue']}</a><br>\n";
?>
.str_replace(" ", "-" was added so i can query my table and have the venue names display in my address bar for seo reasons, but how do I run that back through str_replace to make the '-' all be ' '??
making sense? thanks in advance!
Bookmarks