For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2006 > PRINT "...." ; Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PRINT "...." ; Question
Steff

2006-03-19, 6:56 pm

I am wandering if my code is making sense... I use a lot the print function.
Is it weird in this case where I have to display an array ? I thought it
would be better to have the entire array in php but now I am not sure if
that makes sense. Can you tell me please ?


<html>

<head>

<link href="../withStyle.css" rel="stylesheet" type="text/css">

<title>Reporting System Demand Management</title>
</head>

<body>


<center><h1>Add request</h1></p></center>
<hr>

<p align="center">
 

<?php

print "<form ACTION='..' method='POST'>";
print "<table border='1' width='45%'>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Request Name</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'>
<p align='left'><input type='text' size='40'
name='request_name'><img src='requis.gif' width='15' height='15'></p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Request Date</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'>";
print "<p align='left'>";
print "<select name='day'>";
print "<option selected>dd</option>";
print "<option>01</option>";
print "<option>02</option>";
print "<option>03</option>";
print "<option>04</option>";
print "<option>05</option>";
print "<option>06</option>";
print "<option>07</option>";
print "<option>08</option>";
print "<option>09</option>";
print "<option>10</option>";
print "<option>11</option>";
print "<option>12</option>";
print "<option>13</option>";
print "<option>14</option>";
print "<option>15</option>";
print "<option>16</option>";
print "<option>17</option>";
print "<option>18</option>";
print "<option>19</option>";
print "<option>20</option>";
print "<option>21</option>";
print "<option>22</option>";
print "<option>23</option>";
print "<option>24</option>";
print "<option>25</option>";
print "<option>26</option>";
print "<option>27</option>";
print "<option>28</option>";
print "<option>29</option>";
print "<option>30</option>";
print "<option>31</option>";
print "</select>";
print "<select name='month'>";
print "<option selected>mm</option>";
print "<option>01</option>";
print "<option>02</option>";
print "<option>03</option>";
print "<option>04</option>";
print "<option>05</option>";
print "<option>06</option>";
print "<option>07</option>";
print "<option>08</option>";
print "<option>09</option>";
print "<option>10</option>";
print "<option>11</option>";
print "<option>12</option>";
print "</select>";
print "<select name='year'>";
print "<option selected>aaaa</option>";
print "<option>2006</option>";
print "<option>2007</option>";
print "<option>2008</option>";
print "<option>2009</option>";
print "<option>2010</option>";
print "<option>2011</option>";
print "<option>2012</option>";
print "<option>2013</option>";
print "<option>2014</option>";
print "<option>2015</option>";
print "<option>2016</option>";
print "<option>2017</option>";
print "<option>2018</option>";
print "<option>2019</option>";
print "<option>2020</option>";
print "</select><img src='requis.gif' width='15' height='15'>";
print "</p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Client Name</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'>";
print "<p align='left'>";
print "<select name='Client_name' size='1'>";
print "<option>Name</option>";

//connexion
$c1=oci_connect("stephane","Stef1975",$bdtest05);

$query="select client_firstname||' '||client_lastname as client_fullname
from clients";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
print "<option>";
echo $row[0];
print "</option>";
}

oci_free_statement($stmt);



print "</select><img src='requis.gif' width='15' height='15'></p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Request Type</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'>";
print "<p align='left'>";
print "<select name='Request Type' size='1'>";
print "<option>Request Type</option>";

$query="select request_type_name from request_types";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
print "<option>";
echo $row[0];
print "</option>";
}

oci_free_statement($stmt);


print "</select><img src='requis.gif' width='15' height='15'>";
print "</p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Client Departement</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'>";
print "<p align='left'>";
print "<select name='Department' size='1'>";
print "<option>Departement</option>";

$query="select department_name from departments";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
print "<option>";
echo $row[0];
print "</option>";
}

oci_free_statement($stmt);

print "</select>";
print "</p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Expected Delivery Date</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'>";
print "<p align='left'>";
print "<select name='day'>";
print "<option selected>dd</option>";
print "<option>01</option>";
print "<option>02</option>";
print "<option>03</option>";
print "<option>04</option>";
print "<option>05</option>";
print "<option>06</option>";
print "<option>07</option>";
print "<option>08</option>";
print "<option>09</option>";
print "<option>10</option>";
print "<option>11</option>";
print "<option>12</option>";
print "<option>13</option>";
print "<option>14</option>";
print "<option>15</option>";
print "<option>16</option>";
print "<option>17</option>";
print "<option>18</option>";
print "<option>19</option>";
print "<option>20</option>";
print "<option>21</option>";
print "<option>22</option>";
print "<option>23</option>";
print "<option>24</option>";
print "<option>25</option>";
print "<option>26</option>";
print "<option>27</option>";
print "<option>28</option>";
print "<option>29</option>";
print "<option>30</option>";
print "<option>31</option>";
print"</select>";
print "<select name='month'>";
print "<option selected>mm</option>";
print "<option>01</option>";
print "<option>02</option>";
print "<option>03</option>";
print "<option>04</option>";
print "<option>05</option>";
print "<option>06</option>";
print "<option>07</option>";
print "<option>08</option>";
print "<option>09</option>";
print "<option>10</option>";
print "<option>11</option>";
print "<option>12</option>";
print "</select>";
print "<select name='year'>";
print "<option selected>aaaa</option>";
print "<option>2006</option>";
print "<option>2007</option>";
print "<option>2008</option>";
print "<option>2009</option>";
print "<option>2010</option>";
print "<option>2011</option>";
print "<option>2012</option>";
print "<option>2013</option>";
print "<option>2014</option>";
print "<option>2015</option>";
print "<option>2016</option>";
print "<option>2017</option>";
print "<option>2018</option>";
print "<option>2019</option>";
print "<option>2020</option>";
print "</select>";
print "</p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'>Comment on Request</p>";
print "</td>";
print "<td align='left' width='50%' height='25' colspan='2'><textarea
name=comment cols=30 rows=2></textarea><p>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td align='left' width='50%' height='25'>";
print "<p align='left'></td>";
print "<td align='left' width='25%' height='25'>";
print "<p align='left'><input type='submit' name='addButton'
value='Add Request'>";
print "</p>";
print "</td>";
print "<td align='left' width='25%' height='25'>";
print "<input type='reset' name='resetButton' value='Reset'>";
print "</td>";
print "</tr>";
print "</table>";
print "</form>";

//close connexion
oci_close($c1);

?>

<p align="left"></p>
<hr>


<p align="center"><a href="index.htm">[Home]</a></p>


</body>

</html>

// thanks for looking!


Johannes Wienke

2006-03-19, 6:56 pm

Am 19.03.2006 15:00 schrieb Steff:
> I am wandering if my code is making sense... I use a lot the print function.
> Is it weird in this case where I have to display an array ? I thought it
> would be better to have the entire array in php but now I am not sure if
> that makes sense. Can you tell me please ?
>
>
> <html>
> <head>
> <link href="../withStyle.css" rel="stylesheet" type="text/css">
> <title>Reporting System Demand Management</title>
> </head>
> <body>
> <center><h1>Add request</h1></p></center>
> <hr>
> <p align="center">
>  
> <?php
> print "<form ACTION='..' method='POST'>";
> print "<table border='1' width='45%'>";

[... many other prints ...]

That doesn't make any sense. Most of your prints are static, so they
only take time to be parsed. Leave them out of your php-code and only
use php when it is needed.

By the way it looks much better to do it like this:

echo '<form action="bla.php" method="post">';
BearItAll

2006-03-20, 3:56 am

Steff wrote:

> I am wandering if my code is making sense... I use a lot the print
> function. Is it weird in this case where I have to display an array ? I
> thought it would be better to have the entire array in php but now I am
> not sure if that makes sense. Can you tell me please ?
>


I agree with you, it does look horrible :)

The basic split I would say is in the lines of,


<?php

include 'header.inc'; #where header is your html header

if( ThisIsARunWhereWeNeedTheConnection )
{
include 'ConnectionStatements/Funtions';
}
?>
any initial body code

<?php

include 'MyForm.inc';
# Where form is simply a string
echo '$MyFormString';
?>

#Then code/view specific to this page.


Remember that in php you can pop in and out of php blocks to write your
html. So in your form it would be nicer to work like this,

<?php
#some php code
?>

<form ACTION='..' method='POST'>
<table border='1' width='45%'>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Name</p>
</td>
.....
<?php
#more php code
?>

Personally I have been working much more with placeholders on pages. So
effectively the html view is complete with placeholder areas within 'divs'.
The areas are then only filled in as I need them from the code. Something
like this,

<div id='formArea'>
<?php
if( IncludeThisForm )
{
echo '$ThisForm';
}
else
{
#leave it blank or put something visually nice here
}
?>
</div


Jean Pierre Daviau

2006-03-21, 9:58 pm

print <<<ENDOFP
<form ACTION='..' method='POST'>
<table border='1' width='45%'>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Name</p>
</td>
etc.

ENDOFP;


fwdkhan@gmail.com

2006-03-24, 7:00 pm

if i write ur code then i do like this. i hope it is much batter.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>Untitled Document</title>
</head>

<body>
<center><h1>Add request</h1></p></center>
<hr>


<p align="center">
 

<form ACTION='..' method='POST'><table border='1' width='45%'>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Name</p></td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'><input type='text' size='40'
name='request_name'><img src='requis.gif' width='15' height='15'></p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Date</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='day'>
<option selected>dd</option>
<?
$test=12;
for($a=1;$a<=31;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?>
</select>
<select name='month'>
<option selected>mm</option>
<?
for($a=1;$a<=12;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?></select>

<select name='year'>
<option selected>year</option>
<?
for($a=2006;$a<=2020;$a++)
echo '<option>'.$a.'</option>';
?>
</select><img src='requis.gif' width='15' height='15'>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Client Name</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='Client_name' size='1'>
<option>Name</option>

<?
//connexion
$c1=oci_connect("stephane","Stef1975",$bdtest05);
$query="select client_firstname||' '||client_lastname as
client_fullname
from clients";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo '<option>'.$row[0].'</option>';
}
oci_free_statement($stmt);
?>

</select><img src='requis.gif' width='15' height='15'></p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Type</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='Request Type' size='1'>
<option>Request Type</option>

<?
$query="select request_type_name from request_types";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo '<option>'.$row[0].'</option>';
}
oci_free_statement($stmt);
?>
</select><img src='requis.gif' width='15' height='15'>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Client Departement</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='Department' size='1'>
<option>Departement</option>

<?
$query="select department_name from departments";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);
while ($row = oci_fetch_array($stmt,OCI_NUM))
{
print "<option>";
echo $row[0];
print "</option>";
}
oci_free_statement($stmt);
?>
</select>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Expected Delivery Date</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='day'>
<option selected>dd</option>
<?
for($a=1;$a<=31;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?>
</select>
<select name='month'>
<option selected>mm</option>
<?
for($a=1;$a<=12;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?>

</select>
<select name='year'>
<option selected>year</option>
<?
for($a=2006;$a<=2020;$a++)
echo '<option>'.$a.'</option>';


//close connexion
oci_close($c1);
echo $test;
?>

</select>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Comment on Request</p>
</td>
<td align='left' width='50%' height='25' colspan='2'><textarea
name=comment cols=30 rows=2></textarea><p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'></td>
<td align='left' width='25%' height='25'>
<p align='left'><input type='submit' name='addButton' value='Add
Request'>
</p>
</td>
<td align='left' width='25%' height='25'>
<input type='reset' name='resetButton' value='Reset'>
</td>
</tr>
</table>
</form>

<p align="left"> </p>
<hr>

<p align="center"><a href="index.htm">[Home]</a></p>


</body>
</html>

fwdkhan@gmail.com

2006-03-24, 7:00 pm

if i write ur code then i do like this. i hope it is much batter.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>Untitled Document</title>
</head>

<body>
<center><h1>Add request</h1></p></center>
<hr>


<p align="center">
 

<form ACTION='..' method='POST'><table border='1' width='45%'>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Name</p></td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'><input type='text' size='40'
name='request_name'><img src='requis.gif' width='15' height='15'></p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Date</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='day'>
<option selected>dd</option>
<?
$test=12;
for($a=1;$a<=31;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?>
</select>
<select name='month'>
<option selected>mm</option>
<?
for($a=1;$a<=12;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?></select>

<select name='year'>
<option selected>year</option>
<?
for($a=2006;$a<=2020;$a++)
echo '<option>'.$a.'</option>';
?>
</select><img src='requis.gif' width='15' height='15'>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Client Name</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='Client_name' size='1'>
<option>Name</option>

<?
//connexion
$c1=oci_connect("stephane","Stef1975",$bdtest05);
$query="select client_firstname||' '||client_lastname as
client_fullname
from clients";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo '<option>'.$row[0].'</option>';
}
oci_free_statement($stmt);
?>

</select><img src='requis.gif' width='15' height='15'></p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Request Type</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='Request Type' size='1'>
<option>Request Type</option>

<?
$query="select request_type_name from request_types";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo '<option>'.$row[0].'</option>';
}
oci_free_statement($stmt);
?>
</select><img src='requis.gif' width='15' height='15'>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Client Departement</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='Department' size='1'>
<option>Departement</option>

<?
$query="select department_name from departments";
$stmt=oci_parse($c1,$query);
oci_execute($stmt);
while ($row = oci_fetch_array($stmt,OCI_NUM))
{
print "<option>";
echo $row[0];
print "</option>";
}
oci_free_statement($stmt);
?>
</select>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Expected Delivery Date</p>
</td>
<td align='left' width='50%' height='25' colspan='2'>
<p align='left'>
<select name='day'>
<option selected>dd</option>
<?
for($a=1;$a<=31;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?>
</select>
<select name='month'>
<option selected>mm</option>
<?
for($a=1;$a<=12;$a++){
if($a<10)
echo '<option>0'.$a.'</option>';
else
echo '<option>'.$a.'</option>';}
?>

</select>
<select name='year'>
<option selected>year</option>
<?
for($a=2006;$a<=2020;$a++)
echo '<option>'.$a.'</option>';


//close connexion
oci_close($c1);
echo $test;
?>

</select>
</p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'>Comment on Request</p>
</td>
<td align='left' width='50%' height='25' colspan='2'><textarea
name=comment cols=30 rows=2></textarea><p>
</td>
</tr>
<tr>
<td align='left' width='50%' height='25'>
<p align='left'></td>
<td align='left' width='25%' height='25'>
<p align='left'><input type='submit' name='addButton' value='Add
Request'>
</p>
</td>
<td align='left' width='25%' height='25'>
<input type='reset' name='resetButton' value='Reset'>
</td>
</tr>
</table>
</form>

<p align="left"> </p>
<hr>

<p align="center"><a href="index.htm">[Home]</a></p>


</body>
</html>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com