Members: 16,996
Threads: 38,846
Posts: 159,391
Online: 21

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Archive > Mambo 4.5 > Mambo 4.5 'How Do I' Questions

 
 
LinkBack Thread Tools Display Modes
Old 08.04.2004, 21:13   #1 (permalink)
Junior Mamber
 
noobnuggets's Avatar
 
Join Date: Apr 2004
Location: North Carolina, USA
Posts: 45
noobnuggets is on a distinguished road
Default How to get field names from database, and use pagebreaks too

Hello, I am using the mosaddphp mambot to create articles using dynamic content from other tables I have added to the mambo database. What I was wondering is how do I get the field names? I am using the following syntax:
Code:
PHP Code:
$content "";
$query "SELECT * FROM #__blah ORDER BY blah ASC";
$database->setQuery($query);
$rows =$database->loadObjectList();
$content .="<table cellpadding=\"1\" border=\"0\">";
foreach(
$rows as $row) {
   
$content .="<tr><td valign=\"top\"><img src=\"$mosConfig_live_site/images/M_images/arrow.png\" alt=\"\" /></td>";
   
$content .="<td>".$row->blah."  ".$row->Last_Name."</td><td>"
               
.$row->blah."</td><td>"
               
.$row->blah."</td><td>"
               
.$row->blah."</td></tr>";
}
$content .="</table>";
echo 
$content

This works very nicely, but I do not know how to get the field names so I can add them to the output.

Also I was trying to get {mospagebreak} to work with this so that the output would be spread across several pages. I used the following code:
PHP Code:
    $count++;
    if (
$count 30 == 0)
        echo 
"{mospagebreak}"
I declared the $count variable above the first line of my script, and then added the bit of code above as the first thing inside the foreach statement.
When I run it, I get a blank page with the proper number of pagination links on the bottom. If I try to go to the next page it says: You are not authorized to view this resource.

How do I fix this? And get the fieldnames?
noobnuggets is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Old 08.04.2004, 22:50   #2 (permalink)
Senior Mamber
 
Gayle's Avatar
 
Join Date: Apr 2004
Posts: 140
Gayle is on a distinguished road
Default Re: How to get field names from database, and use pagebreaks too

http://uk.php.net/mysql_list_fields

No idea on the other without seeing the full code.
__________________
"Unix gives you just enough rope to hang yourself -- and then a couple of more feet, just to be sure" --- Eric Allman
Gayle is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09.04.2004, 00:21   #3 (permalink)
Junior Mamber
 
noobnuggets's Avatar
 
Join Date: Apr 2004
Location: North Carolina, USA
Posts: 45
noobnuggets is on a distinguished road
Default Re: How to get field names from database, and use pagebreaks too

Here is the full code of the home_phones.php file:
PHP Code:
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$count 0;
$content "";
$query $mosaddphp_params[0];
$database->setQuery($query);
$rows =$database->loadObjectList();
$content .="<table cellpadding=\"1\" class=\"custom\">";
$content .="<tr><th></th><th>Name</th><th>Home Phone</th><th>Work Phone</th><th>Cell Phone</th></tr>";
foreach(
$rows as $row) {
     
$count++;
    if (
$count 30 == 0)
           echo 
"{mospagebreak}";
    
$content .="<tr><td valign=\"top\"><img src=\"$mosConfig_live_site/images/M_images/arrow.png\" alt=\"\" /></td>";
    
$content .="<td>".$row->First_Name."  ".$row->Last_Name."</td><td>"
                    
.$row->Home_Phone."</td><td>"
                    
.$row->Work_Phone."</td><td>"
                    
.$row->Cell_Phone."</td></tr>";
}
$content .="</table>";
echo 
$content;
?>
In my article I am using: {mosaddphp:home_phones.php,SELECT * FROM mos_table ORDER BY First_Name ASC} This is in the main text box. The privileges are set to special.

When I look at this page I can see the text that is in the intro text box, and then I can see the pagination links that mambo inserted, but none of the content from the database appears, and if I click to see the next page, it gives me a message that I am not authorized.

Thanks for the help with the fields. I was thinking that I could get it from the loadObjectList() function somehow, but after reading through the database.class.php file I realize that i was confused. I am pretty new at php.
noobnuggets is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 06:22.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.