Jump to content
pvspeed

Ajutor php

Recommended Posts

Posted

 

		$sql = "
			SELECT 
                t.ticketid,
				t.subject,
				t.description,
				t.creator,
				t.created,
				t.updated,
				t.status,
				t.priority,
				t.server,	
                (SELECT username FROM ".$this->prefix('users')." WHERE id=t.creator) AS owner	     		
			FROM ".$this->prefix('tickets')."  t
            ORDER BY ticketid DESC 						
		";
		

Vreau sa selectez din mysql din tabelul tickets ticketele care au creator userele din users care au parent$_SESSION['user_id'];

Am incercat asa:

		$sql = "
			SELECT 
                t.ticketid,
				t.subject,
				t.description,
				t.creator,
				t.created,
				t.updated,
				t.status,
				t.priority,
				t.server,			
                (SELECT username FROM ".$this->prefix('users')." WHERE id=t.creator) AS owner,
                (SELECT id FROM ".$this->prefix('users')." WHERE parent=".$_SESSION['user_id'].") AS plm		     		
			FROM ".$this->prefix('tickets')."  t
			WHERE t.creator=".$plm."
            ORDER BY ticketid DESC 						
		";

Ma poate ajuta cineva?

Posted (edited)
SELECT t.ticketid,
				t.subject,
				t.description,
				t.creator,
				t.created,
				t.updated,
				t.status,
				t.priority,
				t.server,
FROM tabel_tckets AS t, tabel_users AS u WHERE u.parent = $_SESSION['user_id']; AND t.creator = u.id

 

Edited by Rubaka
  • Upvote 1
Posted
		$sql = "
			SELECT 
                t.ticketid,
				t.subject,
				t.description,
				t.creator,
				t.created,
				t.updated,
				t.status,
				t.priority,
				t.server,			
                (SELECT username FROM ".$this->prefix('users')." WHERE id=t.creator) AS owner    		
			FROM ".$this->prefix('tickets')." AS t 
			".(!$this->isAllowed(ADMIN) ? ', '.$this->prefix('users').' AS u WHERE u.parent='.$_SESSION['user_id'].' AND t.creator = u.id ' : ' ')."			
			
            ORDER BY ticketid DESC 						
		";

Am introdus asta si a functionat dar vreau sa se afiseze si ticketele facute de $_SESSION['user_id']; 

		$sql = "
			SELECT 
                t.ticketid,
				t.subject,
				t.description,
				t.creator,
				t.created,
				t.updated,
				t.status,
				t.priority,
				t.server,			
                (SELECT username FROM ".$this->prefix('users')." WHERE id=t.creator) AS owner    		
			FROM ".$this->prefix('tickets')." AS t 
			".(!$this->isAllowed(ADMIN) ? ', '.$this->prefix('users').' AS u WHERE t.creator='.$_SESSION['user_id'].' OR u.parent='.$_SESSION['user_id'].' AND t.creator = u.id ' : ' ')."			
			
            ORDER BY ticketid DESC 						
		";
		

 

Am incercat asta dar ticketele facute de $_SESSION['user_id'];  sunt afisate de 4 ori

 

 

Posted (edited)

Uite, ar veni cam asa.

 

$sql = "SELECT tickets.ticketid, tickets.subject, tickets.description, tickets.creator, tickets.created, tickets.updated, tickets.status, tickets.priority, tickets.server, users.username
FROM " . $this->prefix('tickets') . " AS tickets
LEFT JOIN " . $this->prefix('users') . " AS users ON (tickets.creator = users.id)
WHERE tickets.creator = '" . $_SESSION['user_id'] . "' OR users.parent = '" . $_SESSION['user_id'] . "'
ORDER BY ticketid DESC";

 

Nu am inteles insa ce e cu IF-ul pentru isAllowed(ADMIN). Banuiesc ce face, dar pana acum nu ai zis nimic de el.

Daca nu e bine cum ti-am dat, explica clar ce ai nevoie si iti fac 2 query-uri distincte. Recomand sa faci 2, pe if/else, decat 1 cu if-uri in linie. La un moment dat o sa te incurci in el daca esti si incepator.

Edited by Wav3
  • Upvote 3

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...