-1

現時点では、ユーザーのレビューを取得するスクリプトがあります。そのユーザーのレビューがなく、ユーザーがログインしていない場合は、次のようにエコーされます。

  <?
    }

       }else{
          if (!logged_in()) {   
              echo "<div class=\"infobox-noreviews\"><i>{$profile['display_name']
          }   
        doesn't currently have any reviews.<br/>To post a review to his wall,
        <a href=\"loginframe.php\" rel=\"shadowbox;height=300;width=500\">Login</a>
        &nbsp;now.
        </i></div>
        <div class=\"example_review\"><div class=\"example_review_pic\">
          <img width=50px height= 50px src=\"data/photos/0/review.jpg\"/>
        </div>
        <div class=\"example_review_text\">e.g. I had an amazing time. Defo going to be               meeting again.
        <br/><br/>Thanks Larry x</div><div class=\"example_review_pic2\">
        </div></div>
        <div class=\"example_box_container\"><div class=\"review_example_arrow\"></div>
        <div class=\"review_example_box\"></div><div class=\"review_example_text\">   <strong>Here's an Example</strong>
        </div></div>";
    }
    $account_type = account_type();
    if ($acctype['account_type'] == 'member') {
         echo "<div class=\"infobox-noreviews\"><i>{$profile['display_name']
     }
     doesn't currently have any reviews.<br/>Why not post a review to his wall now.</i>   </div>";
   }
     $account_type = account_type();

     if ($acctype['account_type'] == 'user') {
       echo "<div class=\"infobox-noreviews\"><i>{$profile['displays_name']
      } 
     doesn't currently have any reviews.<br/>Sorry but users cannot post Reviews.</i>  </div>";


   }

  }

 ?>

それ以外の場合、ユーザーレビューはログインユーザーとログアウトユーザーの両方に一覧表示されます。ただし、ユーザーがログインしていてレビューがない場合は、上記のスクリプトもエコーアウトされるようにする必要もあります。私はこれをやろうとしましたが、それを行う方法を理解できません。

誰かが私を助けて、私に何ができるかを見せてくれませんか。ここに私のスクリプトをありがとう:

<div class="reviewcontent">
    <?php if ($user['account_type'] == "user"){
    ?>
    <?php
     $days = $reviews['date_added'];

    function days_from_date($days) {


           $age = date_diff(date_create($days), date_create('now'))->d;  
           return $age;
    }

    ?>

    <div class="reviewcontent1">
    <?php
        $reviews_set = get_reviews();
        ?>
        <br/>
        <h3>Latest Reviews</h3>
        <br/> 

        <?php
        if(mysql_num_rows($reviews_set) > 0) {
            while ($reviews = mysql_fetch_array($reviews_set)) {
                $age = days_from_date($reviews['date_added']);
                ?>
                <div class="reviewcase" id="reviewcase">
                 <div class="review-content">
                 <?php echo "{$reviews['content']}"; ?>
                 </div>
                 <div class="message_pic">
                 <?php echo "<a href=\"profile.php?id={$reviews['from_user_id']}\"><img width=\"50px\" height=\"50px\"  src=\"{$prof_photo}\"></a>";?>

                 </div>

                 <div class="reviews_footer">
                 <?php echo "Posted by {$reviews['display_name']}"; ?>&nbsp;<?
            $datetime1 = new DateTime();
            $datetime2 = new DateTime ($reviews['date_added']);
            $interval = $datetime1->diff($datetime2);
            $mdhms = explode('-',$interval->format('%m-%d-%H-%i-%s'));

    $labels = Array(' months', ' days', ' hours', ' minutes', ' seconds');
    $i = 0;
    foreach($mdhms as $t){
      if($t > 0) break;
      $i+=1;
    }
            echo "about ".$t.$labels[$i]." ago"; ?>





              </div>

                 </div>




                 <?
            }

            }else{



        if (!logged_in()) {


    echo "<div class=\"infobox-noreviews\"><i>{$profile['display_name']} doesn't currently have any reviews.<br/>To post a review to his wall, <a href=\"loginframe.php\" rel=\"shadowbox;height=300;width=500\">Login</a>&nbsp;now.</i></div>
    <div class=\"example_review\"><div class=\"example_review_pic\"><img width=50px height= 50px src=\"data/photos/0/review.jpg\"/>
    </div><div class=\"example_review_text\">e.g. I had an amazing time. Defo going to be meeting again.<br/><br/>Thanks Larry x</div><div class=\"example_review_pic2\"></div></div><div class=\"example_box_container\"><div class=\"review_example_arrow\"></div><div class=\"review_example_box\"></div><div class=\"review_example_text\"><strong>Here's an Example</strong></div></div>";
        }

        $account_type = account_type();

         if ($acctype['account_type'] == 'member') {
    echo "<div class=\"infobox-noreviews\"><i>{$profile['display_name']} doesn't currently have any reviews.<br/>Why not post a review to his wall now.</i></div>";


     }
     $account_type = account_type();

     if ($acctype['account_type'] == 'user') {
    echo "<div class=\"infobox-noreviews\"><i>{$profile['displays_name']} doesn't currently have any reviews.<br/>Sorry but users cannot post Reviews.</i></div>";


            }

            }

    ?>



    <?

    }  
    ?>
    <?php

    {?>      


    <?php
    if (logged_in() != '') {
    $account_type = account_type();
    while ($acctype = mysql_fetch_array($account_type)) 

     if ($acctype['account_type'] == 'member')  { 

     ?>




     <?php 
    // check if the review form has been sent
    if(isset($_POST['review_content']))
    {
        $content = $_POST['review_content'];
            //We remove slashes depending on the configuration
            if(get_magic_quotes_gpc())
            {
                    $content = stripslashes($content);
            }
            //We check if all the fields are filled
            if($_POST['review_content']!='')
            {


                {
                $sql = "INSERT INTO ptb_reviews (id, from_user_id, to_user_id, content) VALUES (NULL, '".$_SESSION['user_id']."', '".$profile_id."', '".$content."');";
                mysql_query($sql, $connection);

                echo "<div class=\"infobox-profile4\"><strong>Thank You</strong> - Your review has been sent for approval.</div>";
            } }
    }

    ?> 


     <?php if(isset ($_SESSION['user_id'])) { ?>
    <div class="review-input-case">
    <div class="reviewcase" id="reviewcase">
    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">Review user:<br /><textarea name="review_content" rows="4" maxlength="120" class="review_input_box" style="resize: none;"></textarea><input name="add_review" type="submit" class="review_submit"value="Add Review" /></form>
    </div>
    </div>

    <?php } } }  ?>




    <?php
    if (logged_in() != '') {
    $account_type = account_type();
    while ($acctype = mysql_fetch_array($account_type)) 

     if ($acctype['account_type'] == 'user')  { ?>




     <?php 
    // check if the review form has been sent
    if(isset($_POST['review_content']))
    {
        $content = $_POST['review_content'];
            //We remove slashes depending on the configuration
            if(get_magic_quotes_gpc())
            {
                    $content = stripslashes($content);
            }
            //We check if all the fields are filled
            if($_POST['review_content']!='')
            {


                {
                $sql = "INSERT INTO ptb_reviews (id, from_user_id, to_user_id, content) VALUES (NULL, '".$_SESSION['user_id']."', '".$profile_id."', '".$content."');";
                mysql_query($sql, $connection);

                echo "<div class=\"infobox-profile4\"><strong>Thank You</strong> - Your review has been sent for approval.</div>";
            } }
    }

    ?> 


     <?php if(isset ($_SESSION['user_id'])) { ?>
    <div class="review-input-case">
    <div class="reviewcase" id="reviewcase">
    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">Review user:<br /><textarea name="review_content" rows="4" class="review_input_box" style="resize: none;" disabled="yes" placeholder="user Profiles Cannot Leave Reviews."></textarea><input name="add_review" type="submit" class="review_submit" value="Add Review" disabled="yes"/></form>
    </div>
    </div>

    <?php } } }  ?>


    <?php
    if (!logged_in()) { ?>
    <div class="review-input-case">
         <div class="reviewcase" id="reviewcase">
    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">Review user:<br /><textarea name="review_content" rows="4" class="review_input_box" style="resize: none;" disabled="yes" placeholder="You must be logged in to leave this user a Review."></textarea><input name="add_review" class="review_submit" type="submit" value="Add Review" disabled="yes"/></form>
    </div></div>


    <? } }?>

    </div>
    </div>
4

1 に答える 1

0
$query = mysql_query("SELECT reviews FROM users WHERE userid=$id");  
  if(mysql_num_rows($query)<1)
    {
       include('the file with  first code');
       // or
       // echo 'the first code';
    }
else
{

}
于 2013-02-09T13:55:54.627 に答える