php - Trying to get a list of team names a member is a part of via comparing 2 sql tables -
Trying to get user teams is a part of comparing 2 tables
DB Tables (team) 'varchar' (45) default faucet, 'TeamDesk Longtext', 'Founder' varchar (45), 'team dim' (11) faucet atangentement, zero, `date formatted` integer (11) Primary key (`timid ')) engine = InDebby Outangent = 2 defaults charset = Latin 1; The table 'TeamManbars' (`Timed 'int (11) faucet,' Member 'varchar (45) No,' rank 'varchar (45) default faucet, primary key (` timid') engine = InnoDB default charge = latin1;
The current function is to stuff me:
/ * removeProject * / function getTeamNames ($ id) {global $ session, $ database; $ link = $ database-> Connection; $ Stmt = $ link- & gt; Prepare ("WHERE teamid = $ id" from select teamnames teams); $ Stmt- & gt; Executed (); $ R = $ stmt-> Fetch (); Returns array ('team' = & gt; $ r ['teamname']); } Questions for getting team names:
$ link = $ database-> Connection; {$ Link- & gt; Try Set Attribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION); $ Q = "Select Teammen's WHERE Member =: United Nations"; $ Prep = $ link- & gt; Prepare ($ q); $ Array = array (': un' = & gt; $ user); $ Prep- & gt; Execute ($ array); } Hold (PDOException $ error) {echo ($ error); } Then the information for displaying the data:
& lt; Multiple class = "form-control" & gt; Select & lt ;? Php while ($ tid = $ prep-> fetch ()) {$ teams = $ database-> GetTeamNames ($ tid ['teamid']); Echo ("& lt; option & gt; $ teams" & lt; / options & gt;); }? & Gt; & Lt; / Select & gt; This only displays data as "array"
UPDATE !!!
In this way I have decided this:
while ($ tid = $ prep-> Fetch ()) {$ teams = $ database-> & gt; ; GetTeamNames ($ tid ['teamid']); // echo var_dump ($ team); $ Team = $ Team ['Team']; Echo ("& lt; Option & gt; $ Team "); }
your function function getTeamNames ($ id) returns An associative array is the reason why you are not getting the result. Your loop should look something like
& lt ;? Php while ($ tid = $ prep-> ()) {$ Teams = $ database-> getTeamNames ($ tid ['timid']); Foreign exchange ($ team ['team'] $ as team) {echo ("& lt; option & gt; $ teams "); }}? & Gt;
Comments
Post a Comment