php & mysql loop through records for limited number to be in multiple box -


I have a table with the following structure:

  is not created if data exists Is not `` `` `` `` `` `` `` `` `` `` `` `` `` `` `) Engine = InnoDB default charge = utf8 AUTO_INCREMENT = 1;   

This table contains more than 60 records. I want to preview the records in four boxes - 15 records for each box, it's easy to put one digit, but I want to be in a slideshow. My code is now:

  $ mysql_employers = "SELECT * FROM Data LIMIT". $ Page ",". $ Limiter ""; $ query_employers = $ dblink- & gt; Queries ($ mysql_employers) or die ("Employers Fail!"); $ Employers_link = array (); While ($ Employer = $ query_employers- & gt; receive (PDF :: FETCH_ASSOC)) {$ employers_link [] = $ Employers; } $ Employer = new sensible; $ Employer- & gt; Caching = false; $ Employers- & gt; Allocated ("employers", $ employers_link); $ Employers- & gt; Display ("default / employers.tpl");   

$ page is page number and $ limit is per page limit, which is 15. Smarty template code

  
div class = "employers-box" & gt; {$ Foreign currency $ $ emp} as employer & lt; div class = "employer" & gt; & Lt; Div class = "employer photo" & gt; & Lt; img src = "{$ emp.photo}" & gt; & Lt; / Div & gt; & Lt; Div class = "employer name" & gt; & Lt; a href = "viewemplyer.php? employer = {$ emp.id}" & gt; {$ Emp.name} & lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; {/ Foreach} & lt; / Div & gt;

Instead of being in the pages, can I change it to show it as four boxes (with 15 employers in each box)?

Not the most beautiful way, but you can only use the if statement To check if thresholds are closed, open a div and then open next.

In your example, your array is numeric, so we can use the index key in the form of a counter.

You can use only for a simple statement.

  & lt; div class = "employer-box" & gt; {Foreach key = $ counter item = $ emp = $ Employer} {if $ counter = 15 === 0} & lt; div id = "employer-box - {$ counter / 15}" category = "employer" & gt; {/ if} & lt; div class = "employer" & gt; & Lt; Div class = "employer photo" & gt; & Lt; img src = "{$ emp.photo}" & gt; & Lt; / Div & gt; & Lt; Div class = "employer name" & gt; & Lt; a href = "viewemplyer.php? employer = {$ emp.id}" & gt; {$ Emp.name} & lt; / A & gt; & Lt; / Div & gt; {If $ counter = 15 === 0} & lt; / Div & gt; {/ if} {/ foreach} & lt; / Div & gt;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -