how to show only entered fields ?

This is a discussion on how to show only entered fields ? within the PHP Language forums, part of the PHP Programming Forums category; hi all, I am getting lost in showing data entered in a form to a confirm page. I have a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-15-2004
johnny
 
Posts: n/a
Default how to show only entered fields ?

hi all,

I am getting lost in showing data entered in a form to a confirm page.
I have a form with as many list/menu as the categories existing in the
database. DONE

when user choose the items from the list/menus they are passed on to a
second page where he can check if all data are correct and then send
it. DONE

However on the confirm page the script returns also empty lines of text
for the missing fields. I would like to just have the fields entered by
the user one after each other and not as they were on the first form.
How can I get rid of the empty fields ? ( of course just removing the
<BR> tag is not a solution )

I post the code of both pages below ( only the part of interest )

TIA

Johnny


CONFIRM PAGE


<form name="form1" method="post" action="send.php">
<p>Please check the data u entered</p>
<p>
<input name="hiddenField" type="hidden" value="<?php

foreach ($_POST['field'] as $name=>$value) {


echo nl2br("$value");
}

?>">

<?php

foreach ($_POST['field'] as $name=>$value) {


$split = split("\=", $value);
$pieces = explode("=", $value);
echo nl2br("$pieces[1]<BR>");
}

?>
</p>

<input name="Submit" type="submit" value="PROCEDI &gt;&gt;">
</p>
</form>


FORM PAGE

<form name="form1" method="post" action="confirm.php">

<?php



$cat=mysql_query("SELECT DISTINCT category FROM table ORDER BY
id", $db);
while ($category=mysql_fetch_array($cat)) {
$array_categoy[]=$category["category"];
}



foreach($array_category as $key=>$val) {
$data_link=mysql_query("SELECT * FROM table WHERE
category='$val'",$db);
?>
<?php $label = str_replace ( "_"," ",$val) ; ?>
<p> <?php echo $label; ?></p>

<select name="field[<?php $val ?>]"id="<?php $val ?>">
<option > - - - - - - - - - - - - </option>
<?php
while ($link=mysql_fetch_array($data_link)) {
$description_link= $link["product"];
$id_link = $link["id"];
$code_link = $link["code"];



print "<option value=\"$code_link = $description_link\">
$description_link </option>";





}
?>
</select>
<?php
}
?>

<input name="Submit" type="submit" value="GO ON &gt;&gt;">
</form>

Reply With Quote
  #2 (permalink)  
Old 12-15-2004
Scott Orsburn
 
Posts: n/a
Default Re: how to show only entered fields ?

johnny wrote:

>However on the confirm page the script returns also empty lines of text
>for the missing fields. I would like to just have the fields entered by
>the user one after each other and not as they were on the first form.
>How can I get rid of the empty fields ? ( of course just removing the
><BR> tag is not a solution )
>



Before you echo out the form value check to see if it's empty. I think
comparing it to an empty string will do, but if it doesn't try comparing
to null.

if($FormVal != "") // Possibly need to use: != null instead.
{
echo $FormVal;
}


--
Scott Orsburn
scottso_no@spam_maclaunch.com

Kaomso | Information Technology
www.kaomso.com


Reply With Quote
  #3 (permalink)  
Old 12-15-2004
Michael Fesser
 
Posts: n/a
Default Re: how to show only entered fields ?

.oO(Scott Orsburn)

>Before you echo out the form value check to see if it's empty. I think
>comparing it to an empty string will do, but if it doesn't try comparing
>to null.


empty() exists.

Micha
Reply With Quote
  #4 (permalink)  
Old 12-15-2004
Steve
 
Posts: n/a
Default Re: how to show only entered fields ?

if (!strlen($formVal))

Reply With Quote
  #5 (permalink)  
Old 12-16-2004
Scott Orsburn
 
Posts: n/a
Default Re: how to show only entered fields ?

Michael Fesser wrote:

> .oO(Scott Orsburn)
>
>
>
>>Before you echo out the form value check to see if it's empty. I think
>>comparing it to an empty string will do, but if it doesn't try comparing
>>to null.
>>
>>

>
>empty() exists.
>
>



Cool. I was unaware of that one.


--
Scott Orsburn
scottso_no@spam_maclaunch.com

Kaomso | Information Technology
www.kaomso.com

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:20 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0