OK this is an easy one for someone! – PHP

  php

Q(Question):

OK I’m sooo new to this, but so far i have managed to create a form (like a
shopping list) in one page which looks like this where i can put quantities
in on one page.

www.martinhawken.com/php.php

Then it passes the form info onto my next page which displays a list and
totals. But how, pray, would I make it miss out items on my second page
where they have a value on null? You see I would rather just have the items
where I have actually given a value! Is it some kind of if else statement
possibly followed by the ! mark to reverse the flag or summat?

Any help? I only started this PHP thing 2 days ago!!
Cheers,

Steve

A(Answer):

Steve wrote:

OK I’m sooo new to this, but so far i have managed to create a form (like a
shopping list) in one page which looks like this where i can put quantities
in on one page.

www.martinhawken.com/php.php

Then it passes the form info onto my next page which displays a list and
totals. But how, pray, would I make it miss out items on my second page
where they have a value on null? You see I would rather just have the items
where I have actually given a value! Is it some kind of if else statement
possibly followed by the ! mark to reverse the flag or summat?

You could do something like:

foreach($_REQUEST as $key->$var)
if ($var == "")
unset($_REQUEST[$key]);

print_r($_REQUEST);

But that might not be ideal…

Shawn

Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com

A(Answer):

you could just check the $item1 for null
so something like this
if($item1 != "") {
echo "500 Wire Shelf – Number of items @ £14.00 : ".$item1;
}

and then same with $item2, $item*

"Steve" <lu***********@hotmail.com> wrote in message
news:40**********************@news.astraweb.com…

OK I’m sooo new to this, but so far i have managed to create a form (like
a shopping list) in one page which looks like this where i can put
quantities in on one page.

www.martinhawken.com/php.php

Then it passes the form info onto my next page which displays a list and
totals. But how, pray, would I make it miss out items on my second page
where they have a value on null? You see I would rather just have the
items where I have actually given a value! Is it some kind of if else statement
possibly followed by the ! mark to reverse the flag or summat?

Any help? I only started this PHP thing 2 days ago!!
Cheers,

Steve

A(Answer):

Might want to cast the variable to int first, so that an spaces and
non-numeric entries are ignored

$item1 = (int) $item1;
if($item1) { …

Uzytkownik "Stormkid" <ba*****@goldengate.net> napisal w wiadomosci
news:40***********************@newsreader.goldenga te.net…

you could just check the $item1 for null
so something like this
if($item1 != "") {
echo "500 Wire Shelf – Number of items @ £14.00 : ".$item1;
}

and then same with $item2, $item*

"Steve" <lu***********@hotmail.com> wrote in message
news:40**********************@news.astraweb.com…

OK I’m sooo new to this, but so far i have managed to create a form
(like

a

shopping list) in one page which looks like this where i can put

quantities

in on one page.

www.martinhawken.com/php.php

Then it passes the form info onto my next page which displays a list and
totals. But how, pray, would I make it miss out items on my second page
where they have a value on null? You see I would rather just have the

items

where I have actually given a value! Is it some kind of if else

statement possibly followed by the ! mark to reverse the flag or summat?

Any help? I only started this PHP thing 2 days ago!!
Cheers,

Steve

A(Answer):

Thanks, all of you – you guys are the BEST!! It all worked! Friday 13th is a
sweet one this morning!:

www.martinhawken.com/php.php

Thanks, Shawn – your version was a couple of steps more advanced than my
brain can currently take, so i used Stormkids (Thanks SK), please don’t take
offence, maybe you can help me again when I’m up to speed! Chung’s line of
code worked great, too!

Cheers!

Steve

A(Answer):

OK so far so good, now if someone could point me roughly in the direction of
how to get this data sent to an email address *without* using the dreaded
‘mailto:’ my weekend would be made!?

Thanks!

Steve

A(Answer):

Steve wrote:

OK so far so good, now if someone could point me roughly in the direction of
how to get this data sent to an email address *without* using the dreaded
‘mailto:’ my weekend would be made!?

Thanks!

Steve

You want the mail() function
http://www.php.net/manual/en/function.mail.php

[ Don’t forget to configure php.ini to allow sending mails ]

For example (with a few undefined variables thrown-in, that you have to
replace):

<?php
if ($everything_ok) {
update_db(); // or whatever you have
$message = "new data has been inserted into the db:

field1: $field1
field2: $field2";
mail($your_address, ‘new data’, $message);
}
?>

–= my mail box only accepts =–
–= Content-Type: text/plain =–
–= Size below 10001 bytes =–

LEAVE A COMMENT