| | |
echo statement in form
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 5
Reputation:
Solved Threads: 0
Hello,
Below is a form redirect page. When the form is filled out the following will be seen on the redirect page. What I would like to do is hide the echos that aren't filled out.
<span class="content"><strong>Name:</strong></span> <span class="contentred"><?php echo $fullname; ?></span><br>
<span class="content"><strong>Company:</strong></span> <span class="contentred"><?php echo $company; ?></span><br>
<span class="content"><strong>Phone:</strong></span> <span class="contentred"><?php echo $phone; ?></span><br>
<span class="content"><strong>Email:</strong></span> <span class="contentred"><?php echo $email; ?></span><br>
<span class="content"><strong>Address:</strong></span> <span class="contentred"><?php echo $address; ?></span><br>
<span class="content"><strong>City:</strong></span> <span class="contentred"><?php echo $city; ?></span><br>
<span class="content"><strong>State:</strong></span> <span class="contentred"><?php echo $state; ?></span><br>
So, for instance, if the name and company are filled out then I would like the redirect page to look like this:
Name: What ever is typed in
Company: What ever is typed in
Then I would like the other fields to be hidden.
Currently if the name and company are filled in then it looks like this:
Name: What ever is type in
Company: What ever is typed in
Phone:
Email:
Address:
City:
State:
Below is a form redirect page. When the form is filled out the following will be seen on the redirect page. What I would like to do is hide the echos that aren't filled out.
<span class="content"><strong>Name:</strong></span> <span class="contentred"><?php echo $fullname; ?></span><br>
<span class="content"><strong>Company:</strong></span> <span class="contentred"><?php echo $company; ?></span><br>
<span class="content"><strong>Phone:</strong></span> <span class="contentred"><?php echo $phone; ?></span><br>
<span class="content"><strong>Email:</strong></span> <span class="contentred"><?php echo $email; ?></span><br>
<span class="content"><strong>Address:</strong></span> <span class="contentred"><?php echo $address; ?></span><br>
<span class="content"><strong>City:</strong></span> <span class="contentred"><?php echo $city; ?></span><br>
<span class="content"><strong>State:</strong></span> <span class="contentred"><?php echo $state; ?></span><br>
So, for instance, if the name and company are filled out then I would like the redirect page to look like this:
Name: What ever is typed in
Company: What ever is typed in
Then I would like the other fields to be hidden.
Currently if the name and company are filled in then it looks like this:
Name: What ever is type in
Company: What ever is typed in
Phone:
Email:
Address:
City:
State:
this should do it.
i know theres another way to do it but i can't think of it right now.
PHP Syntax (Toggle Plain Text)
<?php $array = array( 'Name'=>'fullname', 'Company'=>'company', 'Phone'=>'phone', 'Email'=>'email', 'Address'=>'address', 'City'=>'city', 'State'=>'state' ); $html = ''; foreach( $array as $title => $value ) { $str = ${$value}; if ( $str !== '' ) { $html .= "<span class=\"content\"><strong>{$title}:</strong> </span>\n"; $html .= "<span class=\"contentred\">{$str}</span><br />\n"; } } echo $html; ?>
i know theres another way to do it but i can't think of it right now.
Last edited by kkeith29; Nov 3rd, 2008 at 8:27 pm.
![]() |
Similar Threads
- Populating form with existing MySQL data (PHP)
- Parsing html form. (PHP)
- email (PHP)
- Send form inputs to email address (PHP)
- PHP for login authentication (PHP)
- is there something wrong with my SQL statement? (PHP)
- Need help with password strength test script (PHP)
- if statement in php (PHP)
- Populating a fields on a form base on a selected item from a droplist. (PHP)
- BASIC FORM problems... (PHP)
Other Threads in the PHP Forum
- Previous Thread: adding Options to Drop Down menu
- Next Thread: php reader of rss feeds
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






