This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet51/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   47   48   49   50   51   52   53   54   ...   69
Bog'liq
PHP

|
169
In Example 7-6, the
submit
button has a name,
"s"
. We check for the presence of this
parameter value to see whether we have to produce a personality description.
Figure 7-3 shows the multiple selection page and the resulting output.
The same technique applies for any form field where multiple values can be returned.
Example 7-7 shows a revised version of our personality form that is rewritten to use
checkboxes instead of a select box. Notice that only the HTML has changed—the
code to process the form doesn’t need to know whether the multiple values came
from checkboxes or a select box.









if (array_key_exists('s', $_GET)) {
$description = join (" ", $_GET['attributes']);
echo "You have a $description personality.";
}
?>

Select your personality attributes:
Perky
Morose
Thinking
Feeling
Spend-thrift
Shopper


if (array_key_exists('s', $_GET)) {
$description = join (" ", $_GET['attributes']);
echo "You have a $description personality.";
}
?>
// fetch form values, if any
$attrs = $_GET['attributes'];
if (! is_array($attrs)) { $attrs = array( ); }
// create HTML for identically-named checkboxes
function make_checkboxes ($name, $query, $options) {
foreach ($options as $value => $label) {
printf('%s $label, $name, $value);
if (in_array($value, $query)) { echo "checked "; }
echo "/>
\n";
}
}
// the list of values and labels for the checkboxes
$personality_attributes = array(
'perky' => 'Perky',
'morose' => 'Morose',
'thinking' => 'Thinking',
'feeling' => 'Feeling',
'thrifty' => 'Spend-thrift',
'prodigal' => 'Shopper'
);
?>

Select your personality attributes:



if (array_key_exists('s', $_GET)) {
$description = join (" ", $_GET['attributes']);
echo "You have a $description personality.";
}
?>

Background:

Foreground:
1   ...   47   48   49   50   51   52   53   54   ...   69




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish