Created
November 1, 2015 02:42
-
-
Save karellism/34d75c44d8c098765ddb to your computer and use it in GitHub Desktop.
Displaying the data from the simple CMS database - php file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function display_public() { | |
$q = "SELECT * FROM testDB ORDER BY created DESC LIMIT 3"; | |
$r = mysql_query($q); | |
if ( $r !== false && mysql_num_rows($r) > 0 ) { | |
while ( $a = mysql_fetch_assoc($r) ) { | |
$title = stripslashes($a['title']); | |
$bodytext = stripslashes($a['bodytext']); | |
$entry_display .= <<<ENTRY_DISPLAY | |
<h2>$title</h2> | |
<p> | |
$bodytext | |
</p> | |
ENTRY_DISPLAY; | |
} | |
} else { | |
$entry_display = <<<ENTRY_DISPLAY | |
<h2>This Page Is Under Construction</h2> | |
<p> | |
No entries have been made on this page. | |
Please check back soon, or click the | |
link below to add an entry! | |
</p> | |
ENTRY_DISPLAY; | |
} | |
$entry_display .= <<<ADMIN_OPTION | |
<p class="admin_link"> | |
<a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a> | |
</p> | |
ADMIN_OPTION; | |
return $entry_display; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment