php print values

I am a beginner here with PHP , but trying to make a simple script for work.
Basically I have this page > http://jmdostal.com/route2.php thats a simple form that can be filled out, and on the next page it puts the information into a format , (feel free to go to the page above to see what im talking about)

such as -
DRIVER NAME - TRUCK
Job 1 [Delivery] [City] - Items
Job 2 [Delivery] [City] - Items
Job 3 [Delivery] [City] - Items
[][] -
[][] -
[][] -
DRIVER NAME - TRUCK
Job 1 [Delivery] [City] - Items
Job 2 [Delivery] [City] - Items
Job 3 [Delivery] [City] - Items
[][] -
[][] -
[][] -

I have in the php code to add the [ ] so that its in the right format, such as
$city25 = “[”. Trim(stripslashes($_POST[‘city25’])) . “]”;

My question is -
How can I make the script not post anything if there are no values entered in the form?
As you can see I have 8 lines, in case we have 8 jobs that day, but if there are only 3 jobs , then I have all of these
[][] -
[][] -
[][] -
on the next page :frowning:
Hopefully I have explained this well
Any suggestions? Appreciate any help!

Check to see if the form has posted the information with isset()
If it is set, set $city25 otherwise do nothing.

[php]if(isset($_POST[‘city25’])){
$city25 = “[”. Trim(stripslashes($_POST[‘city25’])) . “]”;
}[/php]

etc.

here is an example of something that you can do

here is route2.php:
[php]




DRIVER HELPERS TRUCK
Select One Gustavo Jose F Juan Lucio

</b<

<? for($x = 1; $x <= 6; $x++) { ?> <? } ?>
Job Name D/P City items
Delivery Pickup </b<

DRIVER HELPERS TRUCK
Select One Gustavo Jose F Juan Lucio </b<
<? for($x = 1; $x <= 6; $x++) { ?> <? } ?>
Job Name D/P City items
Delivery Pickup </b<


DOSTAL

[/php]

you will see the symbols [] in the form, this is telling php that it is going to be an array, then I use a for loop to list out how many different job sites that are needed, rather than writting them all out.
Next we need to process the array data so here is a little something tricky I did with putting tables side by side of each other and using for loops to extract the data :

route.php:
[php]





<? echo"{$_POST['driver1']} "; ?> <? echo"{$_POST['h1']} "; ?> <? echo"{$_POST['t1']} "; ?>
<? foreach ($_POST['jobsite'] as $key => $value) { ?> <? } ?>
<?=$value; ?>
<? foreach ($_POST['dp'] as $key => $value) { ?> <? } ?>
<?=$value; ?>
<? foreach ($_POST['city'] as $key => $value) { ?> <? } ?>
<?=$value; ?>
<? foreach ($_POST['items'] as $key => $value) { ?> <? } ?>
<?=$value; ?>
[/php]

Hope this helps

Sponsor our Newsletter | Privacy Policy | Terms of Service