I need some help with this code

AntiTrust

New member
Registered
Joined
Mar 4, 2013
Messages
7
Points
0
I have this code and i want to change it to get random from database.
Any ideea?

$resim = mysql_query("SELECT * FROM ".$table_prefix."postmeta LEFT OUTER JOIN ".$table_prefix."posts ON ".$table_prefix."postmeta.post_id = ".$table_prefix."posts.id Where ".$table_prefix."postmeta.meta_key='featured' ORDER By ".$table_prefix."postmeta.post_id DESC Limit 4");
for ($j=0; $niphell=mysql_fetch_array($resim); $j++){
$ust .= '<li class="ui-tabs-nav-item" id="nav-fragment-'.($j+1).'"><a href="#fragment-'.($j+1).'"><img src="'.$niphell[meta_value].'" width="120" height="90" alt="" /></a></li>
';
$alt .='<div id="fragment-'.($j+1).'" class="ui-tabs-panel" style="">
'.get_post_meta($niphell[post_id], 'embed', true).'
</div>
';
}
 

Inquestor

Well-known member
Registered
Joined
Feb 1, 2013
Messages
215
Points
0
Hey,

Here is the only way to generate a random (anything) from an SQL database. All other ways would require additional PHP functionality

mysql_query("SELECT * FROM ".$table_prefix."postmeta LEFT OUTER JOIN ".$table_prefix."posts ON ".$table_prefix."postmeta.post_id = ".$table_prefix."posts.id WHERE ".$table_prefix."postmeta.meta_key='featured' ORDER BY RAND() LIMIT 4");
 

AntiTrust

New member
Registered
Joined
Mar 4, 2013
Messages
7
Points
0
Thank you verry much, it was helpful, i chaged the old code with this one and woks great
 
Older Threads
Replies
2
Views
2,882
Replies
1
Views
2,188
Replies
1
Views
2,643
Replies
55
Views
21,737
Replies
47
Views
15,910
Newer Threads
Replies
6
Views
3,459
Replies
4
Views
3,228
Replies
5
Views
3,590
Latest Threads
Replies
0
Views
47
Replies
0
Views
83
Replies
0
Views
93
Recommended Threads
Replies
13
Views
6,270
Replies
8
Views
2,502
Replies
2
Views
2,316
Replies
5
Views
3,139
Replies
4
Views
3,053
Similar Threads
Replies
1
Views
606
Replies
3
Views
853
Replies
7
Views
1,772

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top