Help with a PHP exercise

Hello, I need help with a exercise for my PHP class. I have pretty much everything figured out, but the numbers aren’t showing how up how I want it to and I don’t know what I’m doing wrong. My teacher wants my exercise to be like:

this is the html:

HTML code:
and this is how the php is showing up:

and this is my code:

1 Like

Your question is incomplete without the HTML code from your input form (since you’re using the $_POST array), and it’s unclear what your goal is as well. What are you supposed to be doing?

1 Like

Heres what I’m supposed to do:

Heres the HTML code:

Name attributes on input tags are best kept to one word wherever possible, or if you absolutely need to use more than one word, you should use underscores between them, not spaces.

Also, the HTML name attribute is what gets passed to the $_POST array. It’s unclear why you have $_POST['pet1'] in your code.

From your PHP code, it doesn’t seem like you completely understand how HTML forms interact with the $_POST array in PHP, which is beyond the scope of providing a simple hint. If you’re taking this as a class with a teacher, I’d recommend asking your teacher.

Also, you can post your code directly on the forum. The screenshots aren’t necessary.

1 Like