EDITION: Forsyth County
FAQs PLACE A CLASSIFIED AD ADVERTISE YOUR BUSINESS
81 °
Fair
Registered Users, Log In Here
Anyone know php?

BlueRidgeGuy

Posted 1:02 am, 02/08/2011

Oops, kinda.

"**** will never change as its value was set outside of the loop."

Right now **** = Tuesday.

BlueRidgeGuy

Posted 12:57 am, 02/08/2011

****=****[weekday];

echo **** . "<br/>";

**** will never change as its value was set outside of the loop.

mtncruizer

Posted 9:44 pm, 02/07/2011

I've hit a snag on this project. I'm not sure I have it constructed correctly. When I display the file in the browser, Monday (or whatever day it happens to be) is in front of all the items and prices. What is supposed to happen is the day of the week should display along with the 'special' for that day.

Any suggestions would be appreciated.

Here's my code;

//variables
**** = "Assignment 5";
****=getdate();
****=****[weekday];


echo "<html>
<head>
<title>
****
</title>
</head>
<body>
<h1>
Special of the Day
</h1>\n";

**** = array(
"Sunday" =>"52in Flat Screen TV:425.00",
"Monday" =>"Amplifier:145.00",
"Tuesday" =>"HP Computer:355.00",
"Wednesday" =>"500GB External Harddrive:99.00",
"Thursday" =>"Internal Speakers:55.00",
"Friday" =>"Ergonomic Keyboard:85.00",
"Saturday" =>"Wacom Tablet:175.00",
);
foreach (**** as **** => ****)
{
//using list to explode product and price
list(****, ****) = explode(':',****);

echo **** . "<br/>";
echo **** . "<br/>";
echo **** . "<br/>";
echo "----<br/>";
}


echo " </body>
</html>";
?>

mtncruizer

Posted 9:46 pm, 02/04/2011

PHP is hard. It's causing me to think too much. I'm working on another project using an associative array. I think I'm getting close..at least I hope I am....

mtncruizer

Posted 10:41 pm, 01/29/2011

Are you sure you haven't taken this class before? Just asking.

mtncruizer

Posted 10:37 pm, 01/29/2011

You are the MAN, wilkesman2!!!

Thank you for your help. I feel a little better now since this assignment is due Tuesday.

wilkesman2

Posted 10:31 pm, 01/29/2011

Cool, glad you got it fixed.
i would more the " // to another line and maybe even split it like this

// Radius is set to half the given number if the type is diameter,
// or unchanged if radius

**** = (**** == "diameter") ? ****/2 : ****;

I tend to put it before the code with a black line above it so that it is clear what the comment goes to.

mtncruizer

Posted 10:15 pm, 01/29/2011

Hey, Wilkesman2! I made this change: echo circleArea(2); and now it calculates!

I'm still over on that line, though, but I don't know what to do about it.

I'll probably be posting more and begging for help. Thanks for taking the time and lending your expertise! I certainly do appreciate it!!

mtncruizer

Posted 9:58 pm, 01/29/2011

How did you know about the three point deduction for being over 80 lines? Have you had this class before? The last assignment I turned in, I was over and had three points deducted. How do you suggest I fix the problem?

Thanks for your help. I really appreciate it. I'm really struggling with this. I'm never been so lost in a class before. I think if what was in the textbook was what our assignments were based on, it wouldn't be that hard to understand. Last semester, I did very well in html/xhtml. This php is a different animal!

wilkesman2

Posted 9:25 pm, 01/29/2011

this is going to give you a problem
&& !empty(****)
Because **** has no value declared before using it
You are over 80 letters per line and that will cost you 3 points on your grade.

mtncruizer

Posted 6:14 pm, 01/29/2011

Hey wilkesman2. Thanks for the help. I'd like to say that fixed the problem, but it's still only returning -1. I must have the if-else wrong.

Thanks for your help, though.

wilkesman2

Posted 3:23 pm, 01/29/2011

you are needing a **** = 3.141592654; as one of your variables above the **** = (**** * ****);

mtncruizer

Posted 9:40 pm, 01/28/2011

I think I've almost got this but.... it only returns -1 and not the circle area. There are no syntax errors when I check it in Putty so I must have something out of place or not defined somewhere.

Here's my code if anyone can help. Sure hope it's alright to paste code here. If not, sorry Jason. I'll do better next time.

<?php

//variables
**** = "Area of Circle";
**** = 2;
**** = (**** * ****);
**** = "Circle";

echo "<html>
<head>
<title>
****
</title>
</head>
<body>
<h1>
Calculate the area of a circle
</h1>\n";
echo circleArea();

function circleArea(****, ****="radius")
{
if(is_numeric(****) && is_string(****) && !empty(****) && !empty(****))
{
**** = (**** == "diameter") ? ****/2 : ****; // Radius is set to half the given number if the type is diameter, or unchanged if radius
**** = pi()*pow(****,2); // Pi as defined by php multiplied by radius to the power of 2 (squared)
return ****; // Return result
}
else
return -1; // Return -1 when invalid/empty values are given
}
?>

mtncruizer

Posted 5:59 pm, 01/28/2011

Thanks for responding, GoWilkes. I'm only in Wilkes Mondays and Wednesdays and am tied up the whole day with classes. I have classes at another campus on the other days. That's sort of why I was trying to find help on a forum. I work on this a lot, especially on the weekends, and think I just need a nudge to help me wrap my brain around it. I'm having problems figuring out where I need to put things to make them all work together.

Is it okay to post code here? Do I need to use [code] and [/code]?

Thanks again!!

GoWilkes

Posted 1:44 pm, 01/28/2011

I do a lot of coding in PHP, but wouldn't have time to tutor. If you have simple questions, you can post them here, and I (or someone else) can usually point you in the right direction.

If you need an in-person tutor, have you considered asking your professor? If this is at WCC, then a lot of the professors used to tutor on the side.

mtncruizer

Posted 12:07 am, 01/28/2011

Do I hear crickets?

Can anyone help me learn php?

Anyone?

I'm usually a quick study. Just need a little nudge.

Thanks.

mtncruizer

Posted 11:01 pm, 01/26/2011

I'm taking an advanced web scripting class and need help with php. If anyone knows how to write php code, I'd be willing to pay for your services. I made a high 'A' in my html, xhtml class laster semester but php is a different animal.

I'm a little stressed about this class because, if I don't pass it, I don't graduate in May. I HAVE to graduate in May!

Any help and/or suggestions are truly appreciated.

Your Reply

Your Username:

Your Password:


 
Add Reply
Cancel
Dreaming of Italy?
Win a dream trip to Italy! Glide through Venice, sip wine in Tuscany, or explore ancient Rome, experience the magic of Italy. Enter by 7/13/25 for your chance to win a Globus Italian tour for 2!