Jump to content

Redirect on qualifer


Tony808

Recommended Posts

I have a SQL query that I want to qualify the output of:

 

## build the arrays for looping through sub links ##

$catArray[] = $row['fld_main_link_id'];

$text[]     = $row['fld_text'];

$ssL[]      = $row['fld_ss'];

$link[]     = 'index.php?id='.$row['fld_main_link_id'].'&ss='.$row['fld_ss'].'&'.$row['fld_link'];//$row['fld_link']

 

I want to re-write the URL based on the $catArray

 

for example, if catArray[] = 5 redirect to http://somesite.com

 

Is this possible? And if so, help? :)

 

Thanks!

Link to comment
Share on other sites

Thank you. 

 

Maybe I was not clear. I want to replace the URL that is created by this statement:

 

$link[]     = 'index.php?id='.$row['fld_main_link_id'].'&ss='.$row['fld_ss'].'&'.$row['fld_link'];//$row['fld_link']

 

with another web address, for example somesite.com

 

I thought that this would work:

 

if catArray[] = 4 $link[] = 'http://somesite.com';

 

but I end up with this error: Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/moc/public_html/nav.php on line 26

 

Line 26 is the line I added.

 

Here is the code I am working with, with my line added at the end:

 

sql = "SELECT * FROM tbl_main_links ORDER BY fld_main_link_id";
  #### Query 1 MAIN LINKS ####
                    $sql = "SELECT * 
                    FROM tbl_main_links ml
                    WHERE ml.fld_status ='1'
ORDER BY ml.fld_sort ";
$result = mysql_query($sql, $db_connection) or die(mysql_error());
$catArray = array(); 
                    $name     = array();
                    ## fetch an array ##
                    while ($row = mysql_fetch_assoc($result)):
                    
                    ## build the arrays for looping through sub links ##
                    $catArray[] = $row['fld_main_link_id'];
                    $text[]     = $row['fld_text'];
                    $ssL[]      = $row['fld_ss'];
                    $link[]     = 'index.php?id='.$row['fld_main_link_id'].'&ss='.$row['fld_ss'].'&'.$row['fld_link'];//$row['fld_link']
 
if catArray[] = 4 $link[] = 'http://somesite.com';
 
Thanks in advance for any assistance!
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.