To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
The ASP.NET Chart Control
Article :: Introduction to SharePoint Development in Visual Studio 2010
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)



Go Back   VBForums > Other Languages > PHP

Reply Post New Thread
 
Thread Tools Display Modes
Old Jul 11th, 2010, 09:35 PM   #1
penagate
Super Moderator
 
Join Date: Jan 05
Location: Sunny Adelaide
Posts: 12,741
penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)penagate has much to be proud of (1500+)
Re: [RESOLVED] White Spaces Error

Some advice:

Your code structure is very hard to follow. It seems to be a muddle of logic and presentation. (Why are the database calls in the middle of the HTML? Why are you using echo to emit the output?)

As a general rule you should perform all logic (such as authentication and fetching data) before worrying about presentation. In a short script this can be accomplished simply, as in the following template:
PHP Code:
<?php
  
# Open session
  
session_start();

  
# Open database connection
  
$dbh = mysql_connect(...);
  
#...

  # Fetch data into a variable (say $comments)
  #...
?>
<html>
  <!-- Define HTML markup -->

  <!-- Output the data fetched:  -->
  <?php foreach ($comments as $comment): ?>
    <h2><?php echo $comment['title'] ?></h2>
    <p><?php echo $comment['comment'] ?></p>
  <?php endforeach; ?>

  <!-- Any other markup -->
</html>
This type of structure is much easier to follow, easier to maintain, and scales well if your website or web application develops beyond its original level of complexity.
penagate is offline   Reply With Quote
Reply

Go Back   VBForums > Other Languages > PHP


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:29 PM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.