Ik moet een tabel hebben met een header en daaronder de rijen. De import vanuit de db gaat prima, echter gooit ie deze rijen telkens in een nieuwe tabel. Hoe kan ik dit in één tabel krijgen.

voorbeeld nu:
| header 1 | header 2 |
--------------------------
| waarde 1 | waarde 1|


| header 1 | header 2 |
--------------------------
| waarde 2 | waarde 2|

| header 1 | header 2 |
--------------------------
| waarde 3| waarde 3|


voorbeeld hoe het moet zijn:
| header 1 | header 2 |
--------------------------
| waarde 1 | waarde 1|
| waarde 2 | waarde 2|
| waarde 3 | waarde 3|

Waar gaat het fout?
Jacco schreef op 12.10.2007 11:55
Code?

            <table cellpadding="4" cellspacing="0" border="0" class="contentpane">
			<thead>
 			<tr >
	        		<th colspan="2">Naam</th>
	        		<th>Bedrijf</th>
            </tr>
			</thead>
			<tbody>
            <tr>
            	<td width="40px"  class=""sectiontableheader" >
					<?php // Display User Details
						echo $registrant->value;
						//echo $registrant->comments . "<br clear=\"left\" /><br />";
					?>	
            	</td>
            	<td width="200px">
					<?php // Display User Details
			            echo  $registrant->fullname;
					?>	
            	</td width="200px">
            	<td>
					<?php // Display User Details
			             echo  $registrant->name;
					?>	
	            </td>
            </tr>

    		<tbody>
            </table>
Inclusief query en dergelijken

<?php
    }  // viewSession()
   
   
	function displayRegistrations(&$row, $option, $customValues, $customFields) {
		global $database, $mosConfig_live_site, $mosConfig_lang, $eSess;
 		
		/* 
		 * Original Code from Michael Spredemann (scubaguy), which was based on
	     * Buddy Hack by Ford on http://www.mambojoe.com
	     * Revised by pcarr to conditionally deal with guests and community builder
	     */

		// query for people already registered
		//$query  = "SELECT * FROM #__events_registrations ";
		//$query .= "WHERE session_id='".$row->session_id."' AND cancel_date='0000-00-00 00:00:00' ";
		//$query .= "ORDER BY fullname ASC";
		//$database->setQuery($query);
		//$registrants = $database->loadObjectList();

		$query  = "SELECT reg.*, val.* FROM #__events_registrations AS reg"
		. "\n INNER JOIN #__events_registration_fields_values AS val ON val.registration_id = reg.registration_id"
		. "\n WHERE reg.session_id='".$row->session_id."' AND reg.cancel_date='0000-00-00 00:00:00' and field_id='18'";
		$query .= "ORDER BY reg.fullname ASC";
		$database->setQuery($query);
		$registrants = $database->loadObjectList();

		if (count($registrants) > 0) {
			echo "<h3>" . _ESESS_REG_LIST . "</h3>";
		
			foreach ($registrants as $registrant) {			
				if ($eSess["cbIntegrated"] && $eSess["showAvatar"]) {
					// Load the avatar picture.  For guests, display the appropriate no_picture file...
					if ($registrant->userid) {
						$query = "SELECT avatar FROM #__comprofiler WHERE user_id='".$registrant->userid."' AND avatarapproved=1";
						$database->setQuery( $query );
						$avatarFileName = $database->loadObjectList();
						if ($avatarFileName[0]->avatar) {
							/* 
							 * Some photos may be from the gallery, while others may be user submitted
							 */
							if (strcmp("gallery", substr($avatarFileName[0]->avatar, 0, 7))) {
								$avatarImgPath = $mosConfig_live_site . "/images/comprofiler/tn" . $avatarFileName[0]->avatar;
							} else {
								$avatarImgPath = $mosConfig_live_site . "/images/comprofiler/" . $avatarFileName[0]->avatar;
							}
						} else {
							$avatarImgPath = $mosConfig_live_site . "/components/com_comprofiler/images/" . $mosConfig_lang . "/tnnophoto.jpg";
						}
					} else {
						$avatarImgPath = $mosConfig_live_site . "/components/com_comprofiler/images/" . $mosConfig_lang . "/tnnophoto.jpg";
					}
					
					echo "<img src=\"" . $avatarImgPath . "\" alt=\"\" align=\"left\" />";
				}
?>				
            <table cellpadding="4" cellspacing="0" border="0" class="contentpane">
			<thead>
 			<tr >
	        		<th colspan="2">Naam</th>
	        		<th>Bedrijf</th>
            </tr>
			</thead>
			<tbody>
            <tr>
            	<td width="40px"  class=""sectiontableheader" >
					<?php // Display User Details
						echo $registrant->value;
						//echo $registrant->comments . "<br clear=\"left\" /><br />";
					?>	
            	</td>
            	<td width="200px">
					<?php // Display User Details
			            echo  $registrant->fullname;
					?>	
            	</td width="200px">
            	<td>
					<?php // Display User Details
			             echo  $registrant->name;
					?>	
	            </td>
            </tr>

    		<tbody>
            </table>

<?php        
        
			
			} //foreach ($registrants as $registrant)
		} // if (count($registrants) > 0) 
	} // displayRegistrations
	
	
	
	
	
	
	
   
	function displayRegistrationForm($option, &$registration, &$customFields, $customValues) {
   		global $eSess, $mosConfig_absolute_path;
?>
foreach resultaat, maak een tabel aan.

Dat is wat er in jouw code staat. Dan is het niet zo gek dat je diverse tabellen krijgt, of wel dan?
pgFrank schreef op 12.10.2007 12:11
foreach resultaat, maak een tabel aan.

Dat is wat er in jouw code staat. Dan is het niet zo gek dat je diverse tabellen krijgt, of wel dan?


Allereerst bedankt voor je snelle reactie!

okay duidelijk.
Maar daarvoor in de plaats kan ik duys een "FOR" of "WHILE" gebruiken....en dan komen de foutmeldingen :-(
Foreach, for, while, het zijn allemaal lussen. En als jij in een lus iedere keer een compleet nieuwe tabel aanmaakt, krijg je een hele serie tabellen.

Wat jij wilt, is 1 tabel met een hele serie rijen. Het begin en einde van de tabel moet dus buiten de lus staan.

Succes!
YES :-D gevonden
volgorde veranderen van de table en het werkt!!

Nu nog een juiste query maken voor de insert, zodat alle kolommen goed gevuld worden.


<?php
    }  // viewSession()
   
   
	function displayRegistrations(&$row, $option, $customValues, $customFields) {
		global $database, $mosConfig_live_site, $mosConfig_lang, $eSess;
 		
		/* 
		 * Original Code from Michael Spredemann (scubaguy), which was based on
	     * Buddy Hack by Ford on http://www.mambojoe.com
	     * Revised by pcarr to conditionally deal with guests and community builder
	     */

		// query for people already registered
		//$query  = "SELECT * FROM #__events_registrations ";
		//$query .= "WHERE session_id='".$row->session_id."' AND cancel_date='0000-00-00 00:00:00' ";
		//$query .= "ORDER BY fullname ASC";
		//$database->setQuery($query);
		//$registrants = $database->loadObjectList();

		$query  = "SELECT reg.*, val.* FROM #__events_registrations AS reg"
		. "\n INNER JOIN #__events_registration_fields_values AS val ON val.registration_id = reg.registration_id"
		. "\n WHERE reg.session_id='".$row->session_id."' AND reg.cancel_date='0000-00-00 00:00:00' and field_id='18'";
		$query .= "ORDER BY reg.fullname ASC";
		$database->setQuery($query);
		$registrants = $database->loadObjectList();

		if (count($registrants) > 0) {
			echo "<h3>" . _ESESS_REG_LIST . "</h3>";
?>
            <table cellpadding="4" cellspacing="0" border="0" class="contentpane">
			<thead>
 			<tr >
	        		<th colspan="2">Naam</th>
	        		<th>Bedrijf</th>
            </tr>
			</thead>
			<tbody>
<?php		
			foreach ($registrants as $registrant) {			
				if ($eSess["cbIntegrated"] && $eSess["showAvatar"]) {
					// Load the avatar picture.  For guests, display the appropriate no_picture file...
					if ($registrant->userid) {
						$query = "SELECT avatar FROM #__comprofiler WHERE user_id='".$registrant->userid."' AND avatarapproved=1";
						$database->setQuery( $query );
						$avatarFileName = $database->loadObjectList();
						if ($avatarFileName[0]->avatar) {
							/* 
							 * Some photos may be from the gallery, while others may be user submitted
							 */
							if (strcmp("gallery", substr($avatarFileName[0]->avatar, 0, 7))) {
								$avatarImgPath = $mosConfig_live_site . "/images/comprofiler/tn" . $avatarFileName[0]->avatar;
							} else {
								$avatarImgPath = $mosConfig_live_site . "/images/comprofiler/" . $avatarFileName[0]->avatar;
							}
						} else {
							$avatarImgPath = $mosConfig_live_site . "/components/com_comprofiler/images/" . $mosConfig_lang . "/tnnophoto.jpg";
						}
					} else {
						$avatarImgPath = $mosConfig_live_site . "/components/com_comprofiler/images/" . $mosConfig_lang . "/tnnophoto.jpg";
					}
					
					echo "<img src=\"" . $avatarImgPath . "\" alt=\"\" align=\"left\" />";
				}
?>
				
            <tr>
            	<td width="40px" align="left">
					<?php // Display User Details
						echo $registrant->value;
						//echo $registrant->comments . "<br clear=\"left\" /><br />";
					?>	
            	</td>
            	<td width="200px" align="left">
					<?php // Display User Details
			            echo  $registrant->fullname;
					?>	
            	</td width="200px">
            	<td>
					<?php // Display User Details
			             echo  $registrant->name;
					?>	
	            </td>
            </tr>


<?php        
			} //foreach ($registrants as $registrant)
		} // if (count($registrants) > 0)      
?>
    		</tbody>
            </table>
<?php		
	} // displayRegistrations
	
   
	function displayRegistrationForm($option, &$registration, &$customFields, $customValues) {
   		global $eSess, $mosConfig_absolute_path;
?>

Reageren