Jump to content

Trouble displaying results in 2 columns


mishasoni

Recommended Posts

Hi there -

 

I am using the below code to display a set of results in two columns.  I have used the exact code on another page and it works fine, but on this particular page it produces 2 warnings:

 

Warning: mysql_fetch_assoc(): 5 is not a valid MySQL result resource in /home/agciorg/public_html/events/2009/259/roster.php on line 78

 

Warning: mysql_fetch_assoc(): 5 is not a valid MySQL result resource in /home/agciorg/public_html/events/2009/259/roster.php on line 106

 

I've identified the problematic line #s below.

 

Any help as to what could be causing the errors would be much appreciated!

Thanks.

 

<?php							
$number_columns = 2; // manually set the number of columns
$break_point = ceil($totalRows_rsWorkshopRegistrants / $number_columns); // divide total rows by 2 to find break points
$counter = 0; // start a counter
?>


<table border="0" cellpadding="0" cellspacing="0">
   <tr>
<td></td>
<td valign="top">
	<?php 
		do {
			$counter++; // count the output ?> 

                                <?php echo $row_rsWorkshopRegistrants['FirstName'] ?> 
                                <?php echo $row_rsWorkshopRegistrants['LastName'] ?><br />

			<?php if (($counter % $break_point) == 0) { // if current row is equal to break_point
				echo "</td><td valign='top'>"; // close cell and start a new column
			} ?> 

<!-------LINE 106 ---------->  
                <?php } while (($row_rsWorkshopRegistrants = mysql_fetch_assoc($rsWorkshopRegistrants))) ?>	

</td>
    </tr>
</table>
			   
			   
<table border="0">
<?php do { ?>
	 <tr>
	       <td> </td>
		<td >
			<?php echo $row_rsWorkshopRegistrants['FirstName'] ?> 
                                <?php echo $row_rsWorkshopRegistrants['LastName'] ?>
                                <br />
		</td>
		</tr>
		<tr>
                    	</tr>

<!-------LINE 106 ----------> 
       <?php } while ($row_rsWorkshopRegistrants = mysql_fetch_assoc($rsWorkshopRegistrants)); ?>

</table>

 

 

 

Link to comment
Share on other sites

Query is:

 

mysql_select_db($database_AGCI, $AGCI);

$query_rsWorkshopRegistrants = "SELECT * FROM Registration_new WHERE Registration_new.EventID = 259";

$rsWorkshopRegistrants = mysql_query($query_rsWorkshopRegistrants, $AGCI) or die(mysql_error());

$row_rsWorkshopRegistrants = mysql_fetch_assoc($rsWorkshopRegistrants);

$totalRows_rsWorkshopRegistrants = mysql_num_rows($rsWorkshopRegistrants);

 

It must be connecting to the dB ok because it displays the first record correctly, but nothing after that other than the two warning lines.

Link to comment
Share on other sites

<?php                     
$number_columns = 2; // manually set the number of columns
$break_point = ceil($totalRows_rsWorkshopRegistrants / $number_columns); // divide total rows by 2 to find break points
$counter = 0; // start a counter
?>
                  

<table border="0" cellpadding="0" cellspacing="0">
   <tr>
   <td></td>
   <td valign="top">
      <?php 
         do {
            $counter++; // count the output ?>
            
                                <?php echo $row_rsWorkshopRegistrants['FirstName'] ?>
                                <?php echo $row_rsWorkshopRegistrants['LastName'] ?><br />
                                 
            <?php if (($counter % $break_point) == 0) { // if current row is equal to break_point
               echo "</td><td valign='top'>"; // close cell and start a new column
            } ?>

<!-------LINE 106 ----------> 
                <?php } while (($row_rsWorkshopRegistrants = mysql_fetch_assoc($rsWorkshopRegistrants, MYSQL_ASSOC))) ?>   
   
</td>
    </tr>
</table>
               
               
<table border="0">
   <?php do { ?>
       <tr>
             <td> </td>
         <td >
            <?php echo $row_rsWorkshopRegistrants['FirstName'] ?>
                                <?php echo $row_rsWorkshopRegistrants['LastName'] ?>
                                <br />
         </td>
         </tr>
         <tr>
                       </tr>

<!-------LINE 106 ---------->
       <?php } while ($row_rsWorkshopRegistrants = mysql_fetch_assoc($rsWorkshopRegistrants, MYSQL_ASSOC)); ?>

</table>

 

Does this make any difference?

 

In a line similar with mine, I have MYSQL_ASSOC after the the variable of the query result.

Link to comment
Share on other sites

The variable $rsWorkshopRegistrants is defined in the header, which is an include file.

 

mysql_select_db($database_AGCI, $AGCI);
$query_rsWorkshopRegistrants = "SELECT * FROM users WHERE users.UserEventID = 259"; //  **** NEED TO CHANGE EVENTID FOR EACH WORKSHOP ****
$rsWorkshopRegistrants = mysql_query($query_rsWorkshopRegistrants, $AGCI) or die(mysql_error());
$row_rsWorkshopRegistrants = mysql_fetch_assoc($rsWorkshopRegistrants);
$totalRows_rsWorkshopRegistrants = mysql_num_rows($rsWorkshopRegistrants);

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.