06-01-2009, 02:13 PM
|
#11 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 64
Thanks: 1
|
I personally preffer most of the time something like this(depending wheter there is more html or php):
PHP Code:
<?php
include_once("_class/database.php");
include_once("_class/news.php");
$DB = new DB;
$NEWS = new news;
$DB->setup_db('localhost','root','','db');
if ($_POST['title'])
$NEWS->admin_write($_POST);
if ($_GET ['post'] == 1) { ?>
<form method="post" action="index.php">
<h1>Post something!</h1>
<input type="text" name="title"><br>
<input type="text" name="content"></textarea><br>
<input type="submit" name="submit">
</form>
<?php
} else {
$sql = "SELECT * FROM slimplCMS_posts";
foreach ($DB->select($sql) AS $row) {?>
<div id="post_"<?=$row['id']?>">
<p><?=$row['title']?></p>
<p><?=$row['bodytext']?></p>
<p><?=$row['created']?></p>
</div><br>";
<?php } ?>
<a href="?post=1" title="Write an entry!" />Write an entry!</a>
<?php } ?>
Now, you can't see the advantage since the webeditor now has no syntax-highlighting on html, but when opening in eclipse or any similar IDE - it should show you also syntaxhighlighting on the html part. But as I said - I think i'ts not always the best way to do it - it depends on how much html do you have in comparison to the php code you have ;)
|
|
|
|