I would like to display my Query from Mysql on the table. However, my data is like this:
Array([0]=>data1, [1]=>data2, [2]=>data3,[3]=>data4,[4]=>pic1,[5]=>pic2,[6]=>pic3,[7]=>pic4);
I want to display my table as:
|data1 | data2 |data3 |data4
|pic1 | pic2 |pic3 |pic4
I know how to display the data in the single ling like td or tr but not sure how to do tr and td on the same loop. Any helps? Thanks in advance!
while($query=mysql_fetch_array($dataQuery)){
//not sure what to do here.
}
It’s probably easier to assemble the two rows as strings first and then output them betwen table rows. You know how many items you have (number of rows), so divide that by two. Then subtract one from that number (you might want to check that it’s even so you know you haven’t made a mistake) to account for the fact arrays are zero-based. Loop over the whole array. Until you hit your halfway point, you’re assembling your title row. After that you’re assembling your picture row. Then echo the results between table row tags. Here’s a rough (untested) shot at the code: