Retrieving and Presenting SQL Joined Table Records with PHP, Sqlite (or MySql), and HTML -


Please do not hesitate with me while I try to explain your question. I have a SQLite database that has a table containing company information (companies) and product information (product). Companies table ID is added COMPANY_NAME it with the product table by Company_Name For example, the company consists of the name of the 'A' inner volume = ProductID (ProductID company) many associated with it through joining companies to Products can be.

I'm trying to display this information using a loop while loop so that there will be a list of companies with their respective products. I can not understand how to do this. I can record a company like loop with a product, but I can not list a company with many products. The following is what I am trying to achieve:

Company "A" - Location CA Product 1, Product 2, Product 3

Company "C" - Location CA Product 3, product pulls all companies 4, the product 6

the company "F" - for CA product 1, the product 8

query California (CA) in this example.

My code is as follows, but it does not work:

  // srchtext value in an HTML text box // $ txt = $ _GET [ "srchtext "]; $ Dbstate = @ $ db- & gt; Question ( "Company.Company_Name, Company.Company_City, Company.Company_State, Company.Company_Website, Company.Company_Service, Categories.Category_Name, which includes where the company's inner company_name = ProductID ones Products.Product_Name product Company_State = '$ txt ''); While ($ hmstate = $ dbstate-> Fachtere ()) {resonant " ul>"; Echo "& lt; font id = 'srchclr'; color = '# 666666'; & gt;"; $ Hmstate ['business'] '& Lt; Br> Echo '& lt ;; Strong & gt ' '& Lt; / Strong & gt .... $ Hmstate ['Company_City'] ',' $ hmstate ['Company_State']. '& Lt; Br> '& Lt; A href = '$ hmstate [' Company_Website ']' & gt; '.. $ Hmstate ['Company_Website'] '& lt; / A & gt; '. '& Lt; Br> '.. '& Lt; Ul & gt; . '& Lt; Br> '& Lt; Strong> Products or services provided by this company: & lt; / Strong> ......... '& Lt; Br> '& Lt; Br> '& Lt; Ul & gt; $ Hmstate ['Company_Service'] '& Lt; / Ul & gt; '; Echo "& lt; br & gt;"; Echo "& lt; strong> company product category: ; Echo "& lt; br & gt;"; Echo "& lt; br & gt;"; // Product Loop // while ($ hmstate = $ dbstate- & gt; fetchArray ()) {echo " 

Company "A" - Location CA Product 1, Product 2, Product 3, Product 3 Products 4, the product 6, product 1, product 8

I tried to take another PHP "loop", although I will receive the following:

the company "A. "- Location CA Product 3 ...

Company" A "- Location CA Product 1

Company" A "P>

Recent Since I'm using SQLite, if anyone has an example in MySQL or any other SQL DB, which will actually help, I think that my problem is with query and PHP "while loop".

I appreciate your help.

Thanks,

DFM

Your product Jbki- Loop is bringing all the products because you do not "break" while changing Company_Name.

My PHP is not good, but probably something like this:

 . . (Your company's PHP code is here). . // Product Loop // if ($ hmstate = $ dbstate-> Fachtere ()) {$ fetch_okay = true; $ Current_Company_name = $ hmstate ['Company_Name']; $ Same_Company = true; } While (fetch_okay & amp; amp; amp; & amp; amp; समान_ कंपनी) {echo " Fachtere ()) {$ fetch_okay = true; If ($ hmstate ['Company_Name'] = $ current_Company_name] {$ same_Company_Name = true; }}}  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -