Jump to content

[SOLVED] Path Array


rlb1

Recommended Posts

I am attempting to 'hide' a URL with the following code.  I have done this with this code being on another PHP page, but I would like to have the code on the same page if possible.

 

// Here is my attempt:

$path = array(

'Product' => '{$row['Manufacturer']}',
);

if (array_key_exists($_GET['Product'],$path))
    header('Location:'.$path[$_GET['Product']]);


print "  " http://www.domain.com/id=Product ;



//  Here is the one that worked (installed on another page)

<?php

$path = array(

'apparel' => 'http://www.amazon.com/b?%....',
'cameras' => 'http://www.amazon.com/b?%....',
'computers' => 'http://www.amazon.com/b?%....',
'electronics' => 'http://www.amazon.com/b?%....',
'jewelry' => 'http://www.amazon.com/b?%....',
'watches' => 'http://www.amazon.com/b?%....',
'toys' => 'http://www.amazon.com/b?%....',
'musicalinst' => 'http://www.amazon.com/b?%....',
);

if (array_key_exists($_GET['product'],$path))
    header('Location:'.$path[$_GET['product']]);
?>





//  Here is the full page code

Print " <DIV align=left> ";
Print " <A title=";
echo "  ".$row['Name'];
Print " href=";
echo "  ".$row['URL_Product'];    // This shows the URL of the 'actual' store, would like to hide this
Print " target=_blank> ";
Print " <H1> ";
echo "  ".$row['Name'];
Print " </H1></A>";
Print " <TABLE cellSpacing=5 cellPadding=0 width=100% border=0> ";
Print " <TBODY> ";
Print " <TR> ";
Print " <TD> ";
Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> ";
Print " <TBODY> ";
Print " <TR> ";
Print " <TD vAlign=top align=middle width=300> ";
Print " <DIV align=center> ";
Print " <A title=";
echo "  ".$row['Name'];
Print " href=";
echo "  ".$row['URL_Product'];
Print " target=_blank> ";
Print " <IMG src=";
echo "  ".$row['URL_Image_Large'];
Print " alt= ";
echo "  ".$row['Name'];
Print " border=0></A>     ";
Print " <BR> ";
Print " <SPAN class=text_9px>Retailer is responsible for this image.</SPAN> ";
Print " </BR> ";
Print " </DIV></TD> ";
Print " <TD vAlign=top height=200> ";
Print " <TABLE cellSpacing=0 cellPadding=0 width=100% align=left border=0> ";
Print " <TBODY> ";
Print " <TR> ";
Print " <TD> ";
Print " <DIV class=text_11px style=PADDING-LEFT: 15px> ";
Print " <A title=";
echo "  ".$row['Name'];
Print " href=";
echo "  ".$row['URL_Product'];
Print " target=_blank> ";
Print " <H4>";
Print " SKU: ";
echo "  ".$row['SKU'];
Print " </H4></A>";
Print " <A title=";
echo "  ".$row['Name'];
Print " href=";
echo "  ".$row['URL_Product'];
Print " target=_blank> ";
Print " <H4>";
Print " Manufacturer: ";
echo "  ".$row['Manufacturer'];
Print " </H4></A>";
Print " <DIV class=text_11px style=PADDING-BOTTOM: 5px> ";
echo "  ".$row['Description'];
Print " </DIV><BR> ";
Print " <DIV style=PADDING-BOTTOM: 5px; PADDING-TOP: 5px>";
Print " </DIV> ";
Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> ";
Print " <TBODY> ";
Print " <TR> ";
Print " <TD> ";
Print " <DIV><span class=textprice><STRONG>Price:</STRONG></span> ";
Print " <span class=textpricered><STRONG> $";
echo "  ".$row['Price'];
Print " </STRONG> ";
Print " </SPAN></DIV><BR></TD></TR><TR> ";
Print " <TD vAlign=center align=left> ";
Print " <A title=";
echo "  ".$row['Name'];
Print " href=";
echo "  ".$row['URL_Product'];
Print " target=_blank> ";
Print " <IMG src=addtocartbutton.gif align=bottom border=0></A> ";
Print " </TD></TR> ";
Print " <TR> ";
Print " <TD><BR> ";
Print " <DIV class=text_11px><STRONG>Tell a Friend</STRONG></DIV> ";
Print " </TD></TR><TR><TD><BR> ";
Print " <DIV class=text_11px><STRONG>Bookmark this Page</STRONG></DIV> ";
Print " </TD></TR> ";
Print " </TBODY></TABLE></DIV> ";
Print " </TD></TR></TBODY></TABLE> ";
Print " </TD></TR></TBODY></TABLE> ";
Print " </TD></TR></TBODY></TABLE> ";
Print " </DIV> ";
Print " <!-- end content --><!-- start footer --> ";
Print " <BR><BR> ";
Print " <HR> ";
Print " <DIV class=text_12px align=left>";
Print "<B>More Popular Products from";
echo "  ".$row['Manufacturer'];
Print " </B> ";
Print " </DIV> ";
Print " <BR> ";

Link to comment
Share on other sites

I think your problem is that you are trying to use a variable when setting the value of the array index, but you are enclosing it in single quotes. Variables are only interpreted within double quotes. Try this:

 

'Product' => "{$row['Manufacturer']}",

 

Also, always enclose your code in CODE tags in the forum.

Link to comment
Share on other sites

The code is not working...  I am thinking that their is something wrong with the array key??  I would like to have the "$path = array" code on the same page if possible?  If I put it on a different page, will the "{$row['URL_Product']}", variable carry over? 

 

Thanks for your help!!

 

$path = array(

 

'Product' => "{$row['URL_Product']}",

);

 

if (array_key_exists($_GET['id'],$path))

    header('Location:'.$path[$_GET['id']]);

 

 

 

 

 

 

 

 

 

Print " <DIV align=left> ";

Print " <A title=";

echo "  ".$row['Name'];

Print " href=";

echo "  ".$path['Product'];

Print " target=_blank> ";

Print " <H1> ";

echo "  ".$row['Name'];

Print " </H1></A>";

Print " <TABLE cellSpacing=5 cellPadding=0 width=100% border=0> ";

Print " <TBODY> ";

Print " <TR> ";

Print " <TD> ";

Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> ";

Print " <TBODY> ";

Print " <TR> ";

Print " <TD vAlign=top align=middle width=300> ";

Print " <DIV align=center> ";

Print " <A title=";

echo "  ".$row['Name'];

Print " href=";

Print "domain.com/music.php?id=Product";    //  Here is the link

Print " target=_blank> ";

Print " <IMG src=";

echo "  ".$row['URL_Image_Large'];

Print " alt= ";

echo "  ".$row['Name'];

Print " border=0></A>     ";

Print " <BR> ";

Print " <SPAN class=text_9px>Retailer is responsible for this image.</SPAN> ";

Print " </BR> ";

Print " </DIV></TD> ";

Print " <TD vAlign=top height=200> ";

Print " <TABLE cellSpacing=0 cellPadding=0 width=100% align=left border=0> ";

Print " <TBODY> ";

Print " <TR> ";

Print " <TD> ";

Print " <DIV class=text_11px style=PADDING-LEFT: 15px> ";

Print " <A title=";

echo "  ".$row['Name'];

Print " href=";

Print "domain.com/music.php?id=Product";    //  Here is the link

Print " target=_blank> ";

Print " <H4>";

Print " SKU: ";

echo "  ".$row['SKU'];

Print " </H4></A>";

Print " <A title=";

echo "  ".$row['Name'];

Print " href=";

Print "domain.com/music.php?id=Product";    //  Here is the link

Print " target=_blank> ";

Print " <H4>";

Print " Manufacturer: ";

echo "  ".$row['Manufacturer'];

Print " </H4></A>";

Print " <DIV class=text_11px style=PADDING-BOTTOM: 5px> ";

echo "  ".$row['Description'];

Print " </DIV><BR> ";

Print " <DIV style=PADDING-BOTTOM: 5px; PADDING-TOP: 5px>";

Print " </DIV> ";

Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> ";

Print " <TBODY> ";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.