Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

php - Why does this display the wrong value? (cms e107)

I don't really know PHP to begin with. I'm just trying to make a plugin (cms e107) work?

This part of the plugin should display news articles on a games profile page related to the game. It's being handled using the news systems own tags system. Give tags to an article.. give a tag to the game.. the game finds it and displays the item(s).

The problem being is that a game with no tags attached to it displays all of the news articles on the site instead of display that no news articles are found for this game. Querying a not existing game with display that there are no news related to this game. While the game that has tags attached to it displays the articles with that tag.

    if($result_news = mysqli_query($link, "SELECT NewsTagsSELECTED FROM e107_games where id=".$gameID)){        
      if(mysqli_num_rows($result_news) > 0){
        $row_news_array = mysqli_fetch_array($result_news);
        $row_news_array = $row_news_array[0];
        $row_news_array = explode(",", $row_news_array);     

   foreach ($row_news_array as $row_news_val) {     
        if($news_id_array = mysqli_query($link, "SELECT news_id FROM e107_news where news_meta_keywords like '%".$row_news_val."%'")){ 
             if(mysqli_num_rows($news_id_array) > 0){
                   while($news_id_val = mysqli_fetch_array($news_id_array))
                   {
                          $news_id_val_array[] = $news_id_val[0];
                   }
              }
        }       
    }
    $news_id_val_array = array_unique($news_id_val_array);
}
$news_tag_id_array = $news_id_val_array;
$sizeNewsTag = sizeof($news_tag_id_array);
if($sizeNewsTag == "")
{
     ?><h3>No news found for this game.</h3><?php
}

Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...