Das kann im Moment noch warten ich habe ein anderes Problem mit einem CMS. I-was habe ich falsch gestezt etc. Ist nur ein Punkt oder so was, denn ch nicht finde.
Code:
Alles anzeigen
Code:
Quellcode
- class modernCMS {
- var $host;
- var $username;
- var $password;
- var $db;
- function connect() {
- $con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
- mysql_select_db($this->db, $con) or die(mysql_error());
- }
- function get_content($id = '') {
- if($id != ""):
- $id = mysql_real_escape_string($id);
- $sql = "SELECT * FROM modernCMS WHERE id = '$id'";
- $return = '<p><a href="index.php">Go Back to content</a></p>';
- else:
- $sql = "SELECT * FROM modernCMS ORDER BY id DESC";
- endif;
- $res = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($res) != 0):
- while($row = mysql_fetch_assoc($res)) {
- echo '<h1><a href="index.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h1>';
- echo '<p>' . $row['body'] . '</p>';
- }
- else:
- echo '<p>Uh oh, this doesn\'t exist!</p>';
- endif;
- echo $return;
- }
- function add_content($p) {
- $title = mysql_real_escape_string($p['title']);
- $body = mysql_real_escape_string($p['body']);
- if(!$title || !$body):
- if(!title):
- echo "<p>The Title is Required</p>";
- endif;
- if(!body):
- echo "<p>The Body is Required</p>";
- endif;
- echo '<p><a href="add-content.php">Try Again!</a></p>';
- else:
- $sql = "INSERT INTO modernCMS VALUES (null, '$title', '$body')";
- $res = mysql_query($sql) or die(mysql_error());
- echo "Added Successfully!";
- endif;
- }
- function manage_content {
- echo '<div id="manage">';
- $sql = "SELECT * FROM modernCMS";
- $res = mysql_query($sql) or die(mysql_error());
- while($row = mysql_fetch_assoc($res)) :
- ?>
- <div>
- <h2 class="title"><?=$row['title']?></h2>
- <span class="actions"><a href="">Edit</a> | <a href="?delete=<?=$row['id'];?>">Delete</a></span>
- </div>
- <?php
- endwhile;
- echo '</div>'; // Closes Manage Div
- }
- function delete_content($id) {
- if(!$id) {
- return false;
- }else {
- $id = mysql_real_escape_string($id);
- $sql = "DELETE FROM modernCMS WHERE id = '$id'";
- $res = mysql_query($sql) or die(mysql_error());
- echo "Content Deleted Succesfully!";
- }
- }
- } // End the Class
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Torben Brodt () aus folgendem Grund: syntax