0

I have a MySQL table, in which are a number of values. I want these values to be put into a table. The resulting page will be fed through a HTML to PDF script and it seems not to like floats for some reason, so I figured a table would be the best fail-safe method. The table should be 7 columns wide, but my data exceeds that and will continue to grow. How do I tell my PHP script that, after every seven items (7, 14, 21, etc.), we start a new row?

Also, how would the script alter if two variables are in the same cell? Say an icon URL (call it $iconURL) and a piece of descriptive text (call it $desTXT)? I am a PHP noob and don't really know how it would work, I'm just getting to grips with calling the information from a database as it is.

1
  • how exactly is your data structured, and with what query are you retrieving it? Commented Nov 22, 2011 at 21:21

1 Answer 1

1

Set a counter in your loop as you're going through the rows.

If the counter reaches 7 (or 6 if you do it from 0), insert a conditional statement for the break. Then reset the counter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.