Hi All
Just working on a quick script to generate the URL rewrite file for a site.
I need to use strlen in an 'if else' statement for part of it and I cant get it to work.
This is the code
I have tried all sorts. I need to run the first chunk of code for the when there are two characters in the ID and the second chunk when there is one.
Thanks in advance
Aaron
Just working on a quick script to generate the URL rewrite file for a site.
I need to use strlen in an 'if else' statement for part of it and I cant get it to work.
This is the code
Code:
$file= fopen("rewrite_rules.txt", "w");
$_xml = 'rewrite file category rules\r\n;';
// Select all categories //
mssql_select_db('***', $conn);
$sql = "SELECT * FROM categories where hideshow = '1'";
$result = mssql_query($sql);
while($row = mssql_fetch_array($result)){
if (strlen($row['id']) == 2) {
$_xml .="RewriteRule /".$row['urlrewrite']." /display_products.asp?id=".$row['id']." [I,L]\r\n";}
else {
$_xml .="RewriteRule /".$row['urlrewrite']." /browse_category.asp?id=".$row['id']." [I,L]\r\n";}
}
fwrite($file, $_xml);
fclose($file);
echo "Rewrite rules written";
I have tried all sorts. I need to run the first chunk of code for the when there are two characters in the ID and the second chunk when there is one.
Thanks in advance
Aaron