Tony808 Posted November 15, 2013 Share Posted November 15, 2013 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! Quote Link to comment https://forums.phpfreaks.com/topic/283899-redirect-on-qualifer/ Share on other sites More sharing options...
KaiSheng Posted November 15, 2013 Share Posted November 15, 2013 Try using this to redirect header("Location: http://somesite.com"); Quote Link to comment https://forums.phpfreaks.com/topic/283899-redirect-on-qualifer/#findComment-1458316 Share on other sites More sharing options...
Tony808 Posted November 15, 2013 Author Share Posted November 15, 2013 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! Quote Link to comment https://forums.phpfreaks.com/topic/283899-redirect-on-qualifer/#findComment-1458447 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.