Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-18-2005, 09:31 AM   #1 (permalink)
morpheuz
Code Monkey
 
Join Date: Feb 2005
Posts: 64
morpheuz is on a distinguished road
random/top member block?

I'm new to php and simply blown away at how vast it is in capability with mysql. My moderate understanding of html is the only thing keeping php from looking completely alien to me, so I hope that means an old dog can learn some things here.

At the moment, the only scripts that really have my goat are these profile/image generators. I tried to google this but 'block' seems to be correct terminology for the tail end. If this isn't helping I'll go into a little more detail. I've seen this on forums and classified sites where a list of random or 'top 10' images are displayed on a page (usually the index) outside of the image's actual location as linkable thumbnails. I would like to attempt both using member profiles with location inclusion from the profile data (as I've seen it before and it looks pretty cool).

Can anybody help me with this or point me to a tutorial out there that covers what I'm describing?

Thanks in advance. ^_^
morpheuz is offline   Reply With Quote
Old 02-18-2005, 11:06 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
do you have a database setup yet? if so, if you can describe the fields, then it would be more helpful.

there is a way to select random records with sql. the example below will probably not work because your database probably has different field names. but here is how you would select 10 random members:
PHP Code:
<?
$result 
mysql_query("select * from members order by rand() limit 10");
?>
__________________
Mike
sde is offline   Reply With Quote
Old 02-18-2005, 11:27 AM   #3 (permalink)
morpheuz
Code Monkey
 
Join Date: Feb 2005
Posts: 64
morpheuz is on a distinguished road
I have dbs set up on localhost. Which fields do you need? Just member profiles?

Is the above code for a random 10 and a top 10?
morpheuz is offline   Reply With Quote
Old 02-18-2005, 11:41 AM   #4 (permalink)
morpheuz
Code Monkey
 
Join Date: Feb 2005
Posts: 64
morpheuz is on a distinguished road
I'm using xampp and this thing is dying on me while using mysql for some reason. I can't browse any tables without it crashing at the moment so I hope browsing isn't necessary. All the member fields under structure look like this: mem_user, mem_pass, etc.

Last edited by morpheuz; 02-18-2005 at 08:09 PM.
morpheuz is offline   Reply With Quote
Old 02-18-2005, 08:21 PM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
when you say "top 10" .. what are you using as the element of measurement? is it number of posts? the above example is for random 10, .. the one below would be for top 10 if the field you are basing this on is number of posts.
PHP Code:
<?
$result 
mysql_query("select * from members order by posts desc limit 10");
?>
__________________
Mike
sde is offline   Reply With Quote
Old 02-19-2005, 12:40 AM   #6 (permalink)
morpheuz
Code Monkey
 
Join Date: Feb 2005
Posts: 64
morpheuz is on a distinguished road
For top 10 I was meaning profiles themselves turning up as results on the index page automatically, but that would mean there would be some kind of rating function in place wouldn't it?

The random 10 script is fine, but at what part of the string do I insert the db fields exactly and would the appropriate query be to return the results by mem_userid?

Here's two sites I could dig up showing what I'm talking about. I saw a msgboard like this that blew both away but I can't remember the url. >_<

anywho, http://www.webdate.com
http://www.datingsoftware.biz/demo


*EDIT

The string you provided was dead on, the tbl name for users is members; however, when I inserted the query in index.php nothing happened when I saved the file and reloaded the site. Comments?

Last edited by morpheuz; 02-19-2005 at 04:56 AM.
morpheuz is offline   Reply With Quote
Old 02-21-2005, 01:31 AM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
are you connecting to the database befor issuing the select statement ?
ie:
PHP Code:
$db mysql_connect("$server""$user""$password") or die("Invalid server or user."); 
mysql_select_db("your_database"$db); 
$result mysql_query("select * from members order by posts desc limit 10"$db); 
You might have forgotten the $db as the second argument to mysql_query()
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-21-2005, 12:45 PM   #8 (permalink)
morpheuz
Code Monkey
 
Join Date: Feb 2005
Posts: 64
morpheuz is on a distinguished road
Thanks, but nothing I insert from the suggestions seems to matter. The site isn't responding to the php I input or just returns errors if I venture out of the syntax above. I've spent about a week trying to figure this out now. My only guess is that I need to include more code to get the desired results.

I'm beginning to think mysql wants my soul for a trade...


Oh, I left out I'm working with a ready made db and php script so I'm sure this has alot to do with the problem now that I think about it. I'm either leaving something out that's necessary or filling in the fields wrong. I copy and paste what's been put here and when the code doesn't work as is, I try replacing certain words, etc.

The db script in the connect php looks like this: if (DB_CONNECT == 1) return; define("DB_CONNECT",1); and then follows with a series of $Const_ <--covers everything from layout formatting to database setup. Instead of including the root URL all the time I can just fill in $Const_URL/members instead of http://blah/members, etc.

The members table is fragmented instead of everything related being placed there. There are seperate tables for member pics, secondary profile info, and a mini version of member profiles (what the search results return and the data I'm trying to randomize/top 10 on the index). Don't know if this is relevant or not, but there is also a php file for functions.

I'm so lost. I'll never knock a programmer as long as I live. This work is as draining as any job.

Last edited by morpheuz; 02-21-2005 at 01:11 PM.
morpheuz is offline   Reply With Quote
Old 02-21-2005, 10:29 PM   #9 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Then try this:
PHP Code:
$result mysql_query("select * from members order by posts desc limit 10"$DB_CONNECT); 
$counter 1;
while(
$row mysql_fetch_array($result))
{
    echo 
"<b>Selected member " $counter++ . ":</b><br>";
    
print_r($row);
    echo 
"<hr>";
}
mysql_free_result($result); 
Just to give you an idear, if it is posible to fetch anything from the database.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 02-22-2005, 06:36 AM   #10 (permalink)
morpheuz
Code Monkey
 
Join Date: Feb 2005
Posts: 64
morpheuz is on a distinguished road
Thanks, but that's not doing anything either. I think the only way I'll be able to get a handle on this is to learn php/mysql from scratch. The script I'm using uses a complicated method of calling the mini version of profiles.
morpheuz is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Legislator seeks to block Gmail sde Code Newbie News 6 12-26-2004 06:46 PM
Fatal error: Call to a member function on a non-object CrossMediaGroup PHP 2 11-28-2004 02:46 PM
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:36 AM
C# member function sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 02:08 AM
How to check if a member is logged in? prendo PHP 4 04-10-2003 08:48 AM


All times are GMT -8. The time now is 10:57 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting