wordpress - Generating two html tables with titles in first table cell of each row in PHP -


I would like some advice on how to generate two different comparison tables from the same set of data returned from mysql. First one needs only one line as shown below.

The second table is difficult for me, I want titles (brand, country, special functions, etc.) in the first cell of each line, and I use many predecessors to get results, but I It seems that there should be a better way of doing this. Do you have a better suggestion on my code?

$ first table:

  & lt; Table & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; Th & gt; Product 1 & lt; / Th & gt; & Lt; Th & gt; Product 2 & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; TD & gt; 10 & lt; / TD & gt; & Lt; TD & gt; 1 & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

$ second table

  & lt; Table & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; Img src = 'img.jpg' & gt; Product 1 & lt; / Th & gt; & Lt; Th & gt; & Lt; Img src = 'img.jpg' & gt; Product 2 & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; TD & gt; Country & lt; / TD & gt; & Lt; TD & gt; Japan & lt; / TD & gt; & Lt; TD & gt; Italy & lt; / TD & gt; & Lt; Td> Special Tasks & lt; / Td> Adjustable & lt; Td> & Lt; / Td> & Lt; Td> Rechargeable & lt; / Td> & Lt; Td> Brand & lt; / Td> A brand & lt; Td> & Lt; / Td> & Lt; Td> B brand & lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

Code:

  $ sql = "Choose names, images_values, votes, countries, special_reversions, where in the 'products' from the brand (". $ In . ") The name range is named 5"; If ($ wpdb- & gt; Query ($ sql)) // WordPress Version {$ lines = $ wpdb- & gt; Final_text; $ First = ""; $ Sec = ""; $ Tablehead = "& lt; Table & gt; & lt; thead & gt; & lt; tr & gt; & lt; Th & gt; & lt; / th & gt;"; $ First = $ Tablehead; $ Sec = $ Tablehead; Forex currency ($ lines as $ line) {$ first. = "& Lt; th & gt;" $ Line-> Name. "& Lt; / th>"; $ Sec = "& Lt; th> & lt; img src = '". $ Line-> Image_url. ' '/ & Gt; "$ Line-> Names." & Lt; / Th & gt; ";} $ First." = "& Lt; / Tr & gt; & Lt; / Thead & gt; & Lt; / Tbody & gt; & Lt; Tr & gt; & Lt; Th & gt; & Lt; / Th> "; $ sec." = "& Lt; / Tr & gt; & Lt; / Thead & gt; & Lt; / Tbody & gt; & Lt; Tr & gt; "; Foreign Exchange ($ lines as $ line) {$ sec. =" & Lt; TD & gt; Country & lt; / Td & gt; ";} Forex ($ lines as $ line) {$ first. =" & Lt; Td> ". $ Line- & gt; Votes." & Lt; / Td> "$ sec." = "& Lt; Td> "$ line- & gt; Country." & Lt; / Td> ";} Forex ($ lines as $ line) {$ second. =" & Lt; Td> Special functions & lt; / Td> ";} Forex ($ lines as $ line) {$ second. =" & Lt; Td> ". $ Line- & gt; special_activity." & Lt; / Td> ";} Forex ($ rows in the form of $ line) {$ sec. =" & Lt; Td> Brand & lt; / Td> ";} Forex ($ lines as $ line) {$ second. =" & Lt; Td> "$ line- & gt; Brand." & Lt; / Td> "}} $ Endtable =" & lt; / Tr & gt; & Lt; / Tbody & gt; & Lt; / Table> "; $ first. = $ Endtable; $ sec. = $ Endtable;}  


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -