rijen laten zien in 1 tabel

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Raimond

raimond

12/10/2007 11:46:00
Quote Anchor link
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?
 
PHP hulp

PHP hulp

27/12/2024 02:08:10
 
Jacco Engel

Jacco Engel

12/10/2007 11:55:00
Quote Anchor link
Code?
 
Raimond

raimond

12/10/2007 12:02:00
Quote Anchor link
Jacco schreef op 12.10.2007 11:55:
Code?

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
            <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>
Gewijzigd op 01/01/1970 01:00:00 door raimond
 
Jacco Engel

Jacco Engel

12/10/2007 12:04:00
Quote Anchor link
Inclusief query en dergelijken
 
Raimond

raimond

12/10/2007 12:06:00
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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;
?>
 
Frank -

Frank -

12/10/2007 12:11:00
Quote Anchor link
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?
 
Raimond

raimond

12/10/2007 12:32:00
Quote Anchor link
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 :-(
 
Frank -

Frank -

12/10/2007 12:48:00
Quote Anchor link
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!
 
Raimond

raimond

12/10/2007 13:20:00
Quote Anchor link
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.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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;
?>
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.