Jump to content

List numbers up to an assigned value.


elmas156
Go to solution Solved by Jessica,

Recommended Posts

OK, I know the topic title doesn't say much, but what I'm trying to do is fairly simple to explain.  What I'm trying to do is to have real time inventory of specific items that are listed in my database.  For simplicity, I'll just say that I have a two mysql query results that are identified in variables $total, and $used.  By subtracting $used from $total, I get the number of items still available ($available).  What I need to do is create a dropdown box that has numbers listed up to whatever amount is available. 

 

For example, if $available = 4, I need a dropdown box that has options 1,2,3, and 4. 

 

Any ideas on how to do this or what I should search for?  I have found nothing so far.  Thanks in advance for your help.

Link to comment
Share on other sites

Thank you for your help, I really appreciate the time that you and others take to help people who are learning the basics of php.  I'm a little confused though, because you ask "Really?" as if this is a problem that one shouldn't have, or that even the newest of newbies should know. 

Link to comment
Share on other sites

I'm a little confused though, because you ask "Really?" as if this is a problem that one shouldn't have, or that even the newest of newbies should know. 

 

 

I think she was referring to the latter. Not so much the "newest of newbies", but someone who knows at least the very basics of loop structures. I think you would have gotten a little more sympathy if you had shown at least an attempt.

Link to comment
Share on other sites

I didn't say that I was a newbie, nor did I ask for anyone to do the work for me.  If you look back to my original post, my question is this: "Any ideas on how to do this or what I should search for?"

 

I have been dabling in php for a couple of years now, but I haven't been through any formal classes or anything of the sort.  When I have a specific task that I would like to accomplish, I search google and online forums to figure out how to accomplish that task.  Up until now, I haven't had the need to use a for loop to accomplish anything of this nature, and I don't have knowledge of "the very basics of loop structures," nor did I know exactly what to search for to find the answer that I needed.  In this case, I searched for "php list numbers chronologicaly up to a specific value" and "php list numbers up to an assigned value."  With these searches, I came up with no results that pointed me in the direction that I needed.  However, had someone simply answered, "this can be accomplished using a for loop," I would have likely searched "php for loops," and found the result that leads to this page: http://www.w3schools.com/php/php_looping_for.asp, which is exactly what I was looking for.

 

Jessica, I seriously do appreciate your help and your obvious extensive knowledge that you are willing to share with people who ask for help.  I'm just saying that because someone posts a question that is trivial in your opinion, and they haven't shown any code that they've already tried, it doesn't mean that they haven't tried at all.  In order to find something using a search engine or forums, you need to have some knowledge of what you're searching for.  Sure, if you search "bag that a woman carries on her shoulder," you're going to get results for "shoulder bags" and "purses," but that's not always how it works for coding.  Again, thank you for your help, but assuming that someone hasn't tried anything because the anwer is simple to you, only causes that person to be discouraged, and makes you look like a jerk, which, judging by your willingness to help others, I'm sure you are not.  Thanks.

Link to comment
Share on other sites

Thank you for the advice, I will find a tutorial on loops and go through it for future reference.  I have used while loops, but only in basic form, but that is the extent of my experience with any sort of loop.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.