Welcome Guest, Not a member yet? Register   Sign In
Dynamically generate grid and populate it.
#1

[eluser]murphy2006[/eluser]
Hello!

I am a big problem. I am building small clone of the famous "million dollar homepage".
I need to generate a grid (40x60 squares) and then let people buy one or more of the squares. As I am generating the grid I need to populate the cells that are occupied and give it the color that the user selected.

The coordinates (row,cell) are saved into the database like this:

Code:
18,27 18,28 19,27 19,28

I have managed to generate the grid and populate the correct cells but I cannot color them.

Code:
include 'connect.php';

    $result = mysql_query("SELECT cus_pixels FROM customers");

    while($row = mysql_fetch_array($result)) {

        $string .= $row['cus_pixels']." ";

    }

    $pixels = explode(' ', $string);

    $a = 0;

    while ($a <= 40) {

        echo "<tr>";

        $b = 0;

        while ($b <= 60) {

            if (in_array($a.','.$b, $pixels)) {

                echo '<td class="occupied"></td>';

            } else {

                echo '<td class="pixel"></td>';

            }

            $b += 1;
        }

        echo "</tr>";

    $a += 1;

    }

Please help me fix this or perhaps suggest a better approch.
#2

[eluser]danmontgomery[/eluser]
This doesn't look related to codeigniter at all...




Theme © iAndrew 2016 - Forum software by © MyBB