kds2 Posted June 21, 2012 Share Posted June 21, 2012 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>"; } Quote Link to comment https://forums.phpfreaks.com/topic/264585-custom-sized-tables-with-cell-text-pulled-from-database-problem/ Share on other sites More sharing options...
xyph Posted June 21, 2012 Share Posted June 21, 2012 It's hard to follow exactly what's going on here. Can you provide us with a table structure and sample data, along with what you want the output to be? Quote Link to comment https://forums.phpfreaks.com/topic/264585-custom-sized-tables-with-cell-text-pulled-from-database-problem/#findComment-1355988 Share on other sites More sharing options...
kds2 Posted June 22, 2012 Author Share Posted June 22, 2012 Sure. This is what I am getting (1.jpg). but it should be looking like this (2.jpg) Quote Link to comment https://forums.phpfreaks.com/topic/264585-custom-sized-tables-with-cell-text-pulled-from-database-problem/#findComment-1355992 Share on other sites More sharing options...
xyph Posted June 22, 2012 Share Posted June 22, 2012 How are you storing the data in the database? Quote Link to comment https://forums.phpfreaks.com/topic/264585-custom-sized-tables-with-cell-text-pulled-from-database-problem/#findComment-1356016 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.