View Full Version : random profiles on non-vb page
sabret00the
10-07-2003, 10:49 PM
can you help me with this snippet of code please
<?php
$randname="SELECT username, userid FROM user ORDER BY rand() LIMIT 1";
echo ("<a href=\"forums/member.php?s=&action=getinfo&userid=$randname\"><img src=\"img/v2-rand_prof.png\" alt=\"random profile\" width=\"292\" height=\"136\" border=\"0\" /></a>");
?>
when you click the image that that produces it's meant to send you to a random profile but instead of making the userid it gives me the query as the link
e.g. http://www.ebslive.com/forums/member.php?s=&action=getinfo&userid=SELECT username, userid FROM user ORDER BY rand() LIMIT 1
sabret00the
10-07-2003, 11:50 PM
ok figured it out kinda
<?php
$randpro2 = "SELECT * FROM user WHERE userid > 0 AND usergroupid != 10 AND usergroupid != 11";
$randprof = rand(0,$numbermembers);
echo ("<a href=\"forums/member.php?s=&action=getinfo&userid=$randpro2\"><img src=\"img/v2-rand_prof.png\" alt=\"random profile\" width=\"292\" height=\"136\" border=\"0\" /></a>");
?>
just need to get $randpro2 to echo the number of users instead of the users, can someone help?
Dean C
10-08-2003, 01:56 PM
$random = $DB_site->query_first("SELECT userid,usergroupid FROM user WHERE userid > 0 AND usergroupid <> 10 AND usergroupid <> 11 ORDER BY rand()");
echo "<a href=\"forums/member.php?s=&action=getinfo&userid=$random[userid]\"><img src=\"img/v2-rand_prof.png\" alt=\"random profile\" width=\"292\" height=\"136\" border=\"0\" /></a>";
sabret00the
10-08-2003, 04:22 PM
thanks mist, it's greatly appreciated :)
Dean C
10-08-2003, 05:53 PM
Your welcome :) It's always nice answering such simple questions from a place in learning where I was only 6months ago :)
sabret00the
10-09-2003, 02:57 PM
i have an additional query mist, how would i edit the code so it only shows members with more > 0 posts?
Dean C
10-09-2003, 05:32 PM
$random = $DB_site->query_first("SELECT userid,usergroupid FROM user WHERE userid > 0 AND usergroupid <> 10 AND usergroupid <> 11 AND posts > 0 ORDER BY rand()");
echo "<a href=\"forums/member.php?s=&action=getinfo&userid=$random[userid]\"><img src=\"img/v2-rand_prof.png\" alt=\"random profile\" width=\"292\" height=\"136\" border=\"0\" /></a>";
:)
sabret00the
10-09-2003, 09:48 PM
i get this error
Fatal error: Call to a member function on a non-object in /home/ebslive/public_html/index.php on line 161
Dean C
10-10-2003, 03:20 PM
And what is on that line?
sabret00the
10-10-2003, 03:54 PM
$random = $DB_site->query_first("SELECT userid,usergroupid FROM user WHERE userid > 0 AND usergroupid <> 10 AND usergroupid <> 11 AND posts > 0 ORDER BY rand()");
is that line exactly
sabret00the
10-15-2003, 01:21 PM
ok i fixed this thanks to the wonders of phpmyadmin
but $randprof = $DB_site->query_first("SELECT userid,usergroupid FROM user WHERE userid > 0 AND usergroupid <> 10 AND usergroupid <> 11 AND posts > 0 ORDER BY rand()");
echo ("<a href=\"forums/member.php?s=&action=getinfo&userid=$randprof[userid]\" target=\"_blank\"><img src=\"img/v2-rand_prof.png\" alt=\"random profile\" width=\"292\" height=\"136\" border=\"0\" /></a>");
is there anyway to get this to change userid per click instead of per page load
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.