[Script] To put a catalogue in to alphabetical order.
Hey guys
I did see something for this the other night
but i went on a hunt for it and cant find it for the life of me!
All i need is some script that will put my catalogue in to alphabetical order,
Like i said i saw it the other night,
i should of saved it tbh i just did not think at all at the time!
Re: [Script] To put a catalogue in to alphabetical order.
Cant find it either. Seems like Joseph is deleting threads that are solved which is pretty stupid in my opinion.
Re: [Script] To put a catalogue in to alphabetical order.
Here is the code from that thread you mentioned.
PHP Code:
<?php
$db_host = "localhost";
$db_user = "root";
$db_pass = "pass";
$db_database = "db";
$connect = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
$db = mysql_select_db($db_database, $connect) or die(mysql_error());
//variables
$i = 1; // standard
$parent_id = 3; // -1 is the main tab.
$SQL_Query="SELECT * FROM `catalog_pages` WHERE `parent_id` = ".$parent_id." ORDER BY `caption` ASC";
$Result=mysql_query($SQL_Query);
While($data=mysql_fetch_array($Result)){
$Caption=$data["caption"];
$ID=$data["id"];
$SQL_Query2="UPDATE `catalog_pages` SET `order_num` = ".$i." WHERE id = '".$ID."'";
$Result2=mysql_query($SQL_Query2);
echo "The order_num of ".$Caption." is set to ".$i."<br />";
$i++;
}
?>
Re: [Script] To put a catalogue in to alphabetical order.
Quote:
Originally Posted by
Hejula
Here is the code from that thread you mentioned.
PHP Code:
<?php
$db_host = "localhost";
$db_user = "root";
$db_pass = "pass";
$db_database = "db";
$connect = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
$db = mysql_select_db($db_database, $connect) or die(mysql_error());
//variables
$i = 1; // standard
$parent_id = 3; // -1 is the main tab.
$SQL_Query="SELECT * FROM `catalog_pages` WHERE `parent_id` = ".$parent_id." ORDER BY `caption` ASC";
$Result=mysql_query($SQL_Query);
While($data=mysql_fetch_array($Result)){
$Caption=$data["caption"];
$ID=$data["id"];
$SQL_Query2="UPDATE `catalog_pages` SET `order_num` = ".$i." WHERE id = '".$ID."'";
$Result2=mysql_query($SQL_Query2);
echo "The order_num of ".$Caption." is set to ".$i."<br />";
$i++;
}
?>
Ah ha! i love you! (no homo)
I dont supose you would know if it works do you? as i dotn want to do it n then it just kills my cataloge lol
Thanks again dude!
Re: [Script] To put a catalogue in to alphabetical order.
Not sure to be honest, but it doesn't look like it will work. Not with the result you're after anyway.
Re: [Script] To put a catalogue in to alphabetical order.
Alright dude I'l give it a shot on a local server first