Jump to content

dms

Member
  • Posts

    104
  • Joined

  • Last visited

Posts posted by dms

  1. Since you are using $_POST in your form, you might be better served to use it in your PHP script to capture the user input instead of $_REQUEST.

     

    Ben example looks good to me, but I'm curious about one item in the mail().

     

    [mail("email@yahoo.com", "Message from the Website", $message, "From: $email" );] Does ["From: $email"] need to be

    ["From:" . $email]?

  2. I think what your looking to do is to have your navigation in a

    that you would float: left;. Then have the main content of your page to the right. If so, create a
    for the main content and set the left-margin to where it will clear the right margin of the float left area. Your navigation will be the same on each page, but the main content will change.

     

    eg. if your float left area is 300px wide, you need to set the left-margin of the main content to at least 300px and set your left-padding to meet your needs. You may have to wrap all in a

    and set the width of the wrapper and the float:left;. I believe this is the basis of what your looking for - hope it helps.
  3. I believe character encoding names are case sensitive, so you might also be sure to capitalize "UTF-8"

     

    If you are using an older browser, it may be wise to consider one of the other character encoding specs, such as...

     

  4. There may be absolutely no use for this, but if you ever do need to insert an item at the beg/end of an array; you could give the key a name with a low sort value, such as... ['1_dinner'] or a high sort value... ['zzz_dinner'], and then use the ksort() along with array_flip(). The only problem I see is that if you have different keys with the same value, you will lose all but the last key/value pair.

    e.g.

    <?php

    $example['breakfast'] = 'ham and egg';

    $example['lunch'] = 'steak';

    $example['snack'] = 'fish and chips';

     

    $example['1_dinner'] = 'pizza';

     

    ksort($example);

    foreach ($example as $key => $val) {

    echo "$key = $val\n";

    }

     

    $example = array_flip($example);

    $example['pizza'] = 'dinner';

    $example = array_flip($example);

    print_r($example);

    ?>

  5. Warning: array_push() expects at least 2 parameters, 1 given in C:\wamp\www\SMS 2.0\sample.php on line 16

    Array ( [breakfast] => ham and egg [lunch] => steak [snack] => fish and chips [dinner] => pizza )

     

    But you see the dinner was inserted..but how do I remove the error.

     

    Just learning myself, but if the warning is asking for two parameters, maybe by just adding a comma after $example will work. eg. [array_push($example, ['dinner'] = 'pizza');].

     

    If that doesn't work couldn't you just use $example['dinner'] = 'pizza';

  6. You must have 'f' set to 0 (f=0) in you php script or not set at all.

    Then you must have an the if statement to where... if('f'=form1) the form is included in the page.

     

    So, within the link you are resending 'f' through the super global $_get and setting the value to 'form1' which would include the form within the page.

     

    Try this: click on your Form 1 link to display the form and then in the url change [?f=form1] to [?f=0] and see what happens. The page will be redisplayed without the form, because 'f' was reset to false which would cause the if statement not to elevate to true, so the form will not be displayed.

     

    I believe that [f] is the key in the $_GET array which corresponds to the variable $f in your php code.

     

    I hope this is making since, because I'm just learning this myself.

  7. Just learning PHP myself, but I do remember reading something about setting the include_path in the php.ini file. Maybe this is something worth looking into.

     

    I would think that [f] would be the index or key within the $_GET array, which is a variable, so you may trying placing double quotes around it. This is a bit over my head. Good luck.

  8. This code is part of a lesson, where using "each() and list()" were required. Thanks for explaining how to clean up the code using the foreach loop.

     

    I"m not sure why I placed the double quotes around the two $value[] variables - I think I used an example from one of my books. I did notice that by adding single quotes around the [key] you can remove the double quotes and it works fine.

     

    Thanks Ben!

  9. Everything in this code seems to be working except for one desired result - I can not figure out why the total for $grand_total does not calculate. I'm trying to learn some php and I'm at a loss. Thanks in advance, Mark

     

    <?php

    $tax = 0.08; #tax rate is constant

    $sub_total = 0.0;

     

    ?>

    <?php

    //two-dimensional array... to hold the product name, price, shipping.

    $name = array(

    "Candle Holder" => array(

    "price" => 12.95,

    "shipping" => 0.0),

    "Coffee Table" => array(

    "price" => 99.50,

    "shipping" => 0.10),

    "Lamp" => array(

    "price" => 42.99,

    "shipping" => 0.10));

     

     

    //function to populate the sub_total to include... price, tax, shipping.

    function tally($price, $shipping, $tax = 0.08) {

    $sub_total = ($price + ($tax * $price) + $shipping);

    return $sub_total;

    }

     

    /*using list() and each() to traverse the array and capturing the function return and setting the $sub_total value.

    while (list($key, $value) = each($name)) {

    echo "$key: ". "$value[price]". "\n";

    $tally_up=tally($price, $shipping);

    $sub_total += $tally_up;

    }

    $grand_total = $sub_total;

     

    ?>


     

     

    Total (including tax and shipping): $<? echo $grand_total; ?>

  10. From an article today at stltoday.com... "V-Fluence helped the company (Hilton Hotels) provide an Internet identity to help eliminate hotel searches that pulled up sites featuring Paris Hilton". Googled Hilton Hotels and sure enough, no Paris Hilton in sight. Just curious, how would you go about doing that?

  11. "The vertical-align property sets the vertical alignment of an element".... http://www.w3schools.com/Css/pr_pos_vertical-align.asp

     

    eg. vertical-align:middle;

     

    or, It seems to me that you could give each link a class such as one_line and two_lines. Set the line-height and then use padding to adjust each class? Just my two cents, but I'm still very new to this. I'm sure others will have a more concrete solution, but the vertical-align property came straight from w3schools.com.

     

    Mark

  12. I think you should select the list like this, by selecingn the first ul...

    ul li a {

    font-family: Verdana, Arial, Helvetica, sans-serif;

    font-size: 12px;

    text-decoration: none;

    display: block;

    margin: 1px;

    padding: 7px;

    border: 1px solid #990000;

    background-color: #FFFFCC;

    color: #990000;

    size:200px;

    }

     

    ... and select the nested list or submenu by selecting the first ul and then the nested ul.

     

    ul ul a {

    font-family: Verdana, Arial, Helvetica, sans-serif;

    font-size: 12px;

    text-decoration: none;

    display: block;

    margin: 1px;

    padding: 7px;

    border: 1px solid #990000;

    background-color: #FFFFCC;

    color: #990000;

    size:200px;

    }

     

    It seems to me that when dealing with nested list, you would need to specify which ul you are referring to. Good luck.

×
×
  • Create New...