just as a test - i tried this:

$max_rows = 16;
$max_cols = 15;
echo "<table>\n";
for($i=1;$i<=$max_rows;$i++) {
echo "<tr>\n";
for($j=1;$j<=$max_cols;$j++) {
$sql = "SELECT seat FROM attendees";
if($query = @($sql)) {
echo "<td>SOLD</td>\n";
} else {
echo "<td>OPEN</td>\n";
}
}
}

--- This code is also missing the closing <TR> and </TABLE> ---

and this is the output (NOT what I am wanting):

SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD
SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD

    1) I typed the code into the browser as an example. If you're going to knit pick my helpfulness I'll just not answer your questions anymore.

    2) You're assuming that if the entry exists in the table it must be sold. That's probably the issue try printing:

    mysql_result($query,'sold') instead

      1) Im not nitpicking. I greatly appreciate your helping me

      2) that still didnt work - it is saying not sold for the total number of rows and cols....

        
        $max_rows = 16; 
        $max_cols = 15; 
        echo "<table>\n"; 
        for($i=1;$i<=$max_rows;$i++) { 
        echo "<tr>\n"; 
        for($j=1;$j<=$max_cols;$j++) { 
        $sql = "SELECT seat FROM attendees"; 
        $query = @mysql_query($sql);
        
        if($row = mysql_fetch_array($query))
        { 
        echo "<td>SOLD</td>\n"; 
        } 
        else 
        { 
        echo "<td>OPEN</td>\n"; 
        } 
        } 
        } 
        
        

          i must be doing something wrong - that code didnt work Shawon22 - it reverts back to the output above where it lists everything as sold...

            well....it is getting closer...

            i added in the where statement ( WHERE RowID=$i AND ColID=$j ) and it shows that it is working, BUT the seat that is in my db is #25 but the output of my script is making row1 and col1 the actual seat that is sold....

              reverse the condition then

              
              $max_rows = 16;  
              $max_cols = 15;
              echo "<table>\n";
              for($i=1;$i<=$max_rows;$i++) {
              echo "<tr>\n";
              for($j=1;$j<=$max_cols;$j++) {
              $sql = "SELECT seat FROM attendees";
              $query = @mysql_query($sql); if($row = mysql_fetch_array($query)) { echo "<td>OPEN</td>\n"; }
              else
              {
              echo "<td>SOLD</td>\n"; }
              }
              }

                now the first row and first column is open but the other 99 seats are sold

                here is my code in case i have something all messed up

                $max_rows = 16;  
                $max_cols = 15;
                echo "<table>\n";
                for($i=1;$i<=$max_rows;$i++) { echo "<tr>\n"; for($j=1;$j<=$max_cols;$j++) { $sql = "SELECT seat FROM tblSeats WHERE RowID=$i AND ColID=$j"; $query = @mysql_query($sql); if($row = mysql_fetch_array($query)) { echo "<td>OPEN</td>\n"; } else { echo "<td>SOLD</td>\n"; } } echo "</tr>"; } echo "</table>";

                  could u post the datas for the first 5 or 10 rows?

                    I have 1 db table:

                    CREATE TABLE tblseats (
                    RowID tinyint(4) NOT NULL default '0',
                    ColID tinyint(4) NOT NULL default '0',
                    Alias varchar(50) NOT NULL default '',
                    Seat varchar(5) NOT NULL default '',
                    Sold char(1) NOT NULL default '',
                    PRIMARY KEY (RowID,ColID),
                    UNIQUE KEY Alias (Alias),
                    UNIQUE KEY Seat (Seat)
                    ) TYPE=MyISAM

                    with the values:

                    RowID = 1
                    ColID = 1
                    alias = RiverRat
                    seat = 25
                    sold = 1

                    here is the output of my script:

                    OPEN SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD SOLD

                    they all should be open except for the 25th one which is the seat I have in the db

                    • but it is using the ColID and RowID from the db to determine which seat is sold.....
                      
                      $max_rows = 16;   
                      $max_cols = 15;
                      echo "<table>\n";
                      for($i=1;$i<=$max_rows;$i++) { echo "<tr>\n"; for($j=1;$j<=$max_cols;$j++) { $sql = "SELECT seat FROM tblSeats WHERE RowID=$i AND ColID=$j"; $query = @mysql_query($sql); $row = mysql_fetch_array($query); if($row['sold'] == '1') echo "<td>OPEN</td>\n"; else echo "<td>SOLD</td>\n"; } echo "</tr>"; } echo "</table>";

                        still the same output

                        OPEN SOLD SOLD SOLD SOLD SOLD SOLD SOLD

                        $max_rows = 16;
                        $max_cols = 15;
                        echo "<table>\n";
                        for($i=1;$i<=$max_rows;$i++)
                        {
                            echo "<tr>\n";
                            for($j=1;$j<=$max_cols;$j++)
                            {
                                $sql = "SELECT seat, sold FROM tblSeats WHERE RowID=$i AND ColID=$j";
                                $query = @mysql_query($sql);
                        		$row  = mysql_fetch_array($query);
                        		if($row['sold'] == '1')
                        		{
                        			echo "<td>OPEN</td>\n";
                        		}
                        
                        	else
                        	{
                        		echo "<td>SOLD</td>\n";
                        	}
                        }  
                        echo "</tr>";  
                        }  
                        echo "</table>";

                          sorry its the other way around try this

                          
                          
                          $max_rows = 16; 
                          $max_cols = 15; 
                          echo "<table>\n"; 
                          for($i=1;$i<=$max_rows;$i++) 
                          { 
                              echo "<tr>\n"; 
                              for($j=1;$j<=$max_cols;$j++) 
                              { 
                                  $sql = "SELECT seat, sold FROM tblSeats WHERE RowID=$i AND ColID=$j"; 
                                  $query = @mysql_query($sql); 
                                  $row  = mysql_fetch_array($query); 
                                  if($row['sold'] == '1') 
                                  { 
                                      echo "<td>sold</td>\n"; 
                                  } 
                          
                              else 
                              { 
                                  echo "<td>open</td>\n"; 
                              } 
                          }   
                          echo "</tr>";   
                          }   
                          echo "</table>";

                            well...i thought it was working.... maybe i asked the wrong question to begin with

                            here is my code:

                            <?php
                            $alphabet = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q');
                            $rowCount = 14;
                            $totalSeats = 238;
                            
                            $connection = mysql_connect("localhost","******","******") or die ("Couldn't make connection.");
                            $db = mysql_select_db("registration", $connection) or die ("Couldn't select database.");
                            $sql = "SELECT seat, alias FROM attendees";
                            $sql_result = mysql_query($sql,$connection) or die("Couldn't execute query.");
                            
                            $row = mysql_fetch_array($sql_result);
                            $alias = $row['alias'];
                            ?>
                            
                            <center>
                            <table class="seattable" width="650">
                            
                            <?php
                            for($i=0; $i<$totalSeats; $i++)
                            {
                            	$val = $i + 1;
                            	if($i % $rowCount)
                            	{
                            		echo "<td align=\"center\" valign=\"middle\" ";
                            	}
                            
                            else
                            {
                            	echo "</tr><tr>\n";
                            	echo "<td align=\"center\" valign=\"middle\" class=\"rowheader\">";
                            	echo $alphabet[($i / $rowCount)];
                            	echo "</td>\n";
                            	echo "<td align=\"center\" valign=\"middle\" ";
                            }
                            
                            if(in_array($val, $row))
                            {
                            	echo "class=\"closed\"><a class=\"sold\" onMouseOver=\"self.status='SOLD TO ".$alias."'; return true;\" onMouseOut=\"self.status=' '; return true;\">";
                            	echo "{$alias}";
                            }
                            
                            else
                            {
                            	echo "class=\"open\">";
                            	echo "<input type=\"radio\" name=\"seat\" value=\"{$val}\"><font class=\"avail\">{$val}</font>";
                            }
                            
                            if($i % $rowCount + 1)
                            {
                            	echo "</td>\n";
                            }
                            
                            else
                            {
                            	echo "</td></tr>\n\n";
                            }
                            }
                            ?>
                            </table>
                            </center>
                            

                            here is the output results:

                            http://www.lamerc.com/jay2/test2.php

                            and there are 2 things here:

                            1) I want to make th above look like this:
                            http://www.lanhorizon.com/step17.php

                            2) when pulling the seat from the db, it is only recognizing the first entry and not each one that has a seat value....

                              On Astectics

                                  if($i % $rowCount + 1) 
                                  { 
                                      echo "</td>\n"; 
                                  } 
                              
                              else 
                              { 
                                  echo "</td></tr>\n\n"; 
                              } 
                              

                              at this point you need to check with x = 5*y where {0<y<4}

                              so something like this:

                              switch ($i*5) {
                                case 1:
                                  break;
                                case 2:
                                  break;
                                case 3:
                                  break;
                              }

                              Then add in a spacer cell when the condition is met, like so:

                              switch ($i*5) {
                                case 1:
                                  echo "<td bgcolor=#EEEE>&nbsp;</td>\n";
                                  break;
                                case 2:
                                  echo "<td bgcolor=#EEEE>&nbsp;&nbsp;&nbsp;&nbsp;</td>\n";
                                  break;
                                case 3:
                                  echo "<td bgcolor=#EEEE>&nbsp;</td>\n";
                              }

                              as to your second question.

                              You pull the first row and then loop always using that row, you need to pull a new row each time through the loop.

                                Write a Reply...