Jump to content

joshspaulding

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by joshspaulding

  1. Thanks for the replies. Maybe "newbie" is the wrong word. I've already started learning basic PHP. I know HTML, I understand how everything works together (html, php, mysql etc.) Right now I'm looking for more specific guidance on the dynamic pages that contain the rags, but do not contain any php... I've been "around" code for about 8 years. I can't provide the code because this particular web app shared with a partner and he wouldn't want any code in public. He's a coder ... a very busy one ... and I'm just trying to learn things here and there on the side. So basically we have several pages in a /templates/ directory like the root (index.html) login.html learn-more.html etc. etc. Each of them use tags like [menu] (for the top nav menu) [title] in the heading etc. I can modify index.html from within the templates folder and when I upload the changes I can see the changes live at the root of the site, but when I modify learn-more.html (for example) it doesn't change the dynamic page ?action=learnmore ... is this simply an issue of finding the correct directory on the server? yeah, I'm not trying to get into that yet. Althogh I've been toying with WordPress here and there for about 8 years.
  2. I'm a pretty raw newbie with PHP, but I've been around html and code for about 8 years, so a little more knowledgeable than the average newbie. Just for a little background. Right now I'm looking into dynamic php pages and I believe I have a high level understanding of how it works in regards to "splicing" up a page into a header, content and footer and then displaying the page. Seems pretty simple. But I have a site that does this a little differently. It uses [menu] [title] etc. tags within the html pages and the html pages do not include any php at all... they are in a /templates/ directory though. Can someone give me a quick explanation of how that works? You don't have to get incredibility detailed unless you want to... really just looking for someone to point me in the right direction. Thanks!!
  3. hmm ok. Is there another html option that is respected by all browsers? Or, a PHP option? The option you mentioned seemed to just echo a statement on the results page.?
  4. This displays the echo on the results page. Do you know how I could make a "required" pop up window display on submit if one of the questions isn't answered?
  5. Jessica - I actually agree with doing your own research. Doctors also recommend vaccines and crazy amounts of antibiotics when they aren't needed, which often times does more harm than good. But the fact is, we are in a PHP forum Not a health discussion forum. The script I referenced above, as I said, is for our own use and really it's not even for our own use... it's just something I threw together for a little practice. This is why it's usually not a good idea to assume things Lets stick to PHP, since we're in a PHP forum. Then we won't have to waste our time with pointless arguments.
  6. No offense, but I think I'll get my health advice from doctors and my php advice from here Have a good one.
  7. P.S. Although this is 100% off-topic and probably shouldn't even be discussed here and since you seem to be so concerned with what I'm doing: The metrics come from our Pediatrician (what is your medical degree by the way?) who advised us that our son (not yours, or anyone else's) should be getting about 2x's to 2.5x's his body weight in pounds for the first 6 months of his life. Thank you for being so concerned though and I wish you the best of luck with your medical career.
  8. lol This is not a tool that I'm releasing to the public and I'm not looking for medical advice, only PHP advice
  9. I got it. Wrapped round() around the operators and then added ,2 because after I added them it rounded to a whole number, whereas I need it to be a fraction, just not that long of a fraction. Thanks again everyone!
  10. Thanks guys!! Sorry for the newbness lol but how would I implement that in this code? $minoz = $_POST['weight']; $outcomeMin = $minoz * 2; $outcomeMax = $minoz * 2.5; $outcomeHourlymin = $outcomeMin / 24; $outcomeHourlymax = $outcomeMax / 24; echo "Your baby needs from $outcomeMin oz. to $outcomeMax oz. of breastmilk per day or $outcomeHourlymin oz. to $outcomeHourlymax oz. per hour."
  11. Another basic one for you. I just created a little script that asks the user for the current weight of their baby and when submitted it tells them how much breastmilk their baby needs per hour and per day. But the per hour numbers look like this (for example) 0.916666666667 How can I make it look like this: 0.9 ? Thanks!!
  12. Thanks for the reply. ok, so the benefit of get is in it's ability to bypass hidden fields. Is that THE benefit or only one of many examples?
  13. I have a super newbie question for you guys today. I'm almost done with a PHP tutorial and for the most part I understand very basic PHP. In some cases the confusion isn't in how something works or how it's accomplished that is challenging to me, but why and/or when it is used. Like get and post with forms. I understand how they both work for the most part, but I don't understand why you would ever use get instead of post. They accomplish the same thing, correct? From my understanding, the only difference is that get appends the variables to the URL, whereas post hides the variables. But both options accomplish the same thing. Or is my understanding wrong? If I'm right, then why would you ever need to use get?
  14. ok that makes sense. Adding it now. Thanks again!! I really appreciate your time and help.
  15. AHHH I had the array keys wrong! It does work, thanks alot!! You too PFMaBiSmAd! I see you added the following and i see it works with the submit input name. But it also works if I leave that line out and leave the input name out. What's the purpose of that code and the submit input name? Alrighty, I'll start looking into that now! Thanks again!!
  16. That was my next question. Ok, I have that fixed, but now I keep getting the else statement again. I'm reading and looking into mrMarcus's last reply now.
  17. Breakthrough!! lol I got the answer to question one! But it's not showing the answer to the last two questions. NEWEST CODE <form name="questions" action="results.php" method="post"> <h4>1. Are you pro-life (against abortion) or pro-choice (for abortion)?</h4> <input type="radio" name="q1a" value="q1a"/> : I am pro-life<br /> <input type="radio" name="q1b" value="q1b"/> : I am pro-choice <h4>2. Do you believe that gun rights are necessary to preserve safety, freedom and to protect us from tyranny, or do you believe unarmed citizens are safer citizens?</h4> <input type="radio" name="q2a" value="q2a"/> : I support gun rights<br /> <input type="radio" name="q2b" value="q2b"/> : I believe citizens should be unarmed <h4>3. Do you believe in free markets (limited regulation on business) or do you believe the government should regulate business' to any extent necessary?</h4> <input type="radio" name="q3a" value="q3a"/> : I support free markets<br /> <input type="radio" name="q3b" value="q3b"/> : I support regulating to any extent necessary<br /> <br /> <input type="submit" value="Tell me if I'm a Republican or Democrat!" /> </form> <?php $qone = $_POST['q1a']; $qtwo = $_POST['q2a']; $qthree = $_POST['q3a']; if ($qone == "q1a"){ echo "Your answer to question 1 is: I am pro-life. This is a republican/conservative view.<br />"; }elseif ($qone == "q1b"){ echo "Your answer to question 1 is: I am pro-choice. This is a democrat/liberal view.<br />"; }elseif($qtwo == "q2a"){ echo "Your answer to question 2 is: I support gun rights. This is a republican/conservative view.<br />"; }elseif ($qtwo == "q2b"){ echo "Your answer to question 2 is: I believe citizens should be unarmed. This is a democrat/liberal view.<br />"; }elseif ($qthree == "q3a"){ echo "Your answer to question 3 is: I support free markets. This is a republican/conservative view.<br />"; }elseif ($qthree == "q3b"){ echo "Your answer to question 3 is: I support regulating to any extent necessary. This is a democrat/liberal view.<br />"; } else { echo "Well crap. If you're seeing this then I screwed up the code and it's not finding the answer variables. I'm thinking I need to learn more about arrays... need to figure out how to make results.php understand the difference between the two answers for each question. I think this is done by setting values for each answer in index.php then using arrays to 'convert' them over so they can be translated into the results.php page..?.."; } ?>
  18. I know this is extremely basic stuff, so i appreciate you taking the time to help! I didn't paste the code again because I've changed it about 10 times and keep trying new things... unsuccessfully Obviously. Here is the latest. <form name="questions" action="results.php" method="post"> <h4>1. Are you pro-life (against abortion) or pro-choice (for abortion)?</h4> <input type="radio" name="q1a" /> : I am pro-life<br /> <input type="radio" name="q1b" /> : I am pro-choice <h4>2. Do you believe that gun rights are necessary to preserve safety, freedom and to protect us from tyranny, or do you believe unarmed citizens are safer citizens?</h4> <input type="radio" name="q2a" /> : I support gun rights<br /> <input type="radio" name="q2b" /> : I believe citizens should be unarmed <h4>3. Do you believe in free markets (limited regulation on business) or do you believe the government should regulate business' to any extent necessary?</h4> <input type="radio" name="q3a" /> : I support free markets<br /> <input type="radio" name="q3b" /> : I support regulating to any extent necessary<br /> <br /> <input type="submit" value="Tell me if I'm a Republican or Democrat!" /> </form> <?php $qone = $_POST['q1a']; $qtwo = $_POST['q2a']; $qthree = $_POST['q3a']; if ($qone == "q1a1"){ echo "Your answer to question 1 is: I am pro-life. This is a republican/conservative view.<br />"; }elseif ($qone == "q1a2"){ echo "Your answer to question 1 is: I am pro-choice. This is a democrat/liberal view.<br />"; }elseif($qtwo == "q2a1"){ echo "Your answer to question 2 is: I support gun rights. This is a republican/conservative view.<br />"; }elseif ($qtwo == "q2a2"){ echo "Your answer to question 2 is: I believe citizens should be unarmed. This is a democrat/liberal view.<br />"; }elseif ($qthree == "q3a1"){ echo "Your answer to question 3 is: I support free markets. This is a republican/conservative view.<br />"; }elseif ($qthree == "q3a2"){ echo "Your answer to question 3 is: I support regulating to any extent necessary. This is a democrat/liberal view.<br />"; } else { echo "Well crap. If you're seeing this then I screwed up the code and it's not finding the answer variables. I'm thinking I need to learn more about arrays... need to figure out how to make results.php understand the difference between the two answers for each question. I think this is done by setting values for each answer in index.php then using arrays to 'convert' them over so they can be translated into the results.php page..?.."; } ?>
  19. I'm learning the very basics of PHP. I understand how html forms work, I understand what else, elseif, switch statements are and I understand variables and arrays. I should say I understand what they are. What I'm TRYING to understand is how the html file and php file communicate with one another. I know that you tell the html form where the php file is with the form action and that communicates the form data to the php file. But when I try to create a working example, using simple questions that have two answer options using radio buttons, I can't figure out how to echo the user's answer to the questions over to the php output file. So I think my confusion is in the actual communication between the html form file and the php file. And I'm trying to accomplish this in the SIMPLEST way possible. Right now I'm just learning the BASICS of PHP, so I'm not worried about creating the absolute best and most efficient code... just trying to make it functional. Does anyone know of a basic tutorial or article that might explain this? Or maybe you could explain in in a reply if it doesn't require much time? If so I would REALLY appreciate it! Thanks!
  20. Instead of using if and elseifs maybe I should use a switch statement with cases for each answer? Or is that not the problem at all?
  21. ahh ok. I inserted values in the html form, thinking that it would pull them. It's still not working for me though. Is my logic completely off?
  22. ok I'll have to look into that. I've been using dreamweaver for 8 years. Actually, I think I can setup Dreamweaver to do that... just have to research that documentation. Thanks for the suggestion! Thank you very much! I'll definitely look into that, but I think for the time being it's too advanced. I'm still learning the very basics... I feel pretty comfortable with the basics that I've learned so far, but I haven't even learned about setting up MySQL databases and calling them etc. so I've got to learn the rest of the basics before I can even start to wrap my head around data driven designs I think. From an operational standpoint, ignoring the fact that the code could be much more efficient is my code above just totally wrong? Am I way off base or is there just one or two simple things I'm doing that that I could easily fix? I'm just trying to learn from my mistakes. Thanks again!
  23. P.S. Not trying to to start any form of political discussion The site is only for testing purposes and even if I do promote it in the future it's strictly bi-partisan!
×
×
  • 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.