Jump to content

Custom sized tables with cell text pulled from database problem


kds2

Recommended Posts

I am having a problem getting my tables to populate with the date from my database.

I have a table that is sized by the user like in this case its 4 columns by 4 rows. The table is created properly. But the text in each cell does not get placed.

Say col 1 row 1 is labeled sqa1 with value of blue in my database

and col 2 row 2 is labeled sqb2 with value of red in my database

Instead of putting the data from the database it simply gives the cell label

Here is the code

 


while($info = mysql_fetch_array( $data )) 
{ 
$columns = $info['columns'];
$rows = $info['rows'];

$sqa1 = $info['sqa1'];
$sqa2 = $info['sqa2'];
$sqa3 = $info['sqa3'];
$sqa4 = $info['sqa4'];

$sqb1 = $info['sqb1'];
$sqb2 = $info['sqb2'];
$sqb3 = $info['sqb3'];
$sqb4 = $info['sqb4'];

$sqc1 = $info['sqc1'];
$sqc2 = $info['sqc2'];
$sqc3 = $info['sqc3'];
$sqc4 = $info['sqc4'];

$sqd1 = $info['sqd1'];
$sqd2 = $info['sqd2'];
$sqd3 = $info['sqd3'];
$sqd4 = $info['sqd4'];
}

$go = 1;

$width = $columns * 100;
$height = $rows * 100;


if ($go = 1) {
     echo "<table width = $width height = $height border = '1' cellspacing = '2' cellpadding = '0'>";

     // loop to create rows

    for ($r = 1; $r <= $rows; $r++) {
         echo "<tr>";

        // loop to create columns
         for ($c = 1; $c <= $columns;$c++) {

$convcode = $r;

if ($convcode == 1) {
$convcode2 = "a";
} elseif ($convcode == 2) {
$convcode2 = "b";
} elseif ($convcode == 3) {
$convcode2 = "c";
} elseif ($convcode == 4) {
$convcode2 = "d";
}

$$sq = "sq" . $convcode2 . $c;
// $$sq;
$sq2 = "$sq" . $convcode2 . $c;  

          echo "<td>$sq2</td> ";
        }
        
     echo "</tr>";
     }
     echo "</table>";
}

Link to comment
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.