Jump to content

Recommended Posts

So, I took over a project from someone else, and I am trying to populate three columns in a table where there was previously two columns. I've almost got things figured out, but can't quite get my third column to fill. I've got it so its separating the the data into thirds, but only the left column actually has exactly one third of the data. The middle column has the other two thirds of data, and the right column has no data.

 

Here is the code I am working with. However, I've changed what we produce to "stuff" and left out the url for privacy reasons:

 

$iUp = 1;

        $pQuery = mysql_query($query) or die(mysql_error());
        $pExist = mysql_num_rows($pQuery);

        if(!empty($pExist)){

            //$this->stuffPackageOut .= '<form action="https://*************.111/cart" method="GET" name="stuff" onsubmit="return anyCheck()">';
            //$this->stuffPackageOut .= '<form action="index.php" method="GET" name="stuff" onsubmit="return anyCheck()">';
            $this->stuffPackageOut .= '<input type="hidden" name="cart!addFamily">';

            $pCnt = $pExist;
            $pCntHalf = floor($pCnt/3);
            $stuff[0] = NULL;
            $stuff[1] = NULL;
            $stuff[2] = NULL;
            $div = 0;

            while($pRow = mysql_fetch_object($pQuery)){
                if($pCntHalf < $iUp){
                    $div = 2;
                    $div = 1;
                }else{
                    $div = 0;
                    
                }

                $contribName = strtolower(str_replace(" ", "", $pRow->conName));
                $stuffName = strtolower(str_replace(" ", "", $pRow->stfName));

                $stuff[$div] .= '<tr><td valign="top"><input type="checkbox" name="cart_family'.$iUp.'" value="'.$pRow->familyId.'" id="package"> <a href="http://****************.com/stuff/'.$stuffName.'.php" class="packagestufflinks">'.$pRow->fntName.'</td></tr>';
                $iUp++;
            }

            $stuffLeft  = '<table width="137" border="0" cellspacing="8" cellpadding="0" height="10" valign="top">';
            $stuffLeft .= $stuff[0];
            $stuffLeft .= '</table>';

            $stuffMiddle  = '<table width="137" border="0" cellspacing="8" cellpadding="0" height="10" valign="top">';
            $stuffMiddle .= $stuff[1];
            $stuffMiddle .= '</table>';
            
            $stuffRight  = '<table width="137" border="0" cellspacing="8" cellpadding="0" height="10" valign="top">';
            $stuffRight .= $stuff[2];
            $stuffRight .= '</table>';

            $this->stuffPackageOut .= '<table width="100%" height="10"><tr><td align="left" valign="top" width="238" height="10">'.$stuffLeft.'</td><td width="29" valign="top" background="verticaldivider.gif"><img src="http://www.****************.com/pageimages/spacer.GIF" width="29" height="5"></td><td align="left" valign="top" width="238">'.$stuffMiddle.'<td><td width="29" valign="top" background="verticaldivider.gif"><img src="http://www.****************.com/pageimages/spacer.GIF" width="29" height="5"></td><td align="left" valign="top" width="238">'.$stuffRight.'</td></tr></table>';

 

 

I know it has something to do with everything following the "while" coding, but since I don't do this for a living I have no idea what coding is necessary to make my three columns populate.
Please help me.

 

Link to comment
https://forums.phpfreaks.com/topic/287597-populating-a-three-column-table/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.