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

mtncruizer

Posted 1:25 pm, 03/22/2011

Note from GoWilkes: a portion of this post was removed that was in response to an earlier off topic post.

I had my script so it would add and delete from my database but have done something to cause my delete script to cancel before executing. I've got to work on that today. Ugh!

mtncruizer

Posted 11:29 pm, 03/05/2011

I wish I had your smarts, BlueRidgeGuy! Thanks for the help, again!

I just looked at our last six assignments...wish I hadn't. We have to build an entire site in php with all the bells and whistles: shopping cart, links, forms, password areas...the works! I'm already stressed out about it.

BlueRidgeGuy

Posted 10:35 pm, 03/05/2011

**** = "#";
**** = substr(****, 0, 1)
if ( **** == **** ) { match condition }

I'll leave it up to you to figure out how to get ****

mtncruizer

Posted 8:51 pm, 03/04/2011

I'm still plugging away at php but I have a question and I can't find it online or in my textbook.

How do you write a script, or is it a function, that will cause a page to ignore files with special starting characters? Do you use fgets()?

Thanks!!!!

mtncruizer

Posted 12:57 pm, 02/17/2011

Thanks for the encouragement, surfer. I'll be glad when I get used to it. I understand the language, somewhat, I just can't seem to put it all together so it'll work.

islesurfer

Posted 7:47 am, 02/17/2011

When you get used to it, it is a lot of fun.

mtncruizer

Posted 10:40 pm, 02/16/2011

I hate php...

mtncruizer

Posted 10:43 am, 02/12/2011

I think the associative array would work. I wasn't sure how I was supposed to go about it and we really weren't given enough direction. Thanks for the EOF thingy. That will save a lot of time and frustration!!

Thank you for taking the time to help me. I see your last post was after 1am!! I'll going to work on incorporating your suggestions into my assignment today and see where I can get with it. If I get stuck again, I'll be back...

Thanks again!

GoWilkes

Posted 1:17 am, 02/12/2011

One other note I should have mentioned regarding the use of EOF...

It will also plug in the \n at the end of each line, where the way you wrote it would require a manual \n. Which really doesn't matter unless you're viewing the source code, but still, it's more helpful in the long run.

The only downside is when you're plugging in an array element. When you're plugging in an array element inside of an EOF, you have to surround it with { }. Don't ask me why, it's just a PHP thing! LOL

Like so:

// this will have to be wrapped in { }, because it's an array element
****[0] = "Whatever";

// this won't, because it's just a string
**** = "Hello World";

echo <<<EOF
<html
<head>
<title>{****[0]}</title>
</head>

<body>
****
</body>
</html>

EOF;

GoWilkes

Posted 11:42 pm, 02/11/2011

Do you mean that I lost you with the EOF reference? It's simple; this will print the same as what you wrote before, but without escaping the double quotes:

echo <<<EOF
<html>
<head>
<title>****</title>
</head>
<body>

<form action="calctemp.php" method="POST">
<p><strong>Temperature:</strong><br>
<input type="text" name="user">
<p><strong>Select a Temperature to Convert:</strong><br>
<select name"temperature[]" multiple="multiple">
<option value="celsius">Celsius</option>
<option value="fahrenheit">Fahrenheit</option>
<option value="kelvin">Kelvin</option>
</select>
<p><input type="Submit" value="Send"></p>
</form>

</body>
</html>
EOF;

I really want to ask why you're doing your <br> as <br/>, but that's a different thread, I guess.

For your formulas, do you mean for **** to equal $_POST['user']? If so, you'll need to declare that, obviously. Also, you have an extra ( in the first formula.

On the processing page, I would do it one of two ways:

1. You can use a series of if-else or switch-case statements to show the right one; or

2. The way I would do it is to create an associative array (aka, multidimensional array) at the beginning of the page, with each value representing one of the temperatures. Then, just pull out the correct answer using ****[$_POST['user']].

Have you used associative arrays yet? If not, then stick with the if-else statement.

mtncruizer

Posted 10:56 pm, 02/11/2011

I'm afraid you've lost me. I did get my formulas together and I think they will calculate correctly if I can figure out if I need to use 'if' statements and where I need to use them. This is so confusing to me. Thanks for taking time to help me. I know you are very busy and I certainly do appreciate any help you can offer.



Here are my formulas:



****_2_f=(*****9/5+32;
****_2_k=*****9/5+273;
****_2_c=(****-32)*5/9;
****_2_k=****_2_c+273;
****_2_f=(****-273)*9/5+32;
****_2_c=****-273;

GoWilkes

Posted 10:25 pm, 02/11/2011

That's right; the only differences between GET and POST is that GET shows the variables in the address bar, and because of that, GET has a limit on the number of characters that can be sent (a limitation of the users browser, actually, but it's still a limitation).

Your life might also be easier if, in your first sheet, you do this:

echo <<<EOF
<html>
...
</html>
EOF;

Note that you can tab any of the lines here EXCEPT for the last EOF; line; that can't have anything before it on the same line. But using this method, you don't have to escape everything inside of the echo "..."; statement.

mtncruizer

Posted 10:20 pm, 02/11/2011

Thanks. I think I know what you mean. When using GET, the info displays in the url...is that right?



I'm just so lost on all this. Like I said, if I didn't have to take this class, I wouldn't!



Thanks again for your help.

GoWilkes

Posted 9:44 pm, 02/11/2011

It looks like there's a lot left to your processing function. Are you assuming that they're submitting in Farenheit, or should their be a variable for that?

For the sake of testing, you might want to change your method to "GET", and then you can see how the data comes to the processing page in the address bar. That will help you figure out how to process **** a lot easier. Then, if you need to use POST for the assignment, you can just change it back when you're done.

mtncruizer

Posted 9:00 pm, 02/11/2011

I'm back with another project that's bigger than my brain is. I've got the form set up and the return page, but I can't figure out how to get my formulas added as variables (?) and have the conversion take place correctly. Any help will be deeply appreciated!



Here's what I have so far:

My form:

**** = "Assignment 6";


echo "<html>
<head>
<title>
****
</title>
</head>
<body>

<form action=\"calctemp.php\" method=\"POST\">
<p><strong>Temperature:</strong><br/>
<input type=\"text\" name=\"user\"/>
<p><strong>Select a Temperature to Convert:</strong><br/>
<select name\"temperature[]\" multiple=\"multiple\">
<option value=\"celsius\">Celsius</option>
<option value=\"fahrenheit\">Fahrenheit</option>
<option value=\"kelvin\">Kelvin</option>
</select>
<p><input type=\"Submit\" value=\"Send\" /></p>
</form>\n";



//formulas
//Tf=[(9/5)xTc]+32
//Tc=(5/9)x(Tf-32)
//Tc=Tk-273
//Tk=Tc+273


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

?>



My return page:

<?php
echo "<p><b>Welcome!</b><br/> The temperature you chose was: <b>".$_POST["user"]."</b></p>";
echo "<p>Here's the conversion:<br/>";
if (!empty ($_POST ["temperatures"]))
{
echo "<ul>";

foreach ($_POST ["temperatures"] as ****)
{
echo "<li>****</li>";
}
echo "</ul>\n";
}

?>

mtncruizer

Posted 9:47 pm, 02/08/2011

BlueRidgeGuy, you are my hero!!!

I am really struggling with this class and I really appreciate your help!!

I've got to do a temperature conversion table for my next assignment. It has to include celsius, faharenheit and kelvin (I probably didn't spell those correctly). It has to display in a table with the original temp and the conversions for the others. I'm already stressed about this assignment but have been working on it today. I'll probably be posting it in a day or so begging for help with it. Sure hope you are around!!!

Thanks again!!!!

BlueRidgeGuy

Posted 9:24 pm, 02/08/2011

Here is a short and sweet version that prints both the special for the current day and then lists all specials

<?php
//
**** = date("l"); // get the day of the week (format xxxxday)

**** = array('Sunday' => "little tv",
'Monday' => "big tv",
'Tuesday' => "really big tv",
'Wednesday' => "little radio",
'Thursday' => "big radio",
'Friday' => "really big radio",
'Saturday' => "laptop" );
echo "Today is **** and the special is the ****[****]<br /><br />\n";

while (list(****, ****) = each(****))
{
echo "Key: ****; Value: ****<br />\n";
}

?>

mtncruizer

Posted 6:10 pm, 02/08/2011

I think I got it! I took the echo statements out of the braces and now it just displays the day and the special, not all of the items. Woo-hoo!! Now all I have to do is add printf to format the prices!

Thanks for all your help!!

My next assignment is a doozy. I'll probably be on here again begging for help!!

mtncruizer

Posted 3:55 pm, 02/08/2011

Okay, I made the changes and put the variables inside the function but it is still putting the day of the week on each item. I need it to pick up the day from the variable and index it into the array and only echo out the day's special. Example: Today is Tuesday so I only want it to display "Tuesday HP Computer 355.00". I've got to put some formatting in also that will display the price at two decimals and also add the '$' sign, but I'll try to get that in later. I might not be doing the echo correctly at the bottom of my script but I'm not sure.

Here it is again. Tf you have time to look it over, I sure would appreciate it!!

//variables
**** = "Assignment 5";

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(':',****);

****=getdate();
****=****[weekday];

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


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

mtncruizer

Posted 8:32 am, 02/08/2011

Thanks, BlueRidgeGuy!!!! This stuff is driving me crazy!!!!

I've got math class this morning but I'll make the change when I get back and hope for the best!!!

Thanks again! I really appreciate you taking the time to help!

Your Reply

Your Username:

Your Password:


 
Add Reply
Cancel
Sherrill Faw Realty, LLC
We can show you any listing in Wilkes County including HUD forclosures. Helping people find their dream home since 1962. Office: 336-903-0060 Cell: 336-957-7600
Advertise your business here for $5/day
This is crazy: in December 2023, the average banner here was seen 1,139,054 times and was clicked 170 times! Click here to advertise for less than $5 /day.
Joines & James, Attorneys at Law
Joines & James, Attorneys at Law PLLC. 336 838-2701