Jump to content
MakeWebGames

$counter++?


boionfire81

Recommended Posts

By using ++$counter, you'll be incrementing the value, then returning the variable.

By using $counter++, you'll be returning the variable, then incrementing it.

To output the counter, simply do the following in your while() loop.

echo $counter++;

 

But I also need to echo that exact same count 4 times during the loop template.

Unsure what you mean. You need to output the current value of $counter 4 times (ie: 2 2 2 2) or output $counter (irregardless of its value) 4 times during the loop? If you need to output the value of the $counter 4 times (keeping the current value), use a temporary variable in your while loop.

 

while() {
 echo $current = $counter++;
 echo $current . PHP_EOL . $current . PHP_EOL . $current . PHP_EOL . $current; //$current will be a static value until the next iteration
}

https://eval.in/636992 (notice the output starts at 0 and we are using $counter++)

https://eval.in/636993 (notice the output starts at 1 and we are using ++$counter)

https://eval.in/636995 (using a temporary variable to hold the $counter value)

Link to comment
Share on other sites

Well, I tried sniko's. This is basically an hof layout. Each player having a player card with a 3 layer accordion. The accordian id needs to be unique to each player AND the accordion level needs to be unique to itself.

i.e.

<label id='accordion-1'>
<span name='acc-1-1'></span>
<span name='acc-1-2'></span>
<span name='acc-1-3'></span>

NEXT

<label id='accordion-2'>
<span name='acc-2-4'></span>
<span name='acc-2-5'></span>
<span name='acc-2-6'></span>

 

Link to comment
Share on other sites

So just use echo $counter; ?

I don't see what the problem is.

Look it's simple.

 

$counter = 0;
while(each hall of fame){
  echo "<label id='accordion-".$counter."'>";
  $counter++;
}

 

This is basic php?

Have you been using tutorials yet or still running here for every problem you face?

Link to comment
Share on other sites

So just use echo $counter; ?

I don't see what the problem is.

Look it's simple.

$counter = 0;
while(each hall of fame){
echo "<label id='accordion-".$counter."'>";
$counter++;
}

This is basic php?

Have you been using tutorials yet or still running here for every problem you face?

I literally only come to MWG now to see if you've posted and laugh at it. Your post on "session errors" the other day was pure golden and looked like you'd copied parts of the text from Stackeroverflow, merged them with your answers and called it a day. IIRC, 25% of it failed a plagiarism check.

Anyhow, I know I'm not the nicest person to ever cross this forum, but at least I help properly when I do post. You didn't even give an adequate answer to OP's question. "The accordian id needs to be unique to each player"

You keep referencing how some of OP's questions are "basic PHP", lets be real, you've done it in a few of his threads. I think you've found someone worse than you at programming and now seek to appear superior, which is fine, but I wish you'd stop making out like you're a supreme overlord when your Github account is public. Remember when you got upset when I joined the forums, and you messaged me asking me what my problem is with you, etc etc? This is the same thing. It honestly doesn't bother me but i just had to comment because you try really hard to act like you know what you're talking about.

I mean, come on man. A "Pageloader"?

Link to comment
Share on other sites

 

I literally only come to MWG now to see if you've posted and laugh at it. Your post on "session errors" the other day was pure golden and looked like you'd copied parts of the text from Stackeroverflow, merged them with your answers and called it a day. IIRC, 25% of it failed a plagiarism check.

Anyhow, I know I'm not the nicest person to ever cross this forum, but at least I help properly when I do post. You didn't even give an adequate answer to OP's question. "The accordian id needs to be unique to each player"

You keep referencing how some of OP's questions are "basic PHP", lets be real, you've done it in a few of his threads. I think you've found someone worse than you at programming and now seek to appear superior, which is fine, but I wish you'd stop making out like you're a supreme overlord when your Github account is public. Remember when you got upset when I joined the forums, and you messaged me asking me what my problem is with you, etc etc? This is the same thing. It honestly doesn't bother me but i just had to comment because you try really hard to act like you know what you're talking about.

I mean, come on man. A "Pageloader"?

See this is where you are wrong.

I'm not tryin g to come across superior. I'm trying to judge his level of knowledge. I'm trying to find out what he knows about php. Where his knowledge is and what topics he's covered. From there he can be directed to more specific help around the topic.

From what I read I thought the OP wanted to know how to output the $counter variable, which is what I showed.

As for the session error post. Kudos to me then if 25% is apparently plagarised, because it means at least 25% of what I typed is correct. Yay.

The page loader? GG on taking that out of context. Howard Ortan, myself and [uSER=53425]Magictallguy[/uSER] understand what that's all about. But someone as superior and as much of a genuis as you had no use for such a thing. You stick to your Laravel workflow, I'll stick to what I do. Develop, learn and earn money. Sound good? Sweet.

I'm glad my posts entertain you, you should be lucky I'm not charging you for all the laughs you're getting. A ticket to a good comedian is dear enough, you seem to be getting your laughs for free!

Now, let's leave it at that

Link to comment
Share on other sites

See this is where you are wrong.

I'm not tryin g to come across superior. I'm trying to judge his level of knowledge. I'm trying to find out what he knows about php. Where his knowledge is and what topics he's covered. From there he can be directed to more specific help around the topic.

From what I read I thought the OP wanted to know how to output the $counter variable, which is what I showed.

As for the session error post. Kudos to me then if 25% is apparently plagarised, because it means at least 25% of what I typed is correct. Yay.

The page loader? GG on taking that out of context. Howard Ortan, myself and [uSER=53425]Magictallguy[/uSER] understand what that's all about. But someone as superior and as much of a genuis as you had no use for such a thing. You stick to your Laravel workflow, I'll stick to what I do. Develop, learn and earn money. Sound good? Sweet.

I'm glad my posts entertain you, you should be lucky I'm not charging you for all the laughs you're getting. A ticket to a good comedian is dear enough, you seem to be getting your laughs for free!

Now, let's leave it at that

Right, so, you thought OP wanted to know how to output the $counter variable even though he has explicitly said that's not the case? Bringing further credence to the fact you are a "copy and paste coder". You're not judging anything, you are literally at the same level as OP in your learning, you just know how to Google things better, that's it. That is literally it.

My Laravel workflow? What on Earth are you talking about? Now you just sound like you're taking stabs in the dark and hoping you hit something. Laravel is something I use, ever heard of "including but not limited to?", whereas your skillset expands as far as "if it's on Google, I can do it". "Develop, learn and earn money", first off are you implying I don't earn money? Secondly, you don't develop anything, which we have established since you're a copy and paste coder, thirdly, It looks like you haven't learned a single thing in your "claimed" 6 years of experience. I'm surprised anyone pays you. I'd pay you the bare minimum as an apprentice and you'd actually have to go and learn something.

You have EVERY trait of a copy and paste coder so don't piss on my boots and tell me it's raining. You need to stop the big man act and stop pretending like you have a clue what you're doing. Stop trying to appear like you're better than OP and telling him to learn basic PHP when you need to learn it yourself.

Also, fine, if that PageLoader was taken out of context, I admit fault. I will happily pick something else from your Github though, all of it demonstrates your skill as someone that is learning to code. But I assume you've learned loads with the help of Jesus in the past year since the likes of "ChaoticFrame". I love how you've become an expert in 1 year, that's one of, if not the most amusing thing about your facade.

I'll stick to my "Laravel workflow" and being poor whilst you make money and travel the world like a superstar. You clearly do well and are very rich. You go get it, make that money, one can only dream.

  • Like 1
Link to comment
Share on other sites

 

Right, so, you thought OP wanted to know how to output the $counter variable even though he has explicitly said that's not the case? Bringing further credence to the fact you are a "copy and paste coder". You're not judging anything, you are literally at the same level as OP in your learning, you just know how to Google things better, that's it. That is literally it.

My Laravel workflow? What on Earth are you talking about? Now you just sound like you're taking stabs in the dark and hoping you hit something. Laravel is something I use, ever heard of "including but not limited to?", whereas your skillset expands as far as "if it's on Google, I can do it". "Develop, learn and earn money", first off are you implying I don't earn money? Secondly, you don't develop anything, which we have established since you're a copy and paste coder, thirdly, It looks like you haven't learned a single thing in your "claimed" 6 years of experience. I'm surprised anyone pays you. I'd pay you the bare minimum as an apprentice and you'd actually have to go and learn something.

You have EVERY trait of a copy and paste coder so don't piss on my boots and tell me it's raining. You need to stop the big man act and stop pretending like you have a clue what you're doing. Stop trying to appear like you're better than OP and telling him to learn basic PHP when you need to learn it yourself.

Also, fine, if that PageLoader was taken out of context, I admit fault. I will happily pick something else from your Github though, all of it demonstrates your skill as someone that is learning to code. But I assume you've learned loads with the help of Jesus in the past year since the likes of "ChaoticFrame". I love how you've become an expert in 1 year, that's one of, if not the most amusing thing about your facade.

I'll stick to my "Laravel workflow" and being poor whilst you make money and travel the world like a superstar. You clearly do well and are very rich. You go get it, make that money, one can only dream.

Public findings online do not paint a full or accurate picture. As someone who develops for the web I thought you would understand that.

Ever heard the saying don't judge a book by its cover? Well I'm going to change it for this circumstance. Don't judge a person by what you find online.

It's somewhat curious that you picked another php item from my GitHub, which is roughly a year old at this stage. I'm not limited to PHP as much as you are not limited to Laravel. And Laravel was not a stab in the dark. It was down to past conversations we have had about it.

I haven't had an account in GitHub for very long and I haven't used it all that often as can be seen by the number of repos I have. The fact I have things public is so that I could use the code across workstations without needing to manually transfer the files with memory pens or the like. At the time my GitHub account wasn't of the correct type to allow private repos.

I've never claimed to be an expert and I'll gladly admit that I am still learning to program. Aren't all developers? With every new technology, language, framework, version, we have to learn how it works and how to use it.

Does that make me a "copy and paste coder"? No.

I can take the skills I have learned from one language and transfer it to another. I have enough confidence in my ability, as does others and more importantly as does people who are willing to invest in my education. I do not need your approval nor do I need your respect.

I'll say it again. I wasn't trying to appear superior to the OP, I know he is learning, I was trying to gauge where he is at with PHP so that I could maybe attempt to give him more attuned help or if you don't like the thought of me helping him, find articles that will help him.

I am at fault for not reading OP's question correctly which is where the heart of this problem lies. You've just managed to take advantage of it to ridicule me publicly. If that makes you sleep better at night then continue to do so.

But if you do it, move it to another thread please? Instead of clogging up this thread with unrelated posts regarding the OP's question.

Why use MWG as a place to slander others? I know your own web development forum flopped but this isn't the place for it. In reality there is no place for it. There needs to be less negatively and more positive posts here. If you have a problem with me or someone else, take it to Private Messaging, not somewhere that it's public for others to see. You can't know the hurt that it could do.

If there is any way I can prove I'm not a copy and paste coder, I'll gladly accept the challenge. But if you want to continue to make unfound claims go ahead. You're doing me no harm.

Perhaps my public profile on this forum yes, perhaps my reputation will take a hit. But anyone that I've done work for has been more than satisfied so I personally will not take any offence and you will not be hindering me or my learning in any way.

I hope you have a wonderful weekend.

P.s not implying you don't earn money, just stating that I do.

P.p.s nothing I have said is trying to imply anything against you.

[uSER=53425]Magictallguy[/uSER] I wasn't bringing you into it, just referencing you. I apologise if it seemed like I was.

Link to comment
Share on other sites

Not even going to read that because I can tell by the first sentence you're going to try and justify how bad you are.

Look, how about this; you stop inflicting your poorly constructed criticism, spliced explanations and shitty code on people you think you're better than and I'll stop commenting about you and causing you to create a thread crying about it, looking for sympathy?

If you feel there is something important in your above text, please give me a tl;dr and I'll comment on it.

Link to comment
Share on other sites

[MENTION=71663]IllegalPigeon[/MENTION] tl;dr I am still learning. All developers should be. My GitHub is full of things I did to help me learn. PHP is not the only language I'm limited to. Be careful how you criticise others. Some may or may not take it as lightly and could do something irrational. I feel I need to prove I'm not a "copy and paste coder" so what sort of challenge do I need to complete to satisfy you. Can you too prove you are not a copy and paste coder?

Link to comment
Share on other sites

Sure, If you want to prove you're not a copy and paste coder, come and sit down in front of me and code whatever I tell you to code. I don't need to prove my skill, that's the difference. I've actually written stuff that is in use today by big sites and small sites. I own a business that does very well, I don't have to prove anything to anyone. If you want me to prove it, pay my rate of £100 an hour and I'll do whatever you want. Until then, I don't give a flying f*ck.

You feel you need to prove yourself because you want so badly to be acknowledged, liked and prove you have some sort of skill. Fine, I admit, you have the skill of an apprentice and someone just starting out. You're slightly more than your average McCode developer.

And finally, be careful who I criticise? Lol. Do you honestly think I'm scared of criticising anyone? I've had people ring up my place of employment (when I was employed) and threaten to come down and meet me in person to settle an online dispute. To which I say "ok". I will share my opinion to anyone, the worst that can happen is someone DDoS's one of my sites...Oooooh no.

Give it a rest, boy. Go and seek your grandeur elsewhere.

Link to comment
Share on other sites

<?php
$cnt = 0;
//assuming we have results..
while($row = $db->fetch_row($select)) {
   ++$cnt;
   echo '<label id="accordion-'.$cnt.'">';
   for($i = 1; $i <= 3; ++$i)
       echo '<span name="acc-'.$cnt.'-'.$i.'"></span>';
   echo '</label>';
}

Not the cleanest method, but should achieve the desired effect, if I understand correctly

Edited by Magictallguy
Link to comment
Share on other sites

<?php
$cnt = 0;
//assuming we have results..
while($row = $db->fetch_row($select)) {
   ++$cnt;
   echo '<label id="accordion-'.$cnt.'">';
   for($i = 1; $i <= 3; ++$i)
       echo '<span name="acc-'.$cnt.'-'.$i.'"></span>';
   echo '</label>';
}

Not the cleanest method, but should achieve the desired effect, if I understand correctly

It may not work depending how he retrieves the data from the database. I do think he'll need two loops, but I have a feeling he might need two database queries, depending how his database is set up.

Link to comment
Share on other sites

I think you're actually a bigger ass than me...

I like it, keep up the good work - especially where E Coli is involved.

Thanks, man. It's about time I got some recognition around here. I made a thread on other forums looking for people to tell me how great I am, but alas, I am just an ass and not someone pointing out a clear indictment of the educational system here in the UK when I see it.

Also, E Coli

 

https://www.youtube.com/watch?v=LHhth9CmbJ8

  • Like 2
Link to comment
Share on other sites

Thanks, man. It's about time I got some recognition around here.

I read that "thread" with some interest;

Interest in Alain passing judgement on "Many if not most there don't do anything beside talk" - We could do far worse, we could have created NWE, which I named No Way Engine because there is no way I would use that crap. PHP Certification and that's your best work? Less smack talk and more studying, please.

Then to say most don't know PHP and if they do, it's McCode PHP - Again, could be worse - could be an NWE developer.

Also, Interest in E Coli needing verification from others of his 1337 skillz and amazing pers0nality.

Also interested in who "There's at least 3, and they seem to have taken an interest in me." would be.

Since both you and I have made no secret that we think E Coli is a slight bell, I question who the 3rd is.

Back Story - Since E Coli seems to think we dislike him for "unknown reasons"

I was working on a game, which I won't mention the name of, and modified every query call to use a single, lightweight class.

I then decide I'm done working there and go MIA for a few months. During this time E Coli gets the task of changing some things. I re-appear on the web and they ask me to fix some stuff he had wrote.

No problem right? Wrong.

Not only was his code broken, he couldn't be bothered to load up the class to see what it does. I left the site with every query running via $db->execute($sql) and come back to that and ...

 

$db2 = mysql_connect ....

​Yeah, screw you and your attention seeking shizzle,

  • Like 1
Link to comment
Share on other sites

Yeah, I was tempted to sign up to GMF and comment but I didn't want to ruin the circlejerk. I'm perfectly okay with receiving hate for giving my opinion and having someone write indirect threads about me, comparing me to the devil. As long as they got the attention they wanted and comments from a group of enablers comparing the OP to Jesus.

The reference to the headcount, because THAT'S the most import part (oooooh, 3 people don't like me), was in a PM. I just mentioned that it's not just me that thinks these things because at least 2 other people have messaged me and said "looool, have you seen this cancer?" and linked me to certain threads. I just wanted to backup my point that it wasn't a personal attack, other people think it too.

I've been a PHP developer for about 10 years now. I was here when MWG was CE, with mdshare, Rainbow, Nyna and all of the others. I haven't touched McCodes in so long I can't even remember how bad it is, I just come here for entertainment. Alain has his little following because he's been around persistently for so long and knows how to make himself sound smart whilst not being smart.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...