Web Hosting Deals Holiday Logo Design Webcam Chat Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Programming / Scripting / Coding

Programming / Scripting / Coding Got a question about : PHP / Perl / Java / JavaScript / CGI Scripts / JavaScript coding. Ask here! We'll get you the answers !

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-2008, 06:09 AM
Junior Member
 
Join Date: Jan 2008
Posts: 2
slackbear is on a distinguished road
Hello, need a little help with a php script.

Hello,I'm new here xD

Me and a friend are working on a sql type database using xml rss feeds, the problem is the lines like this:

$feed->table_name_."$table"

and i'm not sure exactly how to resolve this, i've tried everything i can think of.Any help would be appreciated =)

here's the code i've got so far:
PHP Code:
function readdb($file$table$row$db$field) {
    
$feed = new SimpleXMLElement($filenulltrue);
        foreach (
$feed->table_name_."$table" as $theTable) { 
            foreach (
"$theTable->row_name_".$row as $theRow) {
                foreach (
"$theRow->db_".$db as $theDB) {
                    foreach (
$theDB->children() as $child) {
                        switch (
$child->getName()) {
                            case 
'$field':
                                return 
"$child<br />\n";
                            break;           
                        }
                    } 
                }
            }
        }
    } 
and here's what we started with:
PHP Code:
$db simplexml_load_file('feed.xml');

function 
readdb($table$row$coldb$colname) {
return 
"$db->table_name_$table->row_name_$row->col_db_$coldb->col_name_$colname";
}
print 
readdb(testrtest1user);
echo 
"<hr>";
print 
$db->table_name_test->row_name_rtest->col_db_1->col_name_user
?>


Last edited by slackbear; 01-09-2008 at 06:14 AM.
Reply With Quote
  #2 (permalink)  
Old 01-31-2008, 09:17 PM
Member
 
Join Date: Oct 2006
Posts: 47
weblizzer is on a distinguished road
Quote:
Originally Posted by slackbear View Post
Hello,I'm new here xD

Me and a friend are working on a sql type database using xml rss feeds, the problem is the lines like this:

$feed->table_name_."$table"

and i'm not sure exactly how to resolve this, i've tried everything i can think of.Any help would be appreciated =)

here's the code i've got so far:
PHP Code:
function readdb($file$table$row$db$field) {
    
$feed = new SimpleXMLElement($filenulltrue);
        foreach (
$feed->table_name_."$table" as $theTable) { 
            foreach (
"$theTable->row_name_".$row as $theRow) {
                foreach (
"$theRow->db_".$db as $theDB) {
                    foreach (
$theDB->children() as $child) {
                        switch (
$child->getName()) {
                            case 
'$field':
                                return 
"$child<br />\n";
                            break;           
                        }
                    } 
                }
            }
        }
    } 
and here's what we started with:
PHP Code:
$db simplexml_load_file('feed.xml');

function 
readdb($table$row$coldb$colname) {
return 
"$db->table_name_$table->row_name_$row->col_db_$coldb->col_name_$colname";
}
print 
readdb(testrtest1user);
echo 
"<hr>";
print 
$db->table_name_test->row_name_rtest->col_db_1->col_name_user
?>

please change the


PHP Code:
foreach ($feed->table_name_."$table" as $theTable) { 
to
PHP Code:
foreach ("$feed->table_name_".$table as $theTable) {

// OR 

foreach ("$feed->table_name_$table" as $theTable) { 
HOPE ANY OF THAT ARE CORRECT


i didn't try it yet so just try to play any of it
__________________
Philippines Freelance Web offers Web Design, Logo Design, Web Redesign, Website Development, Website Maintenance in freelance rate.

For more information please visit our website.
Reply With Quote
  #3 (permalink)  
Old 02-06-2008, 05:21 PM
Junior Member
 
Join Date: Jan 2008
Posts: 2
slackbear is on a distinguished road
Thanks for your reply, i figured no one would respond after the firt two weeks.I have already tried that way, and for the sake of it...i retried and i still get this error:

Warning: Invalid argument supplied for foreach() in /var/www/wtfhax.net/xml.php on line 13

If you run accross anything let me know
Reply With Quote
  #4 (permalink)  
Old 02-19-2008, 08:53 AM
Member
 
Join Date: Oct 2006
Posts: 47
weblizzer is on a distinguished road
Smile

IF you encounter that error meaning, their are no supplied value to be loop in for each so you might to check first the array if the sizeof($yourarray) > 0 then it executes or else nothing to loop.
__________________
Philippines Freelance Web offers Web Design, Logo Design, Web Redesign, Website Development, Website Maintenance in freelance rate.

For more information please visit our website.
Reply With Quote
  #5 (permalink)  
Old 03-09-2008, 12:24 PM
Senior Member
 
Join Date: May 2007
Posts: 181
Blog Entries: 1
skyfe is on a distinguished road
shouldn't this part:

Quote:
foreach ($feed->table_name_."$table" as $theTable) {
foreach ("$theTable->row_name_".$row as $theRow) {
foreach ("$theRow->db_".$db as $theDB) {
be:

Code:
        foreach ($feed->table_name_.$table as $theTable) { 
            foreach ($theTable->row_name_.$row as $theRow) {
                foreach ($theRow->db_.$db as $theDB) {
this?

Reply With Quote
Reply

Bookmarks

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
Forum Jump


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


Fake ID

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com