The order of categories can be changed using the category manager. This way only change the pos not change cid in categories database.
Why I need to change cid in category database?
I do totally new Flash Front_End and just use your system to register and upload the pictures.
I load the database like this:
<?
//Include database info
include("LFCZ.php");
// Create new service for PHP Remoting as Class.
class ServerLFCZ {
function ServerLFCZ() {
//Define the methodTable
$this->methodTable = array(
"doPost" => array(
"description" => "Writes Flash data to mySQL",
"access" => "remote"
),
"doReadAlbum" => array(
"description" => "Read data from mySQL and pass back assoc array",
"access" => "remote"
),
"doReadCategory" => array(
"description" => "Read data from mySQL and pass back assoc array",
"access" => "remote"
),
"doReadPicture" => array(
"description" => "Read data from mySQL and pass back assoc array",
"access" => "remote"
)
);
//Connect to MySQL and select database
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
$db = mysql_select_db(DB_NAME);
}
// Do post take an associative array (an Object in Flash) and puts
// the values in the array into the database. Returns an associative
// array (which comes back as an object) with a field 'status' which
// outlines the success or failure of the insertion into the database.
// doRead requests results, passes them back as a resultset which
// comes back as an instance of mx.remoting.RecordSet
function doReadAlbum($start) {
// Create SQL query
$sql = sprintf("SELECT * FROM LFCZPhoto_albums ORDER BY category");
// Trace the query in the NetConnection debugger
NetDebug::trace($sql);
// Run query on database
$result = mysql_query($sql);
NetDebug::trace(mysql_error());
// Return result
return $result;
}
function doReadCategory($start) {
// Create SQL query
$sqlCategory = sprintf("SELECT * FROM LFCZPhoto_categories ORDER BY cid");
// Trace the query in the NetConnection debugger
NetDebug::trace($sqlCategory);
// Run query on database
$resultCategory = mysql_query($sqlCategory);
NetDebug::trace(mysql_error());
// Return result
return $resultCategory;
}
function doReadPicture($start) {
// Create SQL query
$sql2 = sprintf("SELECT * FROM LFCZPhoto_pictures ORDER BY pid DESC");
// Trace the query in the NetConnection debugger
NetDebug::trace($sql2);
// Run query on database
$result2 = mysql_query($sql2);
NetDebug::trace(mysql_error());
// Return result
return $result2;
}
function doPost($in) {
// Create SQL statement
//Sender Information--------------------
$date = date("m/d/Y H:i:s");
$sendername = $this->escape($in['sendername']);
$senderphone = $this->escape($in['senderphone']);
$senderemail = $this->escape($in['senderemail']);
//-----------------------------------------------
$receiveremail = $this->escape($in['receiveremail']);
$msg = $this->escape($in['pmsg']);
$userpid = $this->escape($in['opid']);
$nsname = $this->escape($in['sname']);
$nsphone = $this->escape($in['sphone']);
$nsemail = $this->escape($in['semail']);
$nsmsg = $this->escape($in['smsg']);
$nstime = $this->escape($in['stime']);
$ip=$_SERVER['REMOTE_ADDR'];
$sql3 = sprintf("INSERT INTO LFCZPhoto_comments (pid, msg_body, msg_date, msg_raw_ip ) VALUES ('$userpid', '$msg', NOW(),'$ip')" );
// Trace the query in the NetConnection debugger
NetDebug::trace($msg);
NetDebug::trace($userpid);
NetDebug::trace($ip);
NetDebug::trace($sql3);
NetDebug::trace(mysql_error());
mb_language("Neutral");
mb_internal_encoding("UTF-8");
mb_http_input( "UTF-8" );
mb_http_output( "UTF-8" );
mb_detect_encoding("auto");
mb_substitute_character("long");
ob_start("mb_output_handler");
$message = "
$nsname $sendername\n
$nsphone $senderphone\n
$nsemail $senderemail\n
$nsmsg $msg \n
$nstime $date\n
IP: $ip\n";
mb_send_mail("$receiveremail","$sendername",
$message,"FROM:$senderemail");
// Run query on database
$result3 = mysql_query($sql3);
// Check to see if the query did what it should have and return
if (mysql_affected_rows() == 1) {
return array("status" => "success");
} else {
return array("status" => "failtest");
}
}
// escape is a private method used for escaping strings before putting them
// in the db. Otherwise you will have issues with ' (quotes).
// You don't have to declare it in the methodTable since you
// won't call it remotely. mysql_real_escape_string is considered more
// secure than addslashes. You might want to do sanity check here too.
function escape($string)
{
return mysql_real_escape_string(htmlspecialchars($string));
}
}
?>
$sqlCategory = sprintf("SELECT * FROM LFCZPhoto_categories ORDER BY cid");
If i insert a new category and it will be last cid. it's position is last one. But I want it will be in somewhere. that's why i want change cid in categories database.
Is it possible to change CID in categories database?
Yours sincerely
Jian Zhan