nitation Posted January 4, 2009 Share Posted January 4, 2009 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 More sharing options...
kenrbnsn Posted January 4, 2009 Share Posted January 4, 2009 What do you mean by I am using an IF statement in my code. But it's not displaying according to my database values. Ken Link to comment https://forums.phpfreaks.com/topic/139417-solved-if-condition-messing-up/#findComment-729320 Share on other sites More sharing options...
sniperscope Posted January 4, 2009 Share Posted January 4, 2009 if($i % 2) can you be more specific? what exactly you want by $i and what do you expect the result ? Link to comment https://forums.phpfreaks.com/topic/139417-solved-if-condition-messing-up/#findComment-729419 Share on other sites More sharing options...
nitation Posted January 4, 2009 Author Share Posted January 4, 2009 Thanks all. I got through with it. Just a minor problem. :-) Link to comment https://forums.phpfreaks.com/topic/139417-solved-if-condition-messing-up/#findComment-729534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.