Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8611723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:26:44+00:00 2026-06-12T04:26:44+00:00

Here is my php code. I want to know if its possible to make

  • 0

Here is my php code. I want to know if its possible to make an if statement so it can only be viewed by the user with a user level of 1. I tried an if statement but I get an Unexpected T_STRING my database had this http://prntscr.com/glmqi cat_mod is for the if statement because it’s a moderator topic.

<?php





$sql = "SELECT
        cat_id,
        cat_name,
        cat_description
    FROM
        categories
    WHERE
        cat_id = " . mysql_real_escape_string($_GET['id']);

$result = mysql_query($sql);

if(!$result)
{
echo 'The category could not be displayed, please try again later.' .   mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{
    echo 'This category does not exist.';
}
else
{
    //display category data
    while($row = mysql_fetch_assoc($result))
    {
        echo '

<h3>You are currently in this section: <u>' . $row['cat_name'] . '<u/></h3>
</div>
  <div class="container_oro2" style="overflow: hidden;">
  Users currently viewing this section:
  </div><div class="header">
    <h3 class="header_title">Topics in this section</h3>
    <div class="header_topics">Hits</div>
    <div class="header_replies">Replies</div>
    <div class="header_action">Last Action</div>
</div><table class="container">';
    }

    //do a query for the topics
    $sql = "SELECT  
                topics.topic_id,
                topics.topic_subject,
                topics.topic_date,
                topics.topic_cat,
                topics.topic_by,
                topics.view,
                topics.reply,
                users.user_id,
                users.user_name
            FROM
                topics

            LEFT JOIN
                    users
                ON
                    topics.topic_by = users.user_id             
            WHERE
                topic_cat = " . mysql_real_escape_string($_GET['id']);

    $result = mysql_query($sql);

    if(!$result)
    {
        echo 'The topics could not be displayed, please try again later.';
    }
    else
    {
        if(mysql_num_rows($result) == 0)
        {
            echo 'There are no topics in this section yet.';
        }
        else
        {
            //prepare the table



            while($row = mysql_fetch_assoc($result))
            {               
                echo '




                <tr class="altcolor_2">';

            echo '<td class="title">';
            echo '  <table>';
                    echo '<tr>';
                        echo '<td class="title_icon_small">
                            <img src="http://www.naruto-boards.com/images/forum/topic_old.gif" alt="" />                            </td>
                        <td class="title_icon_small">
                            <img src="http://www.naruto-boards.com/images/forum/topic_sticky.gif" alt="" />                             </td>
                        <td class="title_title">';
                            echo '<h4 class="inline"><a href="/index.php?area=topic&id=' . $row['topic_id'] . '">' . $row['topic_subject'] . '</a>   ';                                          echo '<img class="pages" src="http://naruto-boards.com/images/forum/topic_paging.gif"  alt="" /> </h4> ';
                            echo'<span>Started on ';  echo date(" F j, Y, g:i A", strtotime($row['topic_date'])); echo' by <a  href="/profile/kross/" class="profilelink"></a></span>';
                        echo '</td>';
                    echo '</tr>';
                echo '</table>';

            echo '</td>';
            echo '<td class="info1">' . $row['view'] . '</td>';
            echo '<td class="info1">' . $row['reply'] . '</td>';
            echo '<td class="info2">
                <div>';
                    echo'Date: ';echo date(" F j, Y, g:i A", strtotime($row['topic_date']));echo'<br />';
                    echo 'By: <a href="/profile/igi33/"  class="profilelink"></a>';

                echo '</div>';
            echo '</td>';
        echo '</tr>';
        echo '<tr class="spacer"><td colspan="4"></td></tr>


';








            }
        }
    }
}
}


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:26:46+00:00Added an answer on June 12, 2026 at 4:26 am

    Try adding an if at the end of the $sql, before the $result = ....

    if ($user_level != 1) { $sql .=  " AND `cat_mod` = 0";}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php while(true){ //code goes here..... } ?> I want to make a PHP web
I want a php page to 'display' a pdf. Here is the code: <?php
Here's my php code: <?php if($user->uid == '1'){ ?> <h3 class=info>Upcoming Games</h3> <!--MY CHANGE
Here is the code I dont know whats wrong with it. <?php //Logout code
I am modifying my PHP network's code to have user roles like wordpress here
Here is my PHP code.. $input = zergling-light $output = str_replace('-', ' (', $input).);
here is my mysql and php code layout: I have 3 tables tableA stores
So I have some PHP code that looks like: $message = 'Here is the
I am completely stumped. Here is my php (CodeIgniter) code: function mod() { $uid
For example, my goal is to test the code given here: PHP script that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.