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?