Search the Community
Showing results for tags 'one'.
-
Hello, I now have a working blog, but only want some blog posts to show. I have a table called 'post_type' and have got the numbers 1 and 2 entered. Here is the code of my blog. Should this only show the posts with 1 in the table post_type ? If not, can you please tell me what's wrong... <?php require_once('Connections/check_mag.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_check_mag, $check_mag); $query_getRecent = "SELECT news.post_id, news.title, news.post_type FROM news WHERE news.post_type = 1 ORDER BY news.updated DESC "; $getRecent = mysql_query($query_getRecent, $check_mag) or die(mysql_error()); $row_getRecent = mysql_fetch_assoc($getRecent); $totalRows_getRecent = mysql_num_rows($getRecent); $var1_getDisplay2 = "-1"; if (isset($_GET['archive'])) { $var1_getDisplay2 = $_GET['archive']; $query_getDisplay = sprintf("SELECT news.post_id,news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE DATE_FORMAT(news.updated, '%%Y-%%m') = %s ORDER BY news.updated DESC", GetSQLValueString($var1_getDisplay2, "text")); } elseif (isset($_GET['post_id'])) { $var2_getDisplay3 = $_GET['post_id']; $query_getDisplay = sprintf("SELECT news.post_id,news.title, news.image, news.author, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE news.post_id = %s", GetSQLValueString($var2_getDisplay3, "int")); } else { $query_getDisplay = "SELECT news.post_id,news.title, news.image, news.author, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC"; } $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Blog</title> <link href="blog.css" rel="stylesheet" type="text/css" /> <style type="text/css"> a:link { color: #82BA63; text-decoration: none; } a:visited { text-decoration: none; color: #82BA63; } a:hover { text-decoration: none; color: #6FAE4D; } a:active { text-decoration: none; color: #82BA63; } </style> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/techyoucation grey.png')"> <div id="blog"> <div id="header"><a href="http://techyoucation.com/blog" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Logo','','images/techyoucation grey.png',1)"><img src="images/full logo.png" alt="techyoucation logo" width="219" height="47" id="Logo" /></a></div> <?php do { ?> <div class="blog_post"> <h4><img src="images/clock.png" width="22" height="22" alt="clock" /> <?php echo $row_getDisplay['formatted']; ?> </h4> <img src="<?php echo $row_getDisplay['image']; ?>" height="200" alt="icon" /> <div id="blog_text"><span style="color:#A0A0A0;font-family:Arial;font-size:25px;"><a href="<?php echo $row_getDisplay['post_id']; ?>"><?php echo $row_getDisplay['title']; ?></a></span><br /> <span style="color:#D0D0D0;font-family:Arial;font-size:15px;">By <?php echo $row_getDisplay['author']; ?></span><br /> <br /> <?php echo substr ($row_getDisplay['blog_entry'],0 ,500); ?>...<br /> <a href="<?php echo $row_getDisplay['post_id']; ?>">Read More</a><br /> <br /> </div> </div> <?php } while ($row_getDisplay = mysql_fetch_assoc($getDisplay)); ?><span style="color:#82BA61;font-family:Arial;font-size:17px;"> <strong>© Copyright 2013 techyoucation.com</strong> </span> </div> </body> </html> <?php mysql_free_result($getRecent); mysql_free_result($getDisplay); ?> Thanks in advance Aled