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?