Trying to build a while loop. Advice, tips, help?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Trying to build a while loop. Advice, tips, help?
Larcen
CZ Super Newbie
Larcen has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 36
Points: 1,270
   
I figure on changing out the <li></li>'s for a function maybe and the function doing the work, but here is what I got now, and instead of the <li>'s i'd like to have it do <td>'s and stop at 3 columns and start a new <tr> row. so the page isn't so god awful long.

  if ($misc == "") {
                 $misc = "None";
             } else {
                 $misc = ereg_replace (",", "</li><li>", $misc);
         }

I have a general idea but just can't seem to make my brain print it out through my fingers. I want to throw the new rows in after like three or so so it becoms a nice neat organized table instead of all in a row. The $misc for example from above comes from a TEXT type field in mysql that has entries that are seperated by , so the ereg_replace will make it into new lines each item. I know this can be done by a while loop and count++'s but putting it down in the code is confusing me and i am lost and have a headache.


Back to top Reply with quote
#2   re: Trying to build a while loop. Advice, tips, help?
rlgnak
CZ Super Newbie
rlgnak has been a member for over 19 year's 19 Year Member
usa.gif alaska.gif
Occupation: College
Gender: Male
Status: Offline
Joined: Jun 22, 2004
0.01 posts per day
Posts: 62
Points: 3,367
   
Ok this is what i came up with if anyone has better idea please share lol

if ($misc == "") {
   $misc = "None";   
}else{
     $misc = explode(',', $misc);
     $text = '<table><tr>';
     foreach ($misc as $value) {
          if($i == 3){
         $text .= '</tr><tr>';
         $i = 0;         
      }
          $text .= '<td>'.$value.'</td>';
      $i++;
   }
   $text .= '</tr></table>';
   $misc = $text;
}




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#3   re: Trying to build a while loop. Advice, tips, help?
Larcen
CZ Super Newbie
Larcen has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 36
Points: 1,270
   
That worked great, thank you.



Back to top Reply with quote
#4   re: Trying to build a while loop. Advice, tips, help?
rlgnak
CZ Super Newbie
rlgnak has been a member for over 19 year's 19 Year Member
usa.gif alaska.gif
Occupation: College
Gender: Male
Status: Offline
Joined: Jun 22, 2004
0.01 posts per day
Posts: 62
Points: 3,367
   
icon_biggrin.gif happy to help where i can




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#5   re: Trying to build a while loop. Advice, tips, help?
Larcen
CZ Super Newbie
Larcen has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 36
Points: 1,270
   
I always tend to forget about explode() if I don't use it after a while. lol



Back to top Reply with quote
#6   re: Trying to build a while loop. Advice, tips, help?
rlgnak
CZ Super Newbie
rlgnak has been a member for over 19 year's 19 Year Member
usa.gif alaska.gif
Occupation: College
Gender: Male
Status: Offline
Joined: Jun 22, 2004
0.01 posts per day
Posts: 62
Points: 3,367
   
i find it very useful to get at those CSV's stuff i still dont know any better way todo it.




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum