Visualizzazione risultati 1 fino 7 di 7

Discussione: Aiuto Ordinamento Array

  1. #1
    Guest

    Predefinito Aiuto Ordinamento Array

    Gente!

    Per il mio sito servirebbe uno script php che mi faccia l'ordinamento delle recensioni e dei gruppi in modo: per nome, sottogerenere (solo metal) e paese di provenienza

    Cioè, mi spiego meglio: se io infilo due recensioni, queste mi si devono mettere da sole in ordine alfabetico.
    Se vado a vedere un gruppo metal e voglio vederlo tramite il sottogenere o il paese, vorrei che fosse possibile farlo

    Ora, io so che bisogna farlo in array, ma dato che io sono esonerato a fare informatica a scuola (causa progetto individuale scolastico) mi sono fermato a

    Codice:
    array()
    -.-

    Mi aiutate?
    Ultima modifica di metaphor : 12-12-2005 alle ore 21.15.27

  2. #2
    Ospite Guest

    Predefinito

    Che c'entra con questa sezione???
    Sposto in livello 3.

    Zau!

  3. #3
    L'avatar di Evcz
    Evcz non è connesso Utente storico
    Data registrazione
    31-05-2002
    Residenza
    Vicenza
    Messaggi
    5,670

    Predefinito

    per l'ordinamento degli array puoi usare:

    http://www.php.net/sort

    da come esponi il problema invece sembra di più ampio respiro...

    se hai tanti testi/canzoni etc.. io vedrei molto meglio un database appoggiato a mysql da cui prelevare i dati di volta in volta già ordinati e tutto...
    There are three kinds of people in this world: people who watch things happen ... people who complain about things that happen ... and people who make things happen...

  4. #4
    Guest

    Predefinito

    Pare brutto aprire un altro topic per un problema molto vicino, ergo!
    Il problema di cui sopra ho risolto, ora ho problemi nella sezione midi, cioè:
    Io vorrei che si mettessero in ordine alfabetico, ma nn si mettono nemmeno col sort :(

    help..
    Ultima modifica di metaphor : 19-12-2005 alle ore 13.50.37

  5. #5
    Guest

    Predefinito

    ho dovuto fare un altro post sennò nn si vedeva in prima pagina

  6. #6
    L'avatar di Evcz
    Evcz non è connesso Utente storico
    Data registrazione
    31-05-2002
    Residenza
    Vicenza
    Messaggi
    5,670

    Predefinito

    posta il codice

    e ripeto: in mysql ti basterebbe un ORDER BY....
    There are three kinds of people in this world: people who watch things happen ... people who complain about things that happen ... and people who make things happen...

  7. #7
    Guest

    Predefinito

    N.B: è uno script che ho trovato su internet nn l'ho fatto io

    Codice:
    <?php
    
    
    
    
    
    	// main configuration------------------------------------------------------------------------------------------------------------------------------
    	
    	$standalone		= "true";
    	
    	$custom_script_name	= "index.php";
    
    	$enable_stats		= "true";
    
    	$download_stats_file	= "./download_stats";
    
    	$download_folder	= "./none_files/";
    
    	$auto_create_filelist	= "true";
    
    
    
    	// standalone modus configuration-----------------------------------------------------------------------------------------------------------
    	
    	$headline_string	= "Lista Midi";
    
    //################################################################################
    //###									####
    //###	CONFIGURATION - ends here						####
    //###									####
    //###	!!! don't edit anything above, except you know what you are doing !!!		####
    //###									####
    //################################################################################
    
    	$download	= $_GET["download"];
    	$SCRIPT_NAME	= getenv("SCRIPT_NAME");
    
    	// auto create download filelist-------------------------------------------------------------------------------------------------------------
    
    	if ($auto_create_filelist=="true") {
    		unset($download_filelist);
    		$current_dir=getcwd();
    		chdir($download_folder);
    		$directory=dir("./");
    		while ($file = $directory->read()) {
    			if (is_file($file) and $file!=basename($SCRIPT_NAME) and $file!=basename($download_stats_file) and $file!=$custom_script_name) {
    				$download_filelist[$file][0]=$file;
    				$download_filelist[$file][1]="application/octet-stream";
    			}
    		}
    		$directory->close();
    		chdir($current_dir);
    	}
    
    	// download handling--------------------------------------------------------------------------------------------------------------------------
    
    	if (isset($download)) {
    		if (isset($download_filelist[$download])) {
    			$filename=$download_folder.$download_filelist[$download][0];
    			if (file_exists($filename)) {
    				if ($enable_stats=="true") {
    					if (file_exists($download_stats_file) and is_writable($download_stats_file)) {
    						foreach (file($download_stats_file) as $line) {
    							$array=explode("|",$line);
    							$download_stats_file_array[$array[0]]=$array[1];
    						}
    						$download_stats_file_array[$download]++;
    						$handle=fopen($download_stats_file,"w");
    						foreach ($download_stats_file_array as $value) {
    							fputs($handle,key($download_stats_file_array)."|".$value."|\n");
    							next($download_stats_file_array);
    						}
    						fclose($handle);
    					}
    					else { die("Sorry, no downloads avalible."); }
    				}
    				header("Content-Type: ".$download_filelist[$download][1]);
    				header("Content-Disposition: attachment; filename=\"".basename($filename)."\"");
    				readfile($filename);
    				exit;
    			}
    			else { die("Sorry, but the requested file could not be found."); }
    		}
    		else { die("Sorry, but the requested download does not exist."); }
    	}
    
    	// initialize global variables-----------------------------------------------------------------------------------------------------------------
    
    	$GLOBALS["SCRIPT_NAME"]			= getenv("SCRIPT_NAME");
    	$GLOBALS["enable_stats"]		= $enable_stats;
    	$GLOBALS["download_stats_file"]		= $download_stats_file;
    	$GLOBALS["download_folder"]		= $download_folder;
    	$GLOBALS["auto_create_filelist"]	= $auto_create_filelist;
    	$GLOBALS["download_filelist"]		= $download_filelist;
    
    	// functions------------------------------------------------------------------------------------------------------------------------------------------
    
    	function manage_download_stats()
    	{
    		$download_stats_file	= $GLOBALS["download_stats_file"];
    		$download_filelist	= $GLOBALS["download_filelist"];
    		
    		// create download stats file if missing-------------------------------------------------
    		if (!file_exists($download_stats_file)) {
    			$handle=fopen($download_stats_file,"w");
    			foreach($download_filelist as $array) {
    				fputs($handle,key($download_filelist)."|0|\n");
    				next($download_filelist);
    			}
    			fclose($handle);
    		}
    		// read download stats file-------------------------------------------------------------------
    		foreach (file($download_stats_file) as $line) {
    			$array=explode("|",$line);
    			$download_stats_file_array[$array[0]]=$array[1];
    		}
    		
    		return $download_stats_file_array;
    	}
    
    	function print_download_table()
    	{
    		$enable_stats		= $GLOBALS["enable_stats"];
    		$download_folder	= $GLOBALS["download_folder"];
    		$auto_create_filelist	= $GLOBALS["auto_create_filelist"];
    		$download_filelist	= $GLOBALS["download_filelist"];
    		$SCRIPT_NAME		= $GLOBALS["SCRIPT_NAME"];
    		
    		// get download stats----------------------------------------------------------------------------	
    		if ($enable_stats=="true") { $download_stats_file_array=manage_download_stats(); }
    		// create download table from download file list------------------------------------
    		echo "<table><tr><th>file</th>";
    		if ($auto_create_filelist!="true") { echo "<th>description</th>"; }
    		echo "<th>filesize</th>";
    		if ($enable_stats=="true") { echo "<th>downloads</th>"; }
    		echo "</tr>";
    		foreach($download_filelist as $download_filelist_array) {
    			if (!isset($download_stats_file_array[key($download_filelist)])) { $download_stats_file_array[key($download_filelist)]=0; };
    			echo "<tr><td><a href =\"$SCRIPT_NAME?download=".urlencode(key($download_filelist))."\" title=\"click to download\">".key($download_filelist)."</a></td>";
    			if ($auto_create_filelist!="true") { echo "<td>$download_filelist_array[2]</td>"; }
    			echo "<td>".sprintf("%.1f",@filesize($download_folder.$download_filelist_array[0])/1024)."K</td>";
    			if ($enable_stats=="true") { echo "<td>".$download_stats_file_array[key($download_filelist)]."</td>"; }
    			echo "</tr>";
    			next($download_filelist);
    		}
    		echo "</table>";
    	}	
    
    	// standalone output------------------------------------------------------------------------------------------------------------------------------
    
    	if ($standalone=="true") {
    		// header--------------------------------------------------------------------------------------------------------------------------------------------------
    		echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">";
    		echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >";
    		echo "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />";
    		echo "<meta name=\"author\" content=\"[ M ] etaphor Staff\" />";
    		echo "<meta name=\"description\" content=\"[ M ] etaphor Midi\" />";
                    echo "<meta name=\"keywords\" content=\"[ M ] etaphor Midi, midi rock, midi, download midi, download midi rock, scarica midi, midi gratis\" />";
    		echo "<title>[ M ] etaphor - Your rock resource - Midi</title>";
    		echo "<style type=\"text/css\">".$css_code."</style></head><body>";
    		// body-----------------------------------------------------------------------------------------------------------------------------------------------------
    		echo "<h2>".$headline_string."</h2>";
    		print_download_table();
    		// 
    	}
    
    include "index.html";
    include "index2.html";
    ?>
    Ultima modifica di metaphor : 19-12-2005 alle ore 16.23.33

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •