PHP - Mlm Demo Structure
Hey guys ;-)
I got a client that asked me today to create him an MLM type website. The first part of my work would be to test if there system works so I need to run a full demo of the multilevel structure. The MLM structure works as follow: 1 person finds 2 members and they then find 2 more each and so on until we reach 100 level deep. If i got this right, At level 5 there will be 25 members At level 10 there will be 100 members At level 20 there will be 400 members At level 40 there will be 1.600 members At level 100 there will be 10.000 members So at the end of the demo there should be 10k members inserted into the table The table looks like this: id, parent, level, under Parent is the ID of the guy that recruited him, level is the level that guy is at (level 1, 2 , 3, 4 or 5) and under is the number of people under him. I need to run a script that will insert all the data into that table so that we can run some test on the liability of the project so we can set the rates right. At first I thought it would be a piece of cake ... but when I started I found out very fast that populating the MLM network 5 level deep is gona be tricky ... my first attempt gave me a result that looks like this: Code: [Select] |0| |1|2| |x|x|3|4| x|x|x|x|x|x|5|6| As you can see the script only grab the last id then adds 2 new members then uses the last one as the parent and starts over ... So my script is useless and I did not figer out how to do everything in 1 step ... Any help would be appreciated. Similar TutorialsWhen having different levels of directories, using relative paths will not work anymore, for example: controller - authentication File 1: include('../../model/header.php') model File 2: header.php view File 3. style.css The header.php file includes the css file with a relative path, but the problem is it includes it as follows: ../view/style.css When now the header.php file gets included into File 1 in the folder "authentication", then the css file will not be accessible anymore, for it to be accessible you would have to go two directories up. In this sense my question is, what would be the proper path structure for a folder structure with multiple levels? Should I rather use absolute paths, I am not so prone of absolute path. What if the folders changes a bit, or the domain changes, or the location changes? Hi there, I am working on a PHP Ecommerce website. We have multiple Suppliers on the website listing their products. Now when a customer buys multiple products belonging to multiple suppliers, the payment has to go to those different respective suppliers through a single Paypal checkout. I have come to know that there is a way of doing is using Paypal Parallel payments method. Its he http://feefighters.com/blog/paypal-announces-adaptive-payments-parallel-payments-and-chained-payments-functionality-via-api/ Anybody here has a working demo of how it works. Kindly reply. Thank you! All comments feedback are always welcomed! Hello everyone, Let me start by saying that this is my first post on this forum and that I am quite a noob when it comes to scripting. With that said, here is my problem: I am trying to edit a getID3 demo file properly to retrieve metadata from mp4 files. The code below belongs from the demo file. <?php require_once('../getid3/getid3.php'); $getID3 = new getID3; $DirectoryToScan = '../container'; $dir = opendir($DirectoryToScan); echo '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="3">'; echo '<TR><TH>Filename</TH><TH>Artist</TH><TH>Title</TH><TH>Bitrate</TH><TH>Playtime</TH></TR>'; while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_file($FullFileName)) { set_time_limit(30); $ThisFileInfo = $getID3->analyze($FullFileName); getid3_lib::CopyTagsToComments($ThisFileInfo); echo '<TR>'; echo '<TD>'.$ThisFileInfo['filenamepath'].'</TD>'; echo '<TD>'.(!empty($ThisFileInfo['comments_html']['artist']) ? implode('<BR>', $ThisFileInfo['comments_html']['artist']) : ' ').'</TD>'; echo '<TD>'.(!empty($ThisFileInfo['comments_html']['title']) ? implode('<BR>', $ThisFileInfo['comments_html']['title']) : ' ').'</TD>'; echo '<TD ALIGN="RIGHT">'.(!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ').'</TD>'; echo '<TD ALIGN="RIGHT">'.(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ').'</TD>'; echo '</TR>'; } } ?> I have added 2 test files in 'container' for testing only. See this image for the result I am getting. As you can see the code isn't retrieving any data at all. Can anyone help me out with this? Thanks in advance, Melissa good day, hello dear community! i am currently ironing out a little parser-script. I have some bits - but now i need to have some improved spider-logic. See the target-url http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50 This page has got more than 6000 results! Well how do i get all the results? I tried out several things - but i dont helped. I allways got bad results. See i have good csv-data - but unfortunatley no spider logic... I need some bits to get there! How to get there!? I use the module LWP::simple and i need to have some improved arguments that i can use in order to get all the 6150 records #!/usr/bin/perl use warnings; use strict; use LWP::Simple; use HTML::TableExtract; use Text::CSV; my $html= get 'http://192.68.214.70/km/asps/schulsuche.asp?q=n&a=50'; $html =~ tr/r//d; # strip the carriage returns $html =~ s/ / /g; # expand the spaces my $te = new HTML::TableExtract(); $te->parse($html); my @cols = qw( rownum number name phone type website ); my @fields = qw( rownum number name street postal town phone fax type website ); my $csv = Text::CSV->new({ binary => 1 }); foreach my $ts ($te->table_states) { foreach my $row ($ts->rows) { trim leading/trailing whitespace from base fields s/^s+//, s/\s+$// for @$row; load the fields into the hash using a "hash slice" my %h; @h{@cols} = @$row; derive some fields from base fields, again using a hash slice @h{qw/name street postal town/} = split /n+/, $h{name}; @h{qw/phone fax/} = split /n+/, $h{phone}; trim leading/trailing whitespace from derived fields s/^s+//, s/\s+$// for @h{qw/name street postal town/}; $csv->combine(@h{@fields}); print $csv->string, "\n"; } } Well - with this i have a good csv-output:- but unfortunatley no spider logic. How to add the spider-logic here... !? well i need some help Love to hear from you good evening dear community! Howdy, at the moment i am debugging some lines of code... purpose: i want to process multiple webpages, kind of like a web spider/crawler might. I have some bits - but now i need to have some improved spider-logic. See the target-url http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50 This page has got more than 6000 results! Well how do i get all the results? I use the module LWP::simple and i need to have some improved arguments that i can use in order to get all the 6150 records Attempt: Here are the first 5 page URLs: http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50&s=0 http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50&s=50 http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50&s=100 http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50&s=150 http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50&s=200 We can see that the "s" attribute in the URL starts at 0 for page 1, then increases by 50 for each page there after. We can use this information to create a loop: #!/usr/bin/perl use warnings; use strict; use LWP::Simple; use HTML::TableExtract; use Text::CSV; my @cols = qw( rownum number name phone type website ); my @fields = qw( rownum number name street postal town phone fax type website ); my $i_first = "0"; my $i_last = "6100"; my $i_interval = "50"; for (my $i = $i_first; $i <= $i_last; $i += $i_interval) { my $html = get("http://192.68.214.70/km/asps/schulsuche.asp?q=e&a=50&s=$i"); $html =~ tr/r//d; # strip the carriage returns $html =~ s/ / /g; # expand the spaces my $te = new HTML::TableExtract(); $te->parse($html); my $csv = Text::CSV->new({ binary => 1 }); foreach my $ts ($te->table_states) { foreach my $row ($ts->rows) { #trim leading/trailing whitespace from base fields s/^s+//, s/\s+$// for @$row; #load the fields into the hash using a "hash slice" my %h; @h{@cols} = @$row; #derive some fields from base fields, again using a hash slice @h{qw/name street postal town/} = split /n+/, $h{name}; @h{qw/phone fax/} = split /n+/, $h{phone}; #trim leading/trailing whitespace from derived fields s/^s+//, s/\s+$// for @h{qw/name street postal town/}; $csv->combine(@h{@fields}); print $csv->string, "\n"; } } } i tested the code and get the following results: .- see below - the error message shown in the command line... btw: here the lines 57 and 58: #trim leading/trailing whitespace from derived fields s/^s+//, s/\s+$// for @h{qw/name street postal town/}; what do you think? Sta�e please Ot",,,Telefo,Fax,Schulat,Webseite Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. "lfd. N.",Schul-numme,Schul,"ame Sta�e please Ot",,,Telefo,Fax,Schulat,Webseite Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. "lfd. N.",Schul-numme,Schul,"ame Sta�e please Ot",,,Telefo,Fax,Schulat,Webseite Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. "lfd. N.",Schul-numme,Schul,"ame Sta�e please Ot",,,Telefo,Fax,Schulat,Webseite Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. Use of uninitialized value $_ in substitution (s///) at bavaria_all_guru.pl line 58. "lfd. N.",Schul-numme,Schul,"ame hello dear all, good day dear php-freaks,
i want to rssify content from another website into my wordpress-page: see the source: https://europa.eu/youth/volunteering/project_en well - is it possible to do this? of course - i have to ask bout the permission at the site of source. but the technical site is also interesting :do you think that this is doable!? note: i only am interested in the summary of the data - that is only a little piece of text.
I have multiple forms within one php file. What is the best structure to use? Code: [Select] if (isset($_POST["one"])) { include... } if (isset($_POST["two"])) { include... } if (isset($_POST["three"])) { include... } OR Code: [Select] if (isset($_POST["one"])) { include... } else if (isset($_POST["two"])) { include... } else if (isset($_POST["three"])) { include... } thanks Alright guys.. I need some advice, some recommendations and definitely some help. I've got a submission form for users to upload an image and some basic personal information. The client wanted the information to be divided by the North America (specifically N.A. and not U.S.) and Europe.. so I created a database table with the typical structu a row for the user's name, email, etc. I also added a row labeled "regionid" in which "1" would equal North America and "2" would equal Europe. This "regionid" row would obviously organize the submission by their country. The client specifically wanted to label North America but mentioned only users from the States would probably only submit images, etc. Users could choose if they were submitting a form for US or Europe and "regionid" would be filled by which form was chosen. Recently, the client threw a curveball and now wants Canada as part of the North America submission form. Now, I don't want to add Canada as another option for my "regionid" row because it does belong under North America. However, I need to alter the structure of the database I currently have so that it can now organize if under North America or Europe, and if under North America, if the submission falls under the United States or Canada. I was thinking of adding a drop down menu under the North America form with the options US or Canada. Do you guys have any advice or other directions you would take to solve this problem.. that is, if my situation is even understandable? I found it pretty difficult to explain! Apologies! Hi. I am creating a database where a user can store up to 50 names of their family members. I have two table structures in mind and curious which one is the more efficient structure. ==================================================================================================== TABLE A: userid-firstfamilymemberid-firstfamilymembername-secondfamilymemberid-secondfamilymembername Note:(the columns would repeated until the fiftiethfamilymemberid and fiftiethfamilymembername for a total of 101 columns) TABLE B: userid-familymemberid-familymembername ====================================================================================================== which is more efficient... Table A which would have more columns but less rows or Table B which would have less rows but more columns.. also keep in mind that the fixed amount is 50 family members per a user. Thanks in advance. Hello everyone I want to know why are these functions discouraged because I have a problem ***************** http://mx.php.net/manual/en/function.spliti.php Warning This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. ***************** I have a long list of standard features of some products (90 features 1800 products) which I am integrating in a CMS. I have to elaborate a CREATE, READ and MODIFY section for the products and I was thinking of using check boxes and if statements with 90 columns in my DB for each feature. (I hope there is an easier way to do this) Before I typed in all the features in one column and splited it with the previous functions mentioned, but it doesn't work for the modify section of the CMS. I am trying to learn a method in which I can easily integrate this 90 standard features in the CMS. Does anyone has a good idea? Hello dear friends, Let say we have Code: [Select] $to = "gigi"; then we have link like this Code: [Select] mysite.com/file.php?id=$1 We can change it to new form by add rule at .htaccess codes Code: [Select] RewriteRule -(.*)\.htm file.php?id=$1 So that the link be like this Code: [Select] mysite.com/$to-$id.htm it will works , Now what if i want to make the link like this Code: [Select] mysite.com/$id/$to.htm what will be the .htaccess code in this way ??? thanks Hi all, I am working on php project and willing to use the "everything as a plugin" idea so alot of people can easily contribute. I am wondering how I can make a php page that includes my plugins, without having to hardcode them(as in require_once, ...). And afterwards it should be possible to execute a function on each of the enabled plugins. Especially the "hardcode" part I am not sure on how to fix it. As for executing a function for each plugin (so that will be a Class object), I wonder how I can make an object of each class from an interface and then execute a function without hardcoding the creation of all objects. Any one ideas or experience with something like this? Thanks in advance. I'm currently working on a site that has about 4 separate panels on the page that all use an include to populate. Each include is interacting with the database and I'm thinking that it might congest the databse to have each panel connecting to the same data base and getting data when the page loads. I was wondering if it would be good practice to take all the connections and functions and put them on a 5th include at the top of the page. This way the connections and functions would be available to each include. Is this a good idea? Will it be a problem for the 4 includes to ask the php function list include for data? Is it better to just let each include contain only the code it needs? Also, say I have 20 functions on the php include and one site page only needs to use 1 function. Would the php function include still loop thru and connect to the database for all 20 functions just because it is included or will it only use the bandwidth needed to execute the 1 function it is being asked to use? Hope that's not over confusing. Thanks! Hy I have a question. Do you think that the code structure from php affect the SEO? I mean if the application is made in basic php or OOP. thk Hey guys, I have a bunch of categories and products in a tree format. For several reasons I need to restructure them from the tree format into a flattened format. I have 2 arrays, one full of categories, the other products. Each category and product has an ID, and a reference to it's parent's ID. The top level categories reference to 0. What I need is to have the categories output like thus: Top Level Categories: Category 1 Category 2 Category 1 Sub category 1 Sub category 2 Category 2 Sub category 3 Sub category 4 Sub category 1 Product 1 Product 2 Sub category 2 Product 3 Product 4 Sub category 3 Product 5 Product 6 Sub category 4 Product 7 Product 8 There could be an unlimited number of sub categories within categories before we get to products, so this needs to be done through a function, however I cannot for the life of me think how to do this. Initially I thought about using 2 arrays, a buffer of categories outputted, and a queue of categories to be outputted, but quickly realised that when I go more than 2 layers deep I can't keep track of the queue's properly. Hi all. I'm starting a mini-project with the purpose of creating PHP generated charts. I just had a quick question on the class structure that I should use. My instinct tells me to do it like this: class chart{ function pie(){ } function bar(){ } } Is that a legitimate structure or is there a better way to do this? Hi I am using the Quote fpdf library to generate a PDF. What I'm looking to do, is to possibly 'nest' cells inside another cell. Code: [Select] ============================ | Main Cell | | ============= =========== | | Cell 2 | | Cell 3 | | ============= =========== | | ============================ So you can see I have one, main cell, and inside this I have Cell 2 and Cell 3, which I'd like inside/nested the main cell. Is this possible using the fpdf library? Thanks Im simply having a problem with structuring a directory structure for mkdir Code: [Select] mkdir("saves/".$worldname."/".$playername, 0777); The middle "/" is causing issues, if I take it out I have no problem in creating a folder name saves/worldnameplayername/ just want to add playername as a sub-dir. I have tried every combination I can think of to get it to accept the divider Any help? Hi guys, I am starting out on mvc, I been reading up on it for a bit now.. and I was just wondering if anyone can take a quick look at it and give me some insight on it? maybe some suggestions etc.. I will be using this for a some what medium site when I know that it is good enough to be published. Note that its not done.. in reality I just need to make sure I am heading in the right direction.
Hello,
I have a table like this: CREATE TABLE days ( id INT AUTO_INCREMENT, daya INT, dayb INT, PRIMARY KEY (id) ); INSERT INTO days VALUES (70, 19, 18), (69, 20, 17), (68, 24, 25), (67, 19, 18), (66, 19, 17), (65, 17, 16);
$sql = "SELECT d1.id AS id1, d2.id AS id2, IF((d1.daya-d2.daya)=1,1,0) + IF((d1.daya-d2.dayb)=1,1,0) + IF((d1.dayb-d2.daya)=1,1,0) + IF((d1.dayb-d2.dayb)=1,1,0) AS tcount FROM days AS d1 , days AS d2 WHERE d1.id IS NOT NULL AND d2.id IS NOT NULL AND d1.id > d2.id"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["id1"] . "</td><td>". $row["id2"] . "</td><td>" . $row["tcount"]. "</td></tr>"; } echo "</table>";
Id1 Id2 Count 50 49 1 50 48 0 49 48 0 50 47 1 49 47 1 48 47 0 50 46 1 49 46 1 48 46 0 47 46 1 50 45 1 49 45 1 48 45 0 47 45 1 46 45 1 I need to convert the table into this form: id1 goes down the first column, and id2 is in the first row. How can i do this, please? can you give me some help? thank you! id2 49 48 47 46 45 id1 50 1 0 1 1 1 49 0 1 1 1 48 0 0 0 47 1 1 46 1 45
|