Jump to content

[SOLVED] If condition messing up


nitation

Recommended Posts

Hello folks,

 

I am using an IF statement in my code. But it's not displaying according to my database values. Please take a look.

$query = "SELECT * FROM nsit_news ORDER BY news_id " . " LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die (mysql_error());

$numrow = mysql_num_rows($result); 
echo "<table border=\"0\" width=\"280%\" cellspacing=\"0\" cellpadding=\"2\">\n"; 
echo "<tr class=\"dataTableHeadingRow\">
      <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\"><font color=\"#c415\">No[#]</font></td>
      <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">News Title</td>
      <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">Created By</td>
  <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">Edited by</td>
  <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">Edited Date</td>
  <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">Current Status</td>
  <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">Date Created</td>
  <a href=\"createNews.php\"><img src=\"images/create_news_btn.gif\"></a>
  <td class=\"dataTableHeadingContent\" align=\"left\" valign=\"top\">Perform Action  
   </td>
  

      </tr>\n"; 
  
		  
for($i = 0; $i < $numrow; $i++) { 
$row = mysql_fetch_array($result);  
if($i % 2) { 
echo "<tr bgcolor=\"#fff\">\n"; 
} else { 
echo "<tr bgcolor=\"#e3a679\">\n";  
} 
echo "<td class=\"dataTableContent\">".$row['news_id']."</td>
      <td class=\"dataTableContent\">".$row['news_title']."</td>
      <td class=\"dataTableContent\">".$row['admin_createdby']."</td>
      <td class=\"dataTableContent\">".$row['admin_lastedit']."</td>
  <td class=\"dataTableContent\">".$row['lasteditdate']."</td>
  <td class=\"dataTableContent\">".$row['news_status']."</td>
  <td class=\"dataTableContent\">".$row['addeddate']."</td>
  <td class=\"dataTableContent\">
  <a href=\"editNews.php?news_id={$row['news_id']}\"><img src=images/icon_edit.gif title=\"Edit\"></a> 
  <a href=\"javascript:delnewspanel('$row[news_id]','$row[news_title]')\"><img src=images/icon_delete.gif title=\"Delete\"></a> 
  <a href=\"javascript:void(0)\" onclick=\"window.open('newsStatus.php?news_id={$row['news_id']}','Publish Menu','width=300,height=200')\">
  if($news_status==1)
       {
	         $news_status_btn=$nopublish;
	   }
	      else
	       {
		     $news_status_btn=$publish;
		   }
  $news_status_btn</a>
  </td>\n"; 
echo "</tr>\n"; 
} 

 

 

Link to comment
https://forums.phpfreaks.com/topic/139417-solved-if-condition-messing-up/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.