Results 1 to 7 of 7
-
20th Jan 2012, 03:22 PM #1OPMember
[PHP] Need help to loop true the results
Thanks in advance!
The goal is to display a list of items (websites) sorted by most votes.
I've got this (from here):
<?php $items = ThumbsUp::items('[quote]')->open(TRUE)->orderby('votes_pct_up desc')->limit(3)->get() ?>
This would result in:
PHP Code:array (
0 =>
array (
'id' => 653,
'name' => '[quote] scandic',
'closed' => false,
'date' => 1325620171,
'votes_up' => 76,
'votes_down' => 36,
'votes_pct_up' => 67.8571,
'votes_pct_down' => 32.1429,
'votes_balance' => 40,
'votes_total' => 112,
),
1 =>
array (
'id' => 654,
'name' => '[quote] mozunk',
'closed' => false,
'date' => 1325620171,
'votes_up' => 75,
'votes_down' => 39,
'votes_pct_up' => 65.7895,
'votes_pct_down' => 34.2105,
'votes_balance' => 36,
'votes_total' => 114,
),
2 =>
array (
'id' => 655,
'name' => '[quote] clarklab',
'closed' => false,
'date' => 1325620171,
'votes_up' => 58,
'votes_down' => 33,
'votes_pct_up' => 63.7363,
'votes_pct_down' => 36.2637,
'votes_balance' => 25,
'votes_total' => 91,
),
)
Reference page: http://tpbmirrors.org/dev.phpAndroidApps Reviewed by AndroidApps on . [PHP] Need help to loop true the results Thanks in advance! The goal is to display a list of items (websites) sorted by most votes. I've got this (from here): <?php $items = ThumbsUp::items('')->open(TRUE)->orderby('votes_pct_up desc')->limit(3)->get() ?> This would result in: array ( 0 => Rating: 5
-
20th Jan 2012, 03:28 PM #2MemberWebsite's:
wscripts.net damnlolscript.com lulzjet.comPHP Code:foreach($items as $item) {
print_r($item); //print array
echo $item['id']; //echo id
echo $item['name']; //echo name
}
-
20th Jan 2012, 03:55 PM #3MemberWebsite's:
sborg.usYou can also use var_dump in place of print_r
http://php.net/manual/en/function.var-dump.php
V3g3ta | Halcyon | Abhi
-
20th Jan 2012, 04:13 PM #4OPMember
Thanks guys!
I am however a complete n00b to php
See http://tpbmirrors.org/dev.php
How do I get t3od0r's code to display "1 +1 -1"?
Cheers
-
20th Jan 2012, 04:47 PM #5MemberWebsite's:
sborg.usOh well!
PHP Code:foreach($items as $item) {
//print_r($item); //print array
echo $item['id'].' has ';
echo $item['votes_up'].' positive votes and '; //echo positive votes
echo $item['votes_down'].' negative votes '; //echo negative votes
echo '<br />'; //linebreak to make things look a bit better
}
653 has 76 positive votes and 36 negative votes
654 has 75 positive votes and 39 negative votes
655 has 58 positive votes and 33 negative votes
I hope you got the point. Check tutorials related to arrays in PHP and this will look a lot simpler
V3g3ta | Halcyon | Abhi
-
20th Jan 2012, 11:51 PM #6MemberWebsite's:
imdber.org justpaste.meIs that the thumbsup script?
-
5th Feb 2012, 09:56 AM #7OPMember
Thanks, I'm getting there
http://tpbmirrors.org/dev.php
Will update on the progress.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Php Loop Prob
By Chris2k in forum Web Development AreaReplies: 1Last Post: 16th Jan 2012, 02:00 PM -
[JAVA} Need help in a Nested Loop
By conrey in forum Web Development AreaReplies: 18Last Post: 10th Oct 2011, 09:41 AM -
is website outlook express results are true..?
By torrfriend in forum Webmaster DiscussionReplies: 2Last Post: 13th Aug 2010, 10:06 AM -
Google going into infinate loop!
By jstep2009 in forum General DiscussionReplies: 3Last Post: 28th Aug 2009, 03:36 PM -
Redirect loop?!?!
By GeeZus in forum Technical Help Desk SupportReplies: 4Last Post: 9th Jun 2009, 04:36 AM
themaManager - edit and manage...
Version 4.04 released. Open older version (or...