Php list page to determine whether to hide-php Tutorial

Source: Internet
Author: User
The php list page determines whether to add this post to favorites. at the end, the $ list & nbsp; is an array & nbsp; data containing each piece of information in the php file edited by mf0916 from 2015 to 10-22:54:06, then write the following code; foreach ($ list & nbsp; as & nbsp; $ value) {$ idintval ($ val php list page to determine whether to add to favorites

This post was last edited by mf0916 at 18:54:06

In the php file

// $ List is an array containing each piece of information, and then write the following code;
Foreach ($ list as $ value ){
$ Id = intval ($ value ['id']); // information id in the list
$ Uid = intval ($ ['uid']); // ID of the currently logged-on user
$ Str = // query the database where likeid = '$ ID' and uid =' $ uid'; // do you have a user id and current information ID?
// This is the query condition. the specific code will not be written (⊙ ﹏ ⊙) B
$ Like = mysql_num_rows ($ str); // The determined result $ like is greater than 0, indicating that it has been added to the Favorites folder.
}
// The output of the above result $ like can display each piece of information. the current user's favorites is 1 or 0.
// No code error

In an html file

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


The problem is how to judge in an html file? That is to say, associate $ like with the List ID.
// Failed to write the following code in $ list in html:

{Loop $ list $}
{If $ like> 0} has been added to {else}. {/if} $ a [id]-$ a [title]-......
{/Loop}

------ Solution ----------------------
It cannot be seen where $ like comes from, and it is a single value.
If it is the one found in code 1, should it be put into $ list?
For each id and uid, $ like is different.

------ Solution ----------------------
Where is $ like assigned?

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.