I need some help with this code

AntiTrust

New member
Joined
Mar 4, 2013
Messages
19
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
Joined
Feb 1, 2013
Messages
495
Points
63
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
Joined
Mar 4, 2013
Messages
19
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
3,036
Replies
1
Views
2,555
Replies
1
Views
3,832
Newer threads
Replies
4
Views
3,431
Replies
1
Views
3,433
Replies
4
Views
4,150
Replies
0
Views
3,280
Latest threads
Replies
0
Views
208
Replies
3
Views
244
Replies
3
Views
321
Replies
3
Views
59
Replies
3
Views
240
Recommended threads
Replies
2
Views
3,480
Replies
4
Views
3,668
Replies
9
Views
4,044

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

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