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") &#123;$goto =  "bolt.php"; &#125;
if ($weapon = "Short_Sword") &#123;$goto =  "sword.php"; &#125;

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)) &#123;
  if ($weapon = "Bolt_Thrower") &#123;$goto =  "bolt.php"; &#125;
  if ($weapon = "Short_Sword") &#123;$goto =  "sword.php"; &#125;
&#125;
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&#1111;'NAME'] = 'bolt thrower';
$href = str_replace(' ', '_', $WEAPON&#1111;'NAME']).'.php';
echo '&lt;a href="'.$WEAPON&#1111;'NAME'].'" target="_blank"&gt;';
would give you

Code: Select all

&lt;a href="bolt_thrower.php" target="_blank"&gt;
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?