[PHP-DB] Multiple Referral Levels

2002-09-25 Thread Daren Cotter

I'm using MySQL to attempt to track multiple referral
levels for a web site. I.e., member 1 refers 2, 2
refers 3, 3 refers 4...member 4 is is on member 1's
3rd referral level.

Anyway, I need to be able to compile a list of the #
of referrals for a specific member on any given level
(up to 12 levels), and I'm trying to determine the
best database setup. I know that a normalized setup
could be:

table:
id int unsigned not null auto_increment
referer int unsigned null
primary key (id)
key (referer)

With this setup, inserting new members would be no
problem. Grabbing the number of referrals for a member
on level 1 would be easy:
SELECT count(*) FROM table WHERE referer = 1
Second level wouldn't be too difficult either, using a
join, but 3rd level and on would be done how? Is it
even possible? I'm aware I could setup some sort of
recursive function, but if a member has 5,000
referrals on level one, I certainly don't want to run
5,000 queries and total the results to get level 2.

So perhaps a design more like:
id
ref1
ref2
ref3
etc
would be better? It's not normalized, but it might do
the job...querying any member's referrals for a
specific level would be no problem. The signup process
would have a bit more work to do, because it'd have to
recursively find the referer all the way up of course.

Bottom line, is I'm looking for the best database
setup that will accomodate my needs (I NEED to be able
to run a queyr that shows me the # of referrals broken
down by level for a member).

Ideally, the # of referral levels would be variable,
meaning the database should not be setup in a way to
accomodate x referral levels, but instead should
accomodate 0-12.

I know there are websites that achieve this (whether
they use MySQL, I don't know)...can anyone offer any
insight?



__
Do you Yahoo!?
New DSL Internet Access from SBC  Yahoo!
http://sbc.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Re: how to format the output of the text info that user uploaded?

2002-08-18 Thread Daren Cotter

If the method they use to upload involves pasting
the text into an HTML textbox, I usually do this:
replace all occurances of \n with br.

Look into the ereg_replace() function in the manual or
at php.net for more info, but that is some limited
formatting.

If you need further formatting, like someone else
pointed out, you'll need to post more info.


--- David Robley [EMAIL PROTECTED] wrote:
 In article
 [EMAIL PROTECTED],
 [EMAIL PROTECTED] 
 says...
  I have a field in a form which allows user to
 upload thier biographys.Once
  they upload a bunch of texts,the script I wrote
 automatically show it on a
  webpage, however, the contents are all scrambled
 toghther without line break
  and formatting..
  How am I able to show the formatted outputs?
  
  I tried to use pre /pre, but it didn't work
 well.
  
  Any suggestions?
 
 For linebreaks, see nl2br(). In respect of
 formatting, you would only 
 expect html tags to be rendered by a browser - if
 you mean some other kind 
 of formatting, perhaps you could provide further
 information.
 
 -- 
 David Robley
 Temporary Kiwi!
 
 Quod subigo farinam
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


__
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php