phpBB Italia chiude!
phpBB Italia ringrazia tutti gli utenti che hanno dato fiducia al nostro progetto per ben 9 anni, e che, grazie al grande lavoro fatto da tutto lo Staff (rigorosamente a titolo gratuito), hanno portato il portale a diventare il principale punto di riferimento italiano alla piattaforma phpBB.

Purtroppo, causa motivi personali, non ho più modo di gestirlo e portarlo avanti. Il forum viene ora posto in uno stato di sola lettura, nonché un archivio storico per permettere a chiunque di fruire di tutte le discussioni trattate.

Il nuovo portale di assistenza per l'Italia di phpBB diventa phpBB-Store.it, cui ringrazio per aver deciso di portare avanti questo grande progetto.

Grazie ancora,
Carlo - Amministratore di phpBB Italia

collegare alcune info su due database

Supporto MODs generale.
Rispondi
juventissimo
Utente
Utente
Messaggi: 243
Iscritto il: 11/12/2011, 12:21
Sesso: Maschio
Versione: 3.0.12
Server: UNIX/Linux
PHP: 5.3.28
Database: MySQL 5.5.36-34.2-log
Contatta:

collegare alcune info su due database

Messaggio da juventissimo » 02/07/2014, 13:56

Ciao a tutti, è da un po di tempo che stò cercando di far apparire sul post profilo post pagina php con varie informazioni e ci sono riuscito (facendo include nel template), ma il mio problema è che vorrei che quella pagina php venisse riferita a quell'utente e non ad altri. provo a spiegare meglio.

sul forum (database 1) l'utente ha un nome id=3, in sls (database 2 che contiene le statistiche che necessito di far visualizzare) ha un nome uguale ma con id=5 (quindi differente) è possibile tramite qualche modifica, script far si che nella pagina del forum appaia nome utente e statistiche riferite a quella persona???

l'immagine allegata l'ho fatta sul mio profilo, ma se guardo altri messaggi di altri utenti appaiono le mie statistiche e non le loro.


grazie a tutti
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.

Avatar utente
Barrnet
Leader Moderatori
Leader Moderatori
Messaggi: 3124
Iscritto il: 04/07/2010, 23:31
Sesso: Maschio
Versione: 3.0.10
Server: UNIX/Linux
PHP: 5.3.10
Database: MySQL 5.1.61-community-log
Contatta:

Re: collegare alcune info su due database

Messaggio da Barrnet » 03/07/2014, 10:42

Per fare una interazione fra diverse tabelle è necessario che i due database condividano un campo in comune o con un valore equivalente.

juventissimo
Utente
Utente
Messaggi: 243
Iscritto il: 11/12/2011, 12:21
Sesso: Maschio
Versione: 3.0.12
Server: UNIX/Linux
PHP: 5.3.28
Database: MySQL 5.5.36-34.2-log
Contatta:

Re: collegare alcune info su due database

Messaggio da juventissimo » 03/07/2014, 13:54

Grazie Barrrnet per la risposta.

esattamente è quello che pensavo solo che oltre ad esserci delle tabelli ci sono anche i database differenti.

infatti l'unico campo in comune che ho impostato è il nome cognome con il nickname... però purtoppo non riesco a fare questo controllo. mi sapresti aiutare?

juventissimo
Utente
Utente
Messaggi: 243
Iscritto il: 11/12/2011, 12:21
Sesso: Maschio
Versione: 3.0.12
Server: UNIX/Linux
PHP: 5.3.28
Database: MySQL 5.5.36-34.2-log
Contatta:

Re: collegare alcune info su due database

Messaggio da juventissimo » 06/07/2014, 18:11

Nulla??? sto impazzendo :(

Avatar utente
Carlo
Amministratore
Amministratore
Messaggi: 9957
Iscritto il: 19/04/2009, 10:24
Sesso: Maschio
Versione: 3.2.0
Server: UNIX/Linux
PHP: 7.1.0
Database: MySQL(i) 10.0.27-MariaDB-cll-lve
Località: Puglia
Contatta:

Re: collegare alcune info su due database

Messaggio da Carlo » 08/07/2014, 23:04

Potresti riportare la query che esegui per reperire le informazioni e descrivere la struttura della tabella che li contiene?
MODs | Stili | Traduzioni MOD
Ogni MP contenente una richiesta di supporto verrà ignorato.

juventissimo
Utente
Utente
Messaggi: 243
Iscritto il: 11/12/2011, 12:21
Sesso: Maschio
Versione: 3.0.12
Server: UNIX/Linux
PHP: 5.3.28
Database: MySQL 5.5.36-34.2-log
Contatta:

Re: collegare alcune info su due database

Messaggio da juventissimo » 09/07/2014, 13:49

Grazie mille per l'aiuto :D

questa è una parte del codice che ho per recuperare i dati dal terzo database (SLS), e qui dentro dovrei mettere il paragone con quello del secondo database (forum), ma purtoppo non so come fare

Codice: Seleziona tutto

//StartSessionSafe();

SetLanguageCookie();
DecideLanguage($prefs['DEF_LANG'], LANG_MAIN);
DecideLanguage($prefs['DEF_LANG'], LANG_BUTTONS);
DecideLanguage($prefs['DEF_LANG'], LANG_SYSTEM);

require_once 'lang/system_lang_english.php';
require_once 'lang/lang_english.php';
require_once 'lang/buttons_lang_english.php';
@include_once 'lang/system_lang_' . GetLanguage (LANG_SYSTEM) . '.php';
@include_once 'lang/lang_' . GetLanguage (LANG_MAIN) . '.php';
@include_once 'lang/buttons_lang_' . GetLanguage (LANG_BUTTONS) . '.php';

class InfoPage extends CTABgen
	{
	var $form;
	var $dbGroups;
	var $formstyle;
	var $ID;
	var $IDclient;
	var $TableB;

	var $dbCountry;
	var $dbCars;
	var $dbCarClass;
	var $db;



	function InfoPage (&$dataarray, $keyname)
		{
		$this->SetData($dataarray, $keyname);
		$this->CTABgen();
                
                $this->user_rights = CRights::GetUserRights($this->GetCurrentUserData('UID'));
                

		$this->db = new CDriversCarClass();
		$this->dbFiles = new CFiles();

		$this->dbCons = new CStandings();
		}


	function Local_Header ()
		{
		global $lang;
		if (empty($this->dataarray['dst'])) $this->dataarray['dst'] = '';

		if ($this->dataarray['dst']=='res') PrintHeader('career');
		else PrintHeader('gtr_drv_details');
		
		global $SYSTEM_OK;
		global $prefs;
		$SYSTEM_OK = true;
		$com_arr = array('tab_dd_common_up.gif', 'tab_dd_common_down.gif');
		$res_arr = array('tab_dd_results_up.gif', 'tab_dd_results_down.gif');



		$tabs = PrintMainMenuDrop($link_arr,0,'center');


		}
	
	function Local_Generate()
		{
		if (empty($this->dataarray['dst'])) $this->Local_Generate_General();
		else $this->Local_Generate_General();
		}

	function Local_Generate_General()
		{

		global $prefs;

		if (empty($this->dataarray['IDdriver'])) return false;

		$persdata = '';

		$this->db->GetSelectedData('IDdriver=' . $this->dataarray['IDdriver']);
		$this->dbFiles->SetAddFields('IDfile');
		$this->dbFiles->SetAllFields(false);
		if (!$this->dbFiles->GetSelectedData('FileType=' . FTYPE_DRVPHOTO . ' AND IDdriver=' . $this->dataarray['IDdriver']))
			{
			$this->PrintError($this->dbFiles->GetErrorDescription());
			return false;
			}

		$show_hidden = empty($this->user_rights['superadmin']) ? false : true;

		$table = new CTable();
		$table->SetPrintReturn(true);

		$this->dbCons->SetPersistentFilter('IDdriver='. $this->ID);

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('QualPos=1');
		$this->dbCons->GetAllRecords();
		$PP = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('RacePos<=5');
		$this->dbCons->GetAllRecords();
		$TOP5 = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('RacePos<=8');
		$this->dbCons->GetAllRecords();
		$TOP8 = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('RacePos<=10');
		$this->dbCons->GetAllRecords();
		$TOP10 = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('RacePos=1');
		$this->dbCons->GetAllRecords();
		$WINS = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('RacePos=2');
		$this->dbCons->GetAllRecords();
		$WINS2 = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('RacePos=3');
		$this->dbCons->GetAllRecords();
		$WINS3 = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(*) AS RES');
		$this->dbCons->SetFilter('');
		$this->dbCons->GetAllRecords();
		$EVENTS = $this->dbCons->Fields['RES'];

		$this->dbCons->SetAllFields(false);
		$this->dbCons->SetAddFields('Count(DISTINCT IDseason) AS RES');
		$this->dbCons->GetAllRecords();
		$SEASONS = $this->dbCons->Fields['RES'];

		$table = new CTable();
		$table->SetPrintReturn(true);
		$stat = $table->OpenTable(0);
            $stat .= $table->PrintData($this->lang['drvdet_nick'], '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($this->db->Fields['Nick'], '4', '', 'det_value','color:#828282');

		$stat .= $table->NextRow();
			$stat .= $table->PrintData($this->lang['drvdet_cseas'], '', '', 'det_name','width:25%;color:#000000');
			$stat .= $table->PrintData($SEASONS, '', '', 'det_value','text-align: right;color:#828282');
			$stat .= $table->PrintData($this->lang['drvdet_cevents'], '', '', 'det_name','width:25%;color:#000000');
			$stat .= $table->PrintData($EVENTS, '', '', 'det_value','text-align: right;color:#828282');
			$stat .= $table->PrintData($this->lang['drvdet_cppso'], '', '', 'det_name','width:25%;color:#000000');
			$stat .= $table->PrintData($PP, '', '', 'det_value','text-align: right;color:#828282');

		$stat .= $table->NextRow();
			$stat .= $table->PrintData($this->lang['drvdet_cwins'], '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($WINS, '', '', 'det_value','text-align: right;color:#828282');
			$stat .= $table->PrintData($this->lang['drvdet_cwins2'], '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($WINS2, '', '', 'det_value','text-align: right;color:#828282');
			$stat .= $table->PrintData($this->lang['drvdet_cwins3'], '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($WINS3, '', '', 'det_value','text-align: right;color:#828282');

		$stat .= $table->NextRow();
			$stat .= $table->PrintData($this->lang['drvdet_ctop5'], '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($TOP5, '', '', 'det_value','text-align: right;color:#828282');
			$stat .= $table->PrintData($this->lang['drvdet_ctop8'], '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($TOP8, '', '', 'det_value','text-align: right;color:#828282');
			$stat .= $table->PrintData(str_replace('8','10',$this->lang['drvdet_ctop8']), '', '', 'det_name','color:#000000');
			$stat .= $table->PrintData($TOP10, '', '', 'det_value','text-align: right;color:#828282');
		$stat .= $table->CloseTable();

		$this->tableA->OpenTable();
		$this->tableA->PrintData($stat, '', '', '', 'width:245px;vertical-align:top;background-color: #e1ebf2;');
		$this->tableA->CloseTable();
		}
	}

$a = new InfoPage(GetHTTPVAR('dataarray'), 'IDdriver');
$a->SetLanguage($lang);
$a->Generate(GEN_STATUS_ERRONLY);

PrintFooter ();

Rispondi

Torna a “Supporto MODs”

Chi c’è in linea

Visitano il forum: Nessuno e 62 ospiti