Hi我的網站上有一個基本的喜歡系統。基本上一旦用戶點擊,這將user_id-has_liked設置爲0.如果mysql的結果不存在回顯?
如果他們的user_id_has_liked設置爲0,它將顯示類似的鏈接,如果它設置爲1,則顯示不同。但是我想添加另一個條件,說如果結果不在mysql中,然後回顯出類似的鏈接。
有人可以告訴我在哪裏,我會添加什麼來使這發生請。
<div class="profile_likes">
<?php
$user_like_set = user_like_status();
while ($like = mysql_fetch_array($user_like_set))
if ($like['user_id_has_liked'] == '0') { ?>
<a href="like_profile.php?to=<?php echo "$profile_id"; ?>">Like</a> | <?
$count_likes_set = count_likes();
while ($likes = mysql_fetch_array($count_likes_set)) {
echo "". $likes['likes'] ." People Like ".$profile[2]."";
//$check_new_duos_set = check_new_escort_duos(); while ($newd = mysql_fetch_array($check_new_duos_set)) {
?>
<? } }?>
<?php
$user_like_set = user_like_status();
while ($like = mysql_fetch_array($user_like_set))
if ($like['user_id_has_liked'] == '1') { ?>
<a href="unlike_profile.php?to=<?php echo "$profile_id"; ?>">Unlike</a> | <?
$count_likes_set = count_likes();
while ($likes = mysql_fetch_array($count_likes_set)) {
echo "". $likes['likes'] ." People Like ".$profile[2]."";
//$check_new_duos_set = check_new_escort_duos(); while ($newd = mysql_fetch_array($check_new_duos_set)) {
?>
<? } }?>
</div>
這不會工作,因爲如果沒有找到記錄,mysql_fetch_array將返回false,因此它不會進入內部循環。 – CuriousMind 2013-02-10 14:33:08
非常真實,謝謝。如果他只是按照他的代碼建議尋找單個條目,那麼他可以用if語句取代while,並添加另一個else子句。 – Montycarlo 2013-02-10 15:08:30
所以有人可以告訴我我需要做什麼,我很困惑。謝謝 – 2013-02-10 15:11:26