TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-08-2008, 01:12 AM   #1 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default Outputting MySQL Results

I just spent a good 20 minutes writing this out, before I realized I'm not explaining it well, nor will all the info I need help with fit on this page. If any of you who are PHP 'gurus' would be willing to hire yourself out for an hour to help me with some questions/problems I'm having, that would be much appreciated. I've probably spent several hours trying to get this to work, using a multitude of different methods, rewriting my code a full two times, and still have gotten no where. That isn't even counting the time I've spent just LOOKING for ways it can be done.

If you would like to read what I started to write, here it is:

Sorry I couldn't think of a better title, but it suffices.

Here is my problem. I'm currently coding a wallpaper script for a multitude of reasons. A few of which being it would help me further my schools by implementing some things I've never used before, developing it for my own site and another persons. I'm trying to make it easy to integrate into, so I'm using "WordPress-like" output techniques (such as $settings->info('url')), and I'm running into trouble actually outputting the data in an easy way.

Now, I've seeked advice from Dread (whom of which Salathe and Wildhoney know) and he told me the way he would store database results, instead of using the results from mysql_fetch_array(), was to run a while loop, and put all the results into an array. It has been going great, but I've ran into a few problems.

The first being, that I have to use a foreach() loop in my site to go through the array and fill in the results. Problem being, the foreach() loop requires an "AS" clause, and I have it, but I'm not using it at all (though I might have to globalize it to make sure I'm getting the right result). Here is my code for my output:
PHP Code:
<?php foreach ($wp->in_category(1) as $wall): ?>
                <div class="wallpaper">
                    <img src="<?php $wp->get_option('thumb_url'); ?>" alt="<?php $wp->get_option('title_attr'); ?>" />
                    <a href="<?php $wp->get_option('view_url'); ?>" title="<?php $wp->get_option('title_attr'); ?>"><?php $wp->get_option('name'); ?></a>
                    <a href="<?php $wp->get_option('download_url'); ?>" title="Download <?php $wp->get_option('title_attr'); ?>" class="download">download this now!</a>
                </div>
            <?php endforeach; ?>
The problem I'm running into this, is that for some STRANGE reason, only the 4th and 2nd data entries in the database properly come out when I'm using a pagination script.
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 01-13-2008, 12:09 PM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

<?php foreach ($wp->in_category(1) as $wall): ?> <- why do you have a colon here?
Orc is offline  
Reply With Quote
Old 01-13-2008, 02:06 PM   #3 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
<?php foreach ($wp->in_category(1) as $wall): ?> <- why do you have a colon here?
Its an alternative to using brackets.
__________________

Village Idiot is offline  
Reply With Quote
Old 01-13-2008, 03:02 PM   #4 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Perhaps he didn't notice the 'endforeach' statement down there :)
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-13-2008, 04:03 PM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
Perhaps he didn't notice the 'endforeach' statement down there :)
Usually they say that's valid yet I always get an error.
Orc is offline  
Reply With Quote
Old 01-13-2008, 04:59 PM   #6 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Then you must be using it wrong. Because that's a language construct, it can't throw errors if it's used like it's made to.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB 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. The time now is 05:00 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design