473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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>

Jul 17 '05 #1
4 1867
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
Jul 17 '05 #2
.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
Jul 17 '05 #3
if (!strlen($formVal))

Jul 17 '05 #4
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

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: MJ | last post by:
I have 4 pricing levels for products. Each customer has only 1 level. If a customer is pricing level 1, I don't want pricing levels 2-4 to show up on the query for each product. How can I...
6
by: Vern | last post by:
I'm adding twenty nodes (Parent and child) to a tree view. Only 10 items are viewable in the window at at time. So when it initially shows the tree, it shows the last ten items forcing me to use...
1
by: Galka | last post by:
Hello I have a form to enter names and some other personal information. When a name is entered, it is checked against existing records: maybe, such name was entered before? If yes, user is...
1
by: jmarr02s | last post by:
I created a subform with 4 separate fields (textboxes) each containing an 8 digit date I want the most current date to show in each of the four fields So under properties for the subform...
1
by: sjvandevoorde | last post by:
I need some help with a couple forms/test fields. Bare with me I have been out of the field for some time and only consider myself an intermediate user. The first one is a subfrom which lists...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
5
theaybaras
by: theaybaras | last post by:
Hi, I'm still getting a feel for some things in Access. What I have is a database of scientific articles. I have an unbound memo field in which I want to have the APA style citation concatenated...
2
by: Sanjaylml | last post by:
I have made a form in Access 2000. In addition to just simply enter the data through form, I have appended sub-form in main form to show the all the entered records as Sub-Form (DataSheet), which is...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.