Welcome to Geeklog, Anonymous Friday, November 29 2024 @ 04:53 pm EST
Geeklog Forums
Show titles of Drafts Block
Status: offline
limiter
Forum User
Newbie
Registered: 05/24/05
Posts: 1
I am making a DVD/Movie review site (yes yes I know there are too many already, but I don't care) and I made a little block that shows DVD and Movie reviews I am working on (aka listed as draft) but not news drafts.
So the block says "Upcoming Reviews" and lists all the titles of current drafts of reviews. I thought someone else might find this helpful, and it may have been done before- if so sorry 'bout that. I am not the greatest PHP coder, so be kind.
/**
* Show upcoming reviews PHP Block function
*/
function phpblock_showupcomingreviews() {
$dbserver = 'yourdatabaseserver';
$usr = 'yourusername';
$pass = 'yourpassword';
$db = 'yourdatabase';
mysql_connect($dbserver,$usr,$pass);
mysql_select_db($db);
$drafts_query_sql = "SELECT * FROM gl_stories WHERE draft_flag = 1 AND (tid = 'moviereview' OR tid = 'dvdreviews') ORDER BY date"; //you can include more topics by adding 'OR tid ='topicname'
$drafts_query = mysql_query($drafts_query_sql);
$drafts_rows = mysql_num_rows($drafts_query);
if ($drafts_rows != 0) { $retval = $retval . "<ul>"; }
$d = 0;
while ($d < $drafts_rows) {
$drafts_title = mysql_result($drafts_query,$d,'title');
$retval = $retval . "<li>" . $drafts_title . "</li>";
$d++;
}
if ($drafts_rows != 0) { $retval = $retval . "</ul>"; }
return $retval;
}
So the block says "Upcoming Reviews" and lists all the titles of current drafts of reviews. I thought someone else might find this helpful, and it may have been done before- if so sorry 'bout that. I am not the greatest PHP coder, so be kind.
Text Formatted Code
/**
* Show upcoming reviews PHP Block function
*/
function phpblock_showupcomingreviews() {
$dbserver = 'yourdatabaseserver';
$usr = 'yourusername';
$pass = 'yourpassword';
$db = 'yourdatabase';
mysql_connect($dbserver,$usr,$pass);
mysql_select_db($db);
$drafts_query_sql = "SELECT * FROM gl_stories WHERE draft_flag = 1 AND (tid = 'moviereview' OR tid = 'dvdreviews') ORDER BY date"; //you can include more topics by adding 'OR tid ='topicname'
$drafts_query = mysql_query($drafts_query_sql);
$drafts_rows = mysql_num_rows($drafts_query);
if ($drafts_rows != 0) { $retval = $retval . "<ul>"; }
$d = 0;
while ($d < $drafts_rows) {
$drafts_title = mysql_result($drafts_query,$d,'title');
$retval = $retval . "<li>" . $drafts_title . "</li>";
$d++;
}
if ($drafts_rows != 0) { $retval = $retval . "</ul>"; }
return $retval;
}
13
8
Quote
All times are EST. The time is now 04:53 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content