in der hoffnung, dass ich das richtige erwischt habe....
Code: Alles auswählen
$sql = "INSERT INTO " . $table_prefix . "introportalmodnav (link_active, link_level, link_level_type, link_name, link_cat, link_sub, link_id) VALUES ('1','-1','2','".$link_name."' ,".$count_info['cat'].",".($count_info['sub']+1).",'0')";
// $sql = "INSERT INTO " . $table_prefix . "introportalmodnav (link_active, link_level, link_level_type, link_name, link_cat, link_sub, link_id) VALUES ('1','-1','2','".addslashes($link_name)."' ,".$count_info['cat'].",".($count_info['sub']+1).",'0')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't insert new sub", "", __LINE__, __FILE__, $sql);
}
} else
if ($mode=='new_cat')
{
$link_name = ( isset($HTTP_POST_VARS['link_name']) ) ? $HTTP_POST_VARS['link_name'] :
((isset($HTTP_GET_VARS['link_name'])) ? $HTTP_GET_VARS['link_name'] : 0);
$sql="SELECT MAX(link_cat) as cat, MAX(link_sub) as sub, max(link_id) as id FROM " . $table_prefix . "introportalmodnav GROUP BY link_cat ORDER BY link_cat DESC LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't fetch cat/sub/link count info", "", __LINE__, __FILE__, $sql);
}
$count_info = $db->sql_fetchrow($result);
$sql = "INSERT INTO " . $table_prefix . "introportalmodnav (link_active, link_level, link_level_type, link_name, link_cat, link_sub, link_id) VALUES ('1','-1','2','".$link_name."' ,".($count_info['cat']+1).",'0','0')";
//$sql = "INSERT INTO " . $table_prefix . "introportalmodnav (link_active, link_level, link_level_type, link_name, link_cat, link_sub, link_id) VALUES ('1','-1','2','".addslashes($link_name)."' ,".($count_info['cat']+1).",'0','0')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't insert new cat", "", __LINE__, __FILE__, $sql);
}
}
if ($mode=='edit')
{
// get the link
$sql="SELECT * FROM " . $table_prefix . "introportalmodnav WHERE link_cat='$cat' AND link_sub='$sub' AND link_id='$id'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't query links cat", "", __LINE__, __FILE__, $sql);
}
$link_info = $db->sql_fetchrow($result);
$sql="SELECT link_cat as cat, MAX(link_sub) as sub, max(link_id) as id FROM " . $table_prefix . "introportalmodnav GROUP BY link_cat";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Couldn't fetch cat/sub/link count info", "", __LINE__, __FILE__, $sql);
}
while($temp = $db->sql_fetchrow($result))
{
$count_info[$temp['cat']] = $temp;
}