Link to home
Start Free TrialLog in
Avatar of fanditha
fanditha

asked on

Skip the record if the record already exist

Hi

I need help reagrding a web page using php/mysql. I am a beiginner and am developing a news site. I would like to skip the records which is displayed in the featured news and display the remaining records.
Example: if the featured news is

ball fell down.. then i woul;d like to skip that news from

ball fell down
blah blah
blah blah
 so the result should be

blah blah
blah blah


got it?

here is the code i am using right now.

<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
<?php
require("./NewsSql.inc.php");
$db = new NewsSQL($DBName);
$homecataresult = $db->getchildcatalog(0);
$homelatestresult = $db->getlatestonhome($front_latestonhomerecord);
$home = $db->getfeaturenewsonhome();

?>
<html>
<head>
<title><?php print "$front_indextitle"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php print "$front_charset"; ?>">
<link rel="stylesheet" href="./style/style.css" type="text/css">
<link rel="stylesheet" href="./style/menu.css" type="text/css">
<script language="JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
<script type="text/javascript" src="./unicodehandler.js"></script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<?php
include("top.php3");
?>
<table width="770" border="0" cellspacing="1" cellpadding="0" align="center" class="table_01">  
  <tr>
    <td class="table_02" width="160" valign="top">
      <table width="160" border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td valign="top"><?php include("left.php"); ?></td>
        </tr>
      </table>      
    </td>
    <td class="en_w" bgcolor="#FFFFFF" valign="top" width="510">
    <table width="510" border="0" cellspacing="0" cellpadding="4">
          <tr>
            <td bgcolor="#F2F2F2" class="menu_in"><?php print "$front_latestnews"; ?></td>
          </tr>
          <?php
          $featureresult = $db->getfeaturenewsonhome();
            //$featureresult1 = $db->getfeaturenewsoncatalog(1);
          if (!empty($featureresult)){
          $newsid = $featureresult[0]["newsid"];
          $title = $featureresult[0]["title"];
          $intro = $featureresult[0]["intro"];
            $content = $featureresult[0]["content"];
            $adddate = $featureresult[0]["adddate"];
            $description= ($content);
              $numwords = 30;
              preg_match("/([\S]+\s*){0,$numwords}/", $description, $regs);
              $shortdesc = trim($regs[0]);
          ?>  
          <tr>
           <td>
           <a href="news.php?newsid=<?php print "$newsid"; ?>" class="feature"><?php print "$title"; ?></a><br>
            <span style= "direction:ltr;unicode-bidi:bidi-override;" class="en_g2"><?php print "$adddate"; ?></span><br>
<!--
           <a href="news.php?newsid=<?php print "$newsid"; ?>" class="feature"><em><?php print "$intro"; ?></em></a><br>
-->
           <?php print "$shortdesc"; ?>.... <a href= "news.php?newsid=<?php print "$newsid"; ?>" class="detail" font> twfcsIlc </a>
           </td>
          </tr>
          <?php
          }
          ?>
          <tr>
            <td>
             <br>
            <?php
            if (!empty($homelatestresult)) {
            while ( list($key,$val)=each($homelatestresult) ) {
            $title = stripslashes($val["title"]);           
            $newsid = stripslashes($val["newsid"]);
            ?>                        
            <a href="news.php?newsid=<?php print "$newsid"; ?>" class="divehi"><img src="./images/bullet_b.gif" width="5" height="5" border="0"><?php print "$title"; ?></a><br>
            <?php
                }
                }
               ?>
            </td>
          </tr>          
    </table>
    <?php
    if (!empty($homecataresult)) {
            $homecataresultcount = count($homecataresult);
              $rows = ceil($homecataresultcount/$tablecolumns);
              $percent = ceil(100/$tablecolumns)-1;
                ?>
    <table width="510" border="0" cellspacing="0" cellpadding="4">
          <?php
            $k = 0;
            for ($i=0;$i<$rows;$i++){
            ?>
           <tr>
              <?php
            $j=0;
            while (($k<$homecataresultcount)&&($j<$tablecolumns)) {           
            $catalogname = $homecataresult[$k]["catalogname"];
            $catalogid = $homecataresult[$k]["catalogid"];       
            $result = $db->getnewsbycatid(0,$front_catnewsonhomerecord,$catalogid);
            ?>
         <td width="<?php print "$percent"; ?>%" valign="top">
        
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td bgcolor="#F2F2F2" class="content"><?php print "$catalogname"; ?></td>
            <td bgcolor="#F2F2F2" class="divehi" align="right"><a href="catalog.php?catalogid=<?php print "$catalogid"; ?>" class="more"><img src="images/bullet_b.gif" width="5" height="5" border="0"><?php print "$front_more"; ?>...</a></td>
          </tr>        
          <tr>
           <td colspan="2">
           <?php
           if (!empty($result)) {
            while ( list($key,$val)=each($result) ) {
            $title = stripslashes($val["title"]);           
            $newsid = stripslashes($val["newsid"]);
           ?>
           <a href="news.php?newsid=<?php print "$newsid"; ?>" class="divehi"><img src="./images/bullet_b.gif" width="5" height="5" border="0"><?php print "$title"; ?></a><br>
           <?php
                }
                }
             ?>
           </td>
          </tr>
          </table>    
          </td>
            <?php
            $j++;
            $k++;
            }
            ?>
          </tr>
          <?php
            }
            ?>
    </table>
    <?php    
    }
    ?>              
    </td>
    <td class="divehi" background="./images/right_bg.gif" valign="top">      
      <table width="200" border="0" cellspacing="0" cellpadding="6">
        <tr>
          <td>
          <tr>
          <td>            
          <form action="search.php" method="POST">                  
            <table border="0" cellspacing="0" cellpadding="0" width="145" align="right">
        <tr>
          <td><font face= "a_faseyha">hOdW!</td></font>
        </tr>
              <tr>
                  <td><input type="text" class="divehi" name="keyword" value="" onkeypress="return juk_HandleKeyPress(event);" size="12"></td>
              </tr>
              <tr><td><input type="submit" name="searchsubmit" value="<?php print "$front_searchsubmit"; ?>"></td></tr>
              <tr><td>&nbsp;</td></tr>
            </table>            
            </form>
          </td>
        </tr>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<?php
include("bottom.php3");
?>
</body>
</html>
Avatar of mespinozae
mespinozae
Flag of Costa Rica image

1st we would appreciate you using the code block for such a long post, makes it a lot easier to read...
2nd, if you are inserting the you can use
INSERT IGNORE .....
to avoid duplicated entries or errors stopping a large batch.
Avatar of Loganathan Natarajan
So,  you want to avoid duplicated records in the display? ... You can do it from sql itself ... by using "distinction" ...  keyword ... did you try that?
Avatar of fanditha
fanditha

ASKER

Ok. I want to do it if certain condition is met; suppose if the isfeatured record is "1" then i don't want that particular record to to display.

Thansks
ASKER CERTIFIED SOLUTION
Avatar of mespinozae
mespinozae
Flag of Costa Rica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
did you try?
so simple ehehe. sometimes i dunt dunt know how to do most simple thing.