Page 1 of 1
target=_blank Problem
Posted: Mon Nov 04, 2002 8:23 pm
by Karl
Well this is for the weapons in my game, some of which have space in their names, for example "Bolt Thrower" so when the link is...
<a href=$WEAPON[NAME] target=_blank>
The url is only /Bolt.php instead of Bolt_Thrower :-\ anyone know how this problem could be solved?
comparison chart?
Posted: Mon Nov 04, 2002 9:41 pm
by mindmeddler2002
Maybe make some header file, or include...
that checks the URL
have all the links go here...
linkexchance.php
Code: Select all
<?php
if ($weapon = "Bolt_Thrower") {$goto = "bolt.php"; }
if ($weapon = "Short_Sword") {$goto = "sword.php"; }
echo "<META HTTP-EQUIV=Refresh CONTENT=0;URL=$goto>";
?>
that is just if u want to go to the corasponding page...
if u needed to save info from the last page, pass it back along
replace
Code: Select all
echo "<META HTTP-EQUIV=Refresh CONTENT=0;URL=$goto>";
with
Code: Select all
echo "<META HTTP-EQUIV=Refresh CONTENT=0;URL=$goto?weapon=$weapon&target=$target>";
another thing is that if $weapon is not in all the pages, as part of the link, u could place all the different vars, into a set.
Code: Select all
if (isset($weapon)) {
if ($weapon = "Bolt_Thrower") {$goto = "bolt.php"; }
if ($weapon = "Short_Sword") {$goto = "sword.php"; }
}
this would prevent errors if u had a link go there without the weapon var set... but if u needed to vars to decide the corasponding link....
then its a bit more complicated, tell me if u use this!
laters
Posted: Tue Nov 05, 2002 2:19 am
by twigletmac
Try using
str_replace() to replace the spaces with underscores and don't forget to use quotes in your HTML:
Code: Select all
$WEAPONї'NAME'] = 'bolt thrower';
$href = str_replace(' ', '_', $WEAPONї'NAME']).'.php';
echo '<a href="'.$WEAPONї'NAME'].'" target="_blank">';
would give you
Code: Select all
<a href="bolt_thrower.php" target="_blank">
Mac
Re: target=_blank Problem
Posted: Tue Nov 05, 2002 5:52 am
by DeGauss
Karl wrote:<a href=$WEAPON[NAME] target=_blank>
You are wrapping quotes around those A attributes, right?
Also, is $WEAPON an array? If so, is it a two-dimensional array?