cheeseus Posted May 19, 2007 Share Posted May 19, 2007 On the page, a particular record is displayed (full length article) and below it the rest of the articles from the same category are listed by their title. In there, however, the main article's name is repeated. I need to "see" which art_id this is and "tell" the query to skip it. But how? This is my main article query: $article_query = mysql_query("SELECT * FROM az_articles WHERE issue = '$myrow[issue]' AND art_id = '$art_id' LIMIT 1",$connect); while($rrow = mysql_fetch_array($article_query)) {...echo... //and here is the query for the rest of the articles $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' ORDER BY art_id DESC",$connect); while($mrow = mysql_fetch_array($more_articles)) { $art_id = $mrow['art_id']; echo "<tr><td class=headline><br><a href=ft_online_art.php?art_id=$art_id class=headlines><img src=images/headlines.gif border=0> <b>"; echo $mrow['art_title']; echo "</a></td></tr>"; } I guess I must write something in the LIMIT clause for the "more_articles" query. This is what I tried (please don't laugh!) $shown_article = mysql_query("SELECT * FROM az_articles WHERE issue = '$myrow[issue]' AND art_id = '$art_id' ",$connect); if($skip_article = $shown_article) { $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' ORDER BY art_id DESC LIMIT $skip_article",$connect); while($mrow = mysql_fetch_array($more_articles)) { Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/ Share on other sites More sharing options...
MadTechie Posted May 19, 2007 Share Posted May 19, 2007 I didn't read the whole thing but.. use limit like this LIMIT start, end so LIMIT 0,5 - displays the first 5 LIMIT 5,5 - displays the next 5 (records 5 to 10) LIMIT 10,5 - displays the next 5 (records 10 to 15) etc Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256896 Share on other sites More sharing options...
cheeseus Posted May 19, 2007 Author Share Posted May 19, 2007 Thanks but this does not solve my case. Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256911 Share on other sites More sharing options...
MadTechie Posted May 19, 2007 Share Posted May 19, 2007 in which i don't understand your question Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256913 Share on other sites More sharing options...
cheeseus Posted May 19, 2007 Author Share Posted May 19, 2007 Please look at this page: http://www.thefrontiertimes.com/ft_online_art.php?art_id=2 First is the full length article, and then come the titles of articles from the same category. But the list of articles I don't want to display the same article. Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256920 Share on other sites More sharing options...
MadTechie Posted May 19, 2007 Share Posted May 19, 2007 Ahh ok 2 options spring to mind #1, just use random (not ideal) $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' ORDER BY RAND()",$connect); #2, store the ids in a cookie and use NOT IN (note cookie should be comma delimited) $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' AND NOT ID in ($COOKIE) ORDER BY art_id DESC",$connect); it depends on the "rules" what are the "rules" for the more_articles, ie only show once! don't show a link to the current article etc Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256923 Share on other sites More sharing options...
cheeseus Posted May 19, 2007 Author Share Posted May 19, 2007 Setting $Cookie is unfortunately beyond my knowledge Instead I wrote a check that, if the ID is the same as that of the main article, displays a transparent 1x1 px image. Perhaps very much "newbie" but all I can do. Better ways are welcome and appreciated! THANKS! $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' ORDER BY art_id DESC ",$connect); while($mrow = mysql_fetch_array($more_articles)) { if($art_id != $mrow['art_id']) { echo "<tr><td class=headline><br><a href=\"ft_online_art.php?art_id=$art_id\" class=headlines><img src=images/headlines.gif border=0> <b>"; echo $mrow['art_title']; echo "</a></td></tr>"; } else { echo "<tr><td class=headline><img src=".$imageurl." border=0></tr>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256947 Share on other sites More sharing options...
MadTechie Posted May 19, 2007 Share Posted May 19, 2007 what about $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' AND (NOT art_id = $rrow[art_id]) ORDER BY art_id DESC",$connect); or make it random (just an idea), without showing current $more_articles = mysql_query("SELECT * FROM az_articles WHERE section = '$rrow[section]' AND (NOT art_id = $rrow[art_id]) ORDER BY RAND()",$connect); Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256948 Share on other sites More sharing options...
cheeseus Posted May 19, 2007 Author Share Posted May 19, 2007 Thanks, this works too! However, every of the listed articles gets the same ID as that of the full-length one Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256960 Share on other sites More sharing options...
AndyB Posted May 19, 2007 Share Posted May 19, 2007 Thanks, this works too! However, every of the listed articles gets the same ID as that of the full-length one ft_online_art.php?art_id=$art_id\ Should be: ft_online_art.php?art_id=$rrow[art_id]\ Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256965 Share on other sites More sharing options...
cheeseus Posted May 19, 2007 Author Share Posted May 19, 2007 Yes, I figured that out, thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/52104-solved-check-if-particular-record-has-been-displayed-and-skip-it/#findComment-256974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.