The following code...
echo "<table width=585 height=182 cass=table1>
<tr>
<td height=10 colspan=3 align=left valign=top></td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text6>". $data['pgmtitle'] ."
</td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text8>". $data['org'] ."</td>
</tr>
<tr>
<td height=21 colspan=3 align=center valign=middle class=text19>". $data['eventdtls'] ."
</td>
</tr>
<tr>
<td width=190 height=28 align=left valign=top class=text3>". $data['venue'] ."</td>
<td width=11 rowspan=2 align=left valign=top><div class=box2></div></td>
<td width=368 rowspan=2 align=left valign=top class=text7>
<b>Contact:</b> ". $data['contactperson'] ."
<br/><b>Phone:</b开发者_StackOverflow> ". $data['contactnumber'] ."
<br/><b>E-mail ID:</b> ". $data['email'] ."
<br/><b>Website:</b> ". $data['website'] ."</td>
</tr>
<tr>
<td height=51 align=left valign=top class=text7>". $data['hr'] .":". $data['min'] ." ". $data['time'] ."<br/>". $data['nature'] ."<br/><b>Category:</b> ". $data['category'] ."
</td>
</tr>
<tr>
<td height=8 colspan=3 align=left valign=top><div class=box3></div></td>
</tr>
</table><br/>";
}
I have a registration page and it goes to a database. And this is the retrieving page. If somebody enters 'pgmtitle' without space or fully in capital letter, the echo table is collapsing. Please help me.
If new lines are giving you problems (it's hard to tell what from your question) you could remove trailing new lines using:
$data = array_map("trim", $data);
The way you're using echo()
is pretty horrible. Try to keep presentation (display of HTML) separate from other logic. You could make the code look far cleaner by using <?php echo $foo ?>
or if you have short tags enabled <?= $foo ?>
<table width=585 height=182 cass=table1>
<tr>
<td height=10 colspan=3 align=left valign=top></td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text6><?php echo $data['pgmtitle'] ?></td>
</tr>
<tr>
<td height=17 colspan=3 align=center valign=middle class=text8><?php echo $data['org'] ?></td>
</tr>
<tr>
<td height=21 colspan=3 align=center valign=middle class=text19><?php echo $data['eventdtls'] ?></td>
</tr>
<tr>
<td width=190 height=28 align=left valign=top class=text3><? $data['venue'] ?></td>
<td width=11 rowspan=2 align=left valign=top><div class=box2></div></td>
<td width=368 rowspan=2 align=left valign=top class=text7>
<b>Contact:</b><?php echo $data['contactperson'] ?>
<br/><b>Phone:</b> <?php echo $data['contactnumber'] ?>
<br/><b>E-mail ID:</b> <?php echo $data['email'] ?>
<br/><b>Website:</b> <?php echo $data['website'] ?></td>
</tr>
<tr>
<td height=51 align=left valign=top class=text7><?php echo $data['hr'] ?>:<?php echo $data['min'] ?> <?php echo $data['time'] ?><br/><?php echo $data['nature'] ?><br/><b>Category:</b> <?php echo $data['category'] ?></td>
</tr>
<tr>
<td height=8 colspan=3 align=left valign=top><div class=box3></div></td>
</tr>
</table><br/>
edit: to answer the further question about iterating:
You can either do:
foreach ($rows as $data) {
?>
...
<td><?php echo $foo ?></td>
...
<?php
}
or if you're using pretty short tags:
<?php foreach ($rows as $data) : ?>
...
<td><?= $foo ?></td>
...
<?php endforeach; ?>
For maintainability and readability it's key that you separate the display logic out.
You are not using any quote in the tag attributes?
class="text7"
for example?
To output them via echo you would have to escaple them using the "\" characater ... like so ...
class=\"test7\"
are you asking for this http://www.php.net/manual/fr/function.wordwrap.php ?
echo "<table><tr><td>".wordwrap($data['pgmtitle'],20,"<br>",true)."</td></tr></table>";
This sounds more like a HTML & CSS problem, not a PHP problem.
Enclose the $data['pgmtitle']
in a DIV tag and set its CSS overflow property to hidden.
If you want to modify the TD tag itself, feel free to consult Why does overflow:hidden not work in a <td>?
精彩评论