Jump to content

Using colspan within a loop?


Bonmot

Recommended Posts

Don't know if this is possible but...I have a php loop that outputs data to a table. Ideally, I would like to have just oneof these outputs go to a cell that spans the width of the table. There are 17 cells foreach record. The first 16 can output in a single row of 16 cells each then the nextdata set generate the next row, etc. I would like it if the 17th cell generates below theline of the first 16 cells and extend the full width as in "colspan=16".The trouble is how to generate this table in a loop so that it ends up being 16 cells ina row, then a single cell full width and then repeat this pattern for each record.Is this possible?Many thanks.

Link to comment
Share on other sites

Sure it is...If I understand you correctly. :)Make your loop then you'll just create two rows inside that loop, like so...

while (...condition...) {	 echo "<tr>";		  //Data for first 16 columns	 echo "</tr><tr>";		  echo "<td colspan='16'>";			   //Data for last column		  echo "</td>";	 echo "</tr>";}

Link to comment
Share on other sites

it's worth pointing out that that the majority of what you would need to make a script like that work is not even in the example, plus about half of what is there is pseudo code. Not to say that PHP is hard, but there's more to it than that.

Link to comment
Share on other sites

I don't even know php and that looks easy... Makes me want to learn it even more.
Scientist is right.The problem that was posed here was more thouroughly addressed on the php forum (also by jkloth -- Thanks!). If you're interested, here it is: http://w3schools.invisionzone.com/index.php?showtopic=30671Even that is still just showing the very limited part of the code where I was havingthe problem. The whole thing is about twice as long as that. And that was just onesmall step in the overall app I was working on (which I finished today, Huzzah!).There are 34 php scripts, 2 CSS and a couple of htmls. I only pose problems on the forum when I'm really stuck but I don't know what I'ddo without the generous help from these members. I hope I can go back and relearn PHP step by step some time. It really doesn't lenditself to learning on the fly the way html or CSS or even Flash does.
Link to comment
Share on other sites

The problem that was posed here was more thouroughly addressed on the php forum (also by jkloth -- Thanks!).
Your welcome! :)
I hope I can go back and relearn PHP step by step some time. It really doesn't lenditself to learning on the fly the way html or CSS or even Flash does.
Sure it does. I never really went through any of the tutorials or anything. I just kinda jumped in and looked over some of the scripts here at work, and of course I use the W3Schools website as a reference if I need it and these forums if I have problems. Everything I've done with PHP, MySQL, and JavaScript have been fly-by-the-seat-of-my-pants kind of projects.But then again I do have a previous background in programming with Java (not javascript), C#, and Visual Basic so maybe that made it easier for me. :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...