Jerzxu Posted March 8, 2008 Share Posted March 8, 2008 HELLO! I am working on a featured users for my site and and it has to grab a random userid from the main accounts table then it goes to the pages table and grabs more info after it has grabbed the username from the main accounts table. It has to do this 3 times and echo the same code 3 times. Now oddly I don't get ANY errors with this code. It just doesn't do anything. //Featured $UID = mysql_query("SELECT * FROM `Accounts` WHERE 'Activated'='Yes' ORDER BY RAND() LIMIT 3"); for ($i=0;$i<3;$i++) { while ($recs = mysql_fetch_array($UID)) { $recs1 = $recs['Username']; $usernamequery = mysql_query("SELECT `Username` FROM `Accounts` WHERE `UID`='$recs1'"); $username = mysql_result($usernamequery,0); $pagequery = mysql_query("SELECT `Page` FROM `Accounts` WHERE `UID`='$recs1'"); $page = mysql_result($pagequery,0); $imagequery = mysql_query("SELECT `Img` FROM `UserPics` WHERE `Username`='$username'"); $image = mysql_query($imagequery,0); if ($page == "Normal") { //Grab About INFO $aboutquery = mysql_query("SELECT `About` FROM `Page_Normal` WHERE `Username`='$username'"); $about = mysql_result($aboutquery,0); } echo "<div class=featured1> <div class=\"padfeat1\" align=\"left\"> <img src=\"stylesheets/images/seperator_03.png\" align=\"left\" hspace=\"5\" /> Pad<br /> <img src=padfeat.jpg style=\"margin-top:1px;\" onclick=\"parent.location=''\" /><img src=padfeat.jpg hspace=\"3\" onclick=\"parent.location=''\" /><img src=padfeat.jpg onclick=\"parent.location=''\" /><img src=padfeat.jpg hspace=\"3\" onclick=\"parent.location=''\" /><br /> <center><a href=\"\">View More</a></center> </div> <img src=\"resize-image.php?image=".$image."\" width=\"62\" height=\"62\" hspace=\"2\" align=\"left\" onclick=\"parent.location=''\" /> <a href=\"http://www.ekoed.com/".$username."\">".$username."</a><br /> <a href=\"http://www.ekoed.com/users.php?account=".$page."\">".$page."</a><br /> About Them: ".$about."<br /> </div>"; } } Now I was reading somewhere that if you have ALOT of accounts that using RAND() would take some time. Not that I will have many users on my site, but is there a way to make it go faster? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 8, 2008 Share Posted March 8, 2008 if you're not seeing anything it's probably because one or more of you SQL statements is incorrect. when i use mysql_query(), i always include or die(mysql_error()) in case my SQL is bad. $result = mysql_query($sql) or die(mysql_error()); i would add some die's and see if your SQL is bad. Quote Link to comment Share on other sites More sharing options...
Jerzxu Posted March 8, 2008 Author Share Posted March 8, 2008 Added and nothing happened. No change whatsoever. It excutes the code, and I echoed some of the variables but they're empty. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 8, 2008 Share Posted March 8, 2008 which variables are empty? can you show output with echos in? Quote Link to comment Share on other sites More sharing options...
Jerzxu Posted March 8, 2008 Author Share Posted March 8, 2008 I edited it abit just to see if it would even grab non random codes. Still doesnt work. $UID = mysql_query("SELECT * FROM `Accounts` WHERE 'Activated'='Yes'"); for ($i=0;$i<3;$i++) { while ($recs = mysql_fetch_array($UID)) { $username = $recs['Username']; $imagequery = mysql_query("SELECT `Img` FROM `UserPics` WHERE `Username`='$username'"); $image = mysql_query($imagequery,0); if ($recs['Page'] == "Normal") { //Grab About INFO $aboutquery = mysql_query("SELECT `About` FROM `Page_Normal` WHERE `Username`='$username'"); $about = mysql_result($aboutquery,0); } if ($recs['Page'] == "Band") { //Grab About INFO } if ($recs['Page'] == "Business") { //Grab About INFO } if ($recs['Page'] == "Studio") { //Grab About INFO } if ($recs['Page'] == "Portfolio") { //Grab About INFO } if ($recs['Page'] == "Website") { //Grab About INFO } echo "<div class=featured1> <div class=\"padfeat1\" align=\"left\"> <img src=\"stylesheets/images/seperator_03.png\" align=\"left\" hspace=\"5\" /> Pad<br /> <img src=padfeat.jpg style=\"margin-top:1px;\" onclick=\"parent.location=''\" /><img src=padfeat.jpg hspace=\"3\" onclick=\"parent.location=''\" /><img src=padfeat.jpg onclick=\"parent.location=''\" /><img src=padfeat.jpg hspace=\"3\" onclick=\"parent.location=''\" /><br /> <center><a href=\"\">View More</a></center> </div> <img src=\"resize-image.php?image=".$image."\" width=\"62\" height=\"62\" hspace=\"2\" align=\"left\" onclick=\"parent.location=''\" /> <a href=\"http://www.ekoed.com/".$recs['Username']."\">".$recs['Username']."</a><br /> <a href=\"http://www.ekoed.com/users.php?account=".$recs['Page']."\">".$recs['Page']."</a><br /> About Them: ".$about."<br /> </div>"; } } As for the output. Just go to www.ekoed.com and that page is it. What is echoed is at the bottom of the page (just error checking underneath the copyright), which is the $UID. If $UID echo's but everything else doesnt. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 8, 2008 Share Posted March 8, 2008 silly question: are there any records where Activated = 'Yes'? Quote Link to comment Share on other sites More sharing options...
Jerzxu Posted March 8, 2008 Author Share Posted March 8, 2008 Yeah theres 2. I purposely made a second account just to check if that may have been causing the problem. Quote Link to comment Share on other sites More sharing options...
Barand Posted March 8, 2008 Share Posted March 8, 2008 $UID = mysql_query("SELECT * FROM `Accounts` WHERE 'Activated'='Yes' ORDER BY RAND() LIMIT 3"); Activated is a column name and shouldn't be in single quotes Quote Link to comment Share on other sites More sharing options...
Jerzxu Posted March 8, 2008 Author Share Posted March 8, 2008 Well that was dumb of me. WORKS NOW! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.