echah 0 Report post Posted June 9, 2008 <html><head><?php$username=$_POST["txtUsername"];$password=$_POST["txtPassword"];//connect to mysql server$db=mysql_connect("localhost","","")or die("could not connect to database, please check that mysql is running");mysql_select_db("foxboro2");//database name$query=SELECT staff.Staff_ID, computer.computer_ID, computer.type, computer.Model, software.software_type, software.Description, software.Serial_NumberFROM (staff LEFT JOIN computer ON staff.Staff_ID=computer.Staff_ID) LEFT JOIN software ON computer.computer_ID=software.computer_ID;";$result=mysql_query($query);$num_rows=mysql_num_rows($result);?><title>AddressBook:View Data</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><? if ($num_rows>0){ ?><table width="98%" border="1"> <tr> <td width="2%"> </td> <td width="31%">Staff ID</td> <td width="19%">Computer ID</td> <td width="31%">Type</td> <td width="19%">Model</td> <td width="31%">Software type</td> <td width="19%">Description</td> <td width="31%">Serial number</td> </tr> <? for($i=1;$i<=$num_rows;$i++){ $row=mysql_fetch_array($result); ?> <tr> <td><? echo $i?></td> <td><? echo $row["Staff_ID]?></td> <td><? echo $row["computer_ID"]?></td> <td><? echo $row["type"]?></td> <td><? echo $row["Model"]?></td> <td><? echo $row["software_type"]?></td> <td><? echo $row["Description"]?></td> <td><? echo $row["Serial_Number"]?></td> </tr> <? }//end for } //end if else{ ?> There is no record to show..... <? }//end else?></table><p> </p></body></html>nape table inner join tu xleh disply ek...die akan kuar 'There is no record to show.....'tolong r bantu sy..buntu dah ni...mencr syntax... Quote Share this post Link to post Share on other sites
arejae 0 Report post Posted June 13, 2008 (edited) sepatutnya ada record ker ?sebelum tuh,mmg awak kena tahu dulu bagaimana relation antara semua table tu. one-to-one,one-to-many ?maybe echah boleh tolong display sample data from table :1. Staff2. Computer3. Softwarebaru senang utk kawan2 lain tengok. begheh. Edited June 13, 2008 by arejae Quote Share this post Link to post Share on other sites
echah 0 Report post Posted June 18, 2008 sy dah berjaya wat inner join tu cz sy lupe nk key in data dlm tables..hihihi..malu jek...and one more thing i want to ask u...cm ne ek coding utk insert, delete, edit table gune coding inner join tu...ade syntax r...tolong ek.. Quote Share this post Link to post Share on other sites
arejae 0 Report post Posted June 20, 2008 er..nie nak syntax SQL tuh ker ? or nak syntax PHP ? Quote Share this post Link to post Share on other sites
kazuharan85 0 Report post Posted June 21, 2008 join dipakai utk select statement je rasenye..kalo nk insert,update or delete kna wat utk satu2 table..tp taktaula kot2 boleh..tp x susah pn sbb dia akan ada id yg sama..so based on id tu la kite delete or update..snarnye yg joinkn antara 2 or lebih table tu based on id yg sama je.. Quote Share this post Link to post Share on other sites
echah 0 Report post Posted June 23, 2008 syntax utk SQL...sy gune coding yg same utk view dgn coding inner join..and mcm xleh gune lak coding tu generate ke coding utk insert, delete an so on... Quote Share this post Link to post Share on other sites
echah 0 Report post Posted June 24, 2008 join dipakai utk select statement je rasenye..kalo nk insert,update or delete kna wat utk satu2 table..tp taktaula kot2 boleh..tp x susah pn sbb dia akan ada id yg sama..so based on id tu la kite delete or update..snarnye yg joinkn antara 2 or lebih table tu based on id yg sama je..memg kena gune base yg same kan....dah try r...n sush skit...coding jd panjg giler...so for exmple if kite nk insert data so dua2 table pun berubah sekali....utk view sy dah wat nn blh run utk stemant yg lain tu r..sush skit.... Quote Share this post Link to post Share on other sites
arejae 0 Report post Posted June 27, 2008 syntax utk SQL...sy gune coding yg same utk view dgn coding inner join..and mcm xleh gune lak coding tu generate ke coding utk insert, delete an so on...sebenarnya join ke tak join ker...kita punya tujuan nak view result kan. means,still lagi kita guna select statement. kalau utk delete,insert,update kita kenalah pakai specific statement utk tujuan2 tuh. err...tak tahulah menjawab soklan ke idak.ermm..nampak macam awak nak buat address book nyer application kan. (based on awak nyer <title>) apa kata kalau cuba usha kat sini caner derang buat.http://php.about.com/od/finishedphp1/ss/address_book.htm Quote Share this post Link to post Share on other sites
echah 0 Report post Posted June 30, 2008 sebenarnya join ke tak join ker...kita punya tujuan nak view result kan. means,still lagi kita guna select statement. kalau utk delete,insert,update kita kenalah pakai specific statement utk tujuan2 tuh. err...tak tahulah menjawab soklan ke idak.ermm..nampak macam awak nak buat address book nyer application kan. (based on awak nyer <title>) apa kata kalau cuba usha kat sini caner derang buat.http://php.about.com/od/finishedphp1/ss/address_book.htmops..bukan address book...hihih...lupe lak nk update...nk wat database utk staff company ni...ok..thank a lot byk gak membantu...hihih...one more thing is, if kite nk join table kan gune one to many.*contoh 1 staff ade dua computer laptop n desktop so die punye coding tu kan kite leh wat jgk ke kt PHP mysql tu???confius r....ihihihi..byk lak soalan kt awk....sory...sy bru nk blaja... Quote Share this post Link to post Share on other sites
arejae 0 Report post Posted July 1, 2008 boleh. janji SQL syntax tuh betui. Quote Share this post Link to post Share on other sites
dellantre 0 Report post Posted July 10, 2008 Bukan join table ni untuk merge table ker.tapi dulu aku pernah pernah menggabungkan pelajar yang berada di 2 blok berasingan tetapi sama tingkatan.tujuan aku join table utk gabungkan pelajar yang sama tingkatan di query yang aku nak.malangnya aku da lama tak sentuh mysql.yang aku ingat cuma apa yang dipratikkan dan ianya terhasil.maaf, cuma berkongsi pengalaman. Quote Share this post Link to post Share on other sites
echah 0 Report post Posted July 10, 2008 Bukan join table ni untuk merge table ker.tapi dulu aku pernah pernah menggabungkan pelajar yang berada di 2 blok berasingan tetapi sama tingkatan.tujuan aku join table utk gabungkan pelajar yang sama tingkatan di query yang aku nak.malangnya aku da lama tak sentuh mysql.yang aku ingat cuma apa yang dipratikkan dan ianya terhasil.maaf, cuma berkongsi pengalaman.memg utk marge table...untuk view sy dah dpt coding die...masalah skrg utk edit, update, insert...tu problem skit dgn coding die...st try wat...tp syntax r...tu yg nk tau coding tuk marge table ni leh ke wat utk edit, update, insert tu?? Quote Share this post Link to post Share on other sites
budak IT 0 Report post Posted August 4, 2008 join mainly for retrieving records dari database... kalau tuk insert or update, u kena specify table tu satu persatu... condition nye, u may change tapi bukan the insert or update statement... contoh - something cenggini lar...:insert into table A (select from table c ......)tapi kalau dari form, memang kena insert satu2... sebab awak ada master and detail table.. so, master memang kena insert dulu.. then baru detail... Quote Share this post Link to post Share on other sites
echah 0 Report post Posted August 4, 2008 join mainly for retrieving records dari database... kalau tuk insert or update, u kena specify table tu satu persatu... condition nye, u may change tapi bukan the insert or update statement... contoh - something cenggini lar...:insert into table A (select from table c ......)tapi kalau dari form, memang kena insert satu2... sebab awak ada master and detail table.. so, master memang kena insert dulu.. then baru detail...ooo...mksdnyecontoh: table 1: stafftable 2: hardwareabove statement ade 2 table....so if nk insert, update n delete kena one by one r insert n change ek....xleh dr table staff and hrdware yg dah combine tu kite change or insert?? Quote Share this post Link to post Share on other sites