blueman378 Posted December 25, 2007 Share Posted December 25, 2007 hi guys i have this problem i just noticed that the link prints the name perfect however it only prints the first word of the name in the actual url, and this causes it to on any names that are longer than one word to instead of having a link like beat em up its just beat, this would be fine but it means that this code <?php //gameform global $database; $q = "SELECT cName FROM " . gsubcat . " ORDER BY `cName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); ?> | <?php while( $row = mysql_fetch_assoc($result) ) { echo "<a href=".$row[cName].".php>".$row['cName']."</a> | "; } ?> does not work as the .php is not printed on any links longer than one word Quote Link to comment Share on other sites More sharing options...
raku Posted December 25, 2007 Share Posted December 25, 2007 It may be because there is a space character in the url. You could try a function that replaces whitespace with an underscore after the name is retrieved from the database so that nothing needs to be changed in the data. Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 25, 2007 Author Share Posted December 25, 2007 or possibly change it with %20, do you think that would solve it? Quote Link to comment Share on other sites More sharing options...
raku Posted December 25, 2007 Share Posted December 25, 2007 It might, but an underscore may look cleaner in your URL. You could just also merge them, then have php split the string at the next capital letter. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 25, 2007 Share Posted December 25, 2007 Put the value of the URL in quotes. That will automatically cause the browser to encode the space. <?php echo '<a href="' . $row[cName] . '.php">' . $row['cName'] . '</a> | '; ?> Ken Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 25, 2007 Author Share Posted December 25, 2007 thanks ken that worked Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.