This Form works successfully, however, the Sub-Category list elements don’t appear in alphabetical order, even though I entered them into this script’s siteAdmin sub-category-input in alphabetical order. Is there a line of code that could direct the elements to appear in alphabetically order upon selecting the drop-down choices? Here’s the Form code:
It would be easier to figure out what this form is doing if you could fix the html errors in it first. Things start getting a bit jumbled when you place an <input> and a <table> inside an unordered list <ul> without them being inside list items <li>.
Thanks for your reply.
No, I’m not aware of an “ORDER BY” clause.
Are you suggesting that if the the db column used an ORDER BY clause to keep the sub-category-names column in alphabetical order, that the Forms’ related drop-down list elements would appear in alphabetical order?
Thanks for that reply.
Based on “it’s more the query that retrieves the data for display, rather than altering the column itself”, any idea as to what I might try, will be appreciated.
Thanks for your reply.
Can you please provide some more info, maybe an example, of what it would take having the query do it? Any additional clarification/explanation will be welcomed.
Or in the php uploader.php file (below), the sub-category(sub_cat) code seems to start aroung line 30.
I’m just looking for something to ‘display’ the drop-down choices in alphabetical order. Any ideas are appreciated.
<?php
include_once ('classes/config.php');
include_once ('classes/sessions.php');
include 'uploader_conlib.php';
$config['notification_error'] = $lang_error;
$page_title = $lang_upload_video;
if ($_SESSION['user_id'] == "") {
header("Location: $login_out_link");;
die();
}
$load_javascript = 1;
$ahah = 1;
$thickbox = 1;
//get channel data, create "select" form fields to load into form
$sql = "SELECT channel_id, channel_name FROM channels ORDER BY channel_name ASC";
$result1 = @mysql_query($sql);
$count_cats = @mysql_num_rows($result1);
$fields_all = '';
$sub_fields_all = '';
$show_fields = '';
$fields_all .= '<option value="99999">Select One</option>';
while ($result = @mysql_fetch_array($result1)) {
$fields_all .= '<option value="'.$result['channel_id'].'">'.$result['channel_name'].'</option>';
}
$sub_cat_choice = (int) mysql_real_escape_string( $_GET['sub_cat'] );
if ( $sub_cat_choice ) {
if ( $sub_cat_choice == '99999' ) {
$sub_fields_all .= '<select class="image_form" style="width:160px;" size="1" name="sub_cat">';
$sub_fields_all .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
$sub_fields_all .= '</select> ('.$lang_select.')';
echo $sub_fields_all;
die();
} else {
$sql2 = "SELECT * from sub_channels WHERE parent_channel_id = $sub_cat_choice";
$query = @mysql_query($sql2);
$sub_fields_all .= '<select class="image_form" style="width:160px;" size="1" name="sub_cat">';
$sub_fields_all .= '<option value="99999">Select One</option>';
while ($result2 = @mysql_fetch_array($query)) {
$count_subs = @mysql_num_rows($query);
$sub_fields_all .= '<option value="'.$result2['sub_channel_id'].'">'.$result2['sub_channel_name'].'</option>';
}
if ( $count_subs == '' ) {
$sub_fields_all .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
}
$sub_fields_all .= '</select> ('.$lang_select.')';
echo $sub_fields_all;
die();
}
}
// grab values from form if any
$form_submitted = $_POST['form_submitted'];
$title = $_POST['title'];
$description = $_POST['description'];
$tags = $_POST['tags'];
$location_recorded = $_POST['location_recorded'];
$allow_comments = $_POST['allow_comments'];
$allow_embedding = $_POST['allow_embedding'];
$public_private = $_POST['public_private'];
$channel = $_POST['channel'];
$sub_cat = $_POST['sub_cat'];
$thumbnail = $_POST['thumbnail'];
$new = $_POST['new'];
$procede = true;
$row = mysql_query("SELECT channel_name FROM channels WHERE channel_id = '$channel'");
while( $result = mysql_fetch_assoc($row) ) $channel_name = $result['channel_name'];
// validate form
if ($form_submitted == 'yes') {
$post_vid_upload_token = mysql_real_escape_string( $_POST['vid_upload_token'] );
if ( $post_vid_upload_token != $_SESSION['vid_upload_token'] ) {
//$spammer_msg = 'Spammer Bot detected!';
//die($spammer_msg);
die_spammer_alerts($referer);
}
foreach ($_POST as $key => $value) {
if ($key == 'title' || $key == 'description' || $key == 'tags' || $key == '$channel') {
if (!isset($value) || ($value == '')) {
$display_key = @str_replace('_', ' ', $key);
$error_message = $config['notification_error'];
$blk_notification = 1;
$error_message = $error_message . " - " . $display_key . " - $lang_required ";
$procede = false;
}
}
}
if ( $channel == '99999' ) {
$error_message = $config['notification_error'];
$blk_notification = 1;
$error_message = $error_message . " - $lang_select_channel";
$procede = false;
}
} else {
$procede = false;
}
// display page with form error
if ($procede == false && $form_submitted == 'yes') {
unset($_SESSION['vid_upload_token']);
$_SESSION['vid_upload_token'] = NULL;
$vid_upload_token = randomcode();
$_SESSION['vid_upload_token'] = $vid_upload_token;
$template = "themes/$user_theme/templates/main_1.htm";
$inner_template1 = "themes/$user_theme/templates/inner_upload_video_form.htm";
$TBS = new clsTinyButStrong;
$TBS->NoErr = true;
$TBS->LoadTemplate("$template");
$TBS->Render = TBS_OUTPUT;
$TBS->Show();
@mysql_close();
die();
}
// disply clean page
if (!isset($form_submitted) || ($form_submitted == '')) {
unset($_SESSION['vid_upload_token']);
$_SESSION['vid_upload_token'] = NULL;
$vid_upload_token = randomcode();
$_SESSION['vid_upload_token'] = $vid_upload_token;
$template = "themes/$user_theme/templates/main_1.htm";
$inner_template1 = "themes/$user_theme/templates/inner_upload_video_form.htm";
$TBS = new clsTinyButStrong;
$TBS->NoErr = true;
$TBS->LoadTemplate("$template");
$TBS->Render = TBS_OUTPUT;
$TBS->Show();
@mysql_close();
die();
}
if ($procede == true && $form_submitted == 'yes') {
//=================================START OF UPLOAD=================================
$THIS_VERSION = '2.0';
if (isset($_GET['cmd']) && $_GET['cmd'] == 'about') {
kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER VERSION = <b>" .
$UBER_VERSION . "</b><br>UU_FILE_UPLOAD = <b>" . $THIS_VERSION . "<b><br>\n");
}
$tmp_sid = md5(uniqid(mt_rand(), true));
///////////////////////////////////////////////////////////////////////
// This is where you might set your config file eg. //
// if($_SESSION['user'] == "tom"){ $config_file = 'uu_tom_config'; } //
///////////////////////////////////////////////////////////////////////
$config_file = $default_config_file;
$path_to_upload_script .= '?tmp_sid=' . $tmp_sid;
$path_to_ini_status_script .= '?tmp_sid=' . $tmp_sid;
if ($MULTI_CONFIGS_ENABLED) {
$path_to_upload_script .= "&config_file=$config_file";
$path_to_ini_status_script .= "&config_file=$config_file";
}
//allow form to be refilled on error
foreach($_POST as $key=>$value) {
$$key = $value;
}
$template = "themes/$user_theme/templates/main_1.htm";
$inner_template1 = "themes/$user_theme/templates/inner_upload_video.htm";
$TBS = new clsTinyButStrong;
$TBS->NoErr = true;// no more error message displayed.
$TBS->LoadTemplate("$template");
$TBS->Render = TBS_OUTPUT;
$TBS->Show();
@mysql_close();
die();
//===============================================================END OF UPLOADER================================================================
}
function die_spammer_alerts($referer) {
global $member_uploading, $user_ip, $admin_email, $site_name;
$subject = 'Possible Video Spamming !!';
$message = "The following member uploaded a possible spam video: => " . $member_uploading . "\n\n" . "The IP used: " . $user_ip . "\n";
$to = $admin_email;
$from = $site_name;
mail($to, $subject, $message, "From: Video demo site");
if ( $referer > '' ) $CONFIG_AUTO_BAN_SPAMMERS == 'YES';
if ( $CONFIG_AUTO_BAN_SPAMMERS == 'YES' ) {
$deny_ip = "deny from $user_ip\n" ;
$ban_file = '.htaccess';
$fo = fopen($ban_file,'a');
fwrite($fo,$deny_ip);
fclose($fo);
}
write_log($message);
}
function write_log($message) {
global $tracking_log_file;
if (@file_exists($tracking_log_file)) {
$fo = @fopen($tracking_log_file, 'a');
@fwrite($fo, $message);
@fclose($fo);
} else {
$fo = @fopen($tracking_log_file, 'w');
@fwrite($fo, $message);
@fclose($fo);
}
exit();
}
?>
As horrible and destined to die as that code is (execution day fast approaches), it already contains an example.
SELECT channel_id, channel_name FROM channels ORDER BY channel_name ASC
SELECT * from sub_channels WHERE parent_channel_id = $sub_cat_choice
SELECT channel_name FROM channels WHERE channel_id = '$channel'
SELECT * from sub_channels WHERE parent_channel_id = $sub_cat_choice
if this is the query that supplies the drop-down list you’re asking about, and add the ORDER BY clause. You need to ORDER BY the column name that you want it to appear in order of.
Thank you for your reply. Much appreciated.
The column that contains the sub-category names for the drop-down list is sub_channel_name.
So, that line should be changed to something like this?:
"SELECT * from sub_channels WHERE parent_channel_id = $sub_cat_choice ORDER BY sub_channel_name ";