PHP List page to determine whether to hide

Source: Internet
Author: User
PHP List page to determine whether to collect
This post was last edited by mf0916 on 2015-10-22 18:54:06

In the PHP file

$list is the data that the array contains for each piece of information, and then writes the following code;
foreach ($list as $value) {
$id =intval ($value [' id ']); information ID in//list
$uid =intval ($[' uid ");//ID of the currently logged on user
$STR =//Query database where likeid= ' $id ' and uid= ' $uid ';//There is no user ID and current information ID
The query condition is this, the specific code will not write (⊙﹏⊙) b
$like = mysql_num_rows ($STR);//Judging the result $like greater than 0 means that the collection
}
The above results output $like can show the current user collection of each message is 1 or 0
No error in code

In the HTML file

{Loop $list $a}
$a [id]-$a [title]-........
{/loop}


the question is how to judge in the HTML file? Which means associating the $like with the ID of the list.
In the HTML $list write down the following code is unsuccessful

{Loop $list $a}
{if $like >0} is not a favorite {else} is not a collection {/if} $a [id]-$a [title]-........
{/loop}

------to solve the idea----------------------
I can't see where $like came from, and it's a single value.
If it is the one that is queried in code 1, it should be put into the $list?
$like are different for each ID and UID pair

------to solve the idea----------------------
Where did $like assign the value?
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.