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 6713109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:20:25+00:00 2026-05-26T08:20:25+00:00

I have a MySql table. I want to check its specific field in all

  • 0

I have a MySql table.
I want to check its specific field in all the rows. If this field has a specific value in any of the rows, I want PHP to print something and if any of the row doesn’t have that value, then I want PHP to do something else.

look at this code:

$queryplus="SELECT * FROM comments WHERE id='$id' and comment='plus'";
$resultplus=mysql_query($queryplus) or die(mysql_error());
while($rowplus = mysql_fetch_array($resultplus))
{
    $email3=$rowplus['email'];
    $fname3=$rowplus['fname'];
    $lname3=$rowplus['lname'];
    $email=$_SESSION['email'];
}

if ($email==$email3)
{
    echo "UNPLUS";
}
else
{
    echo "PLUS";
}

In this code, if the last row inserted has $email=$email3 then the if command executes successfully and it prints UNPLUS, but if $email=$email3 is true in any other row than the last row, the command fails to execute and prints the PLUS.

Please tell me what’s wrong in it.

NOTE: $_SESSION[’email’] is the value of the email field of another table which has the value provided by the user who is logged in at the moment.

  • 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-05-26T08:20:26+00:00Added an answer on May 26, 2026 at 8:20 am

    Try

    $queryplus="SELECT * FROM comments WHERE id='".mysql_real_escape_string($id)."' and email='".mysql_real_escape_string($_SESSION['email']."' and comment='plus'";
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php file that selects all rows in a table, i want
I have a MySql table where I want to get the count of rows
I have a table generated by PHP/mysql, I want a user to click the
Excuse the terrible question title. I have this PHP string and want to check
I have a MySQL table with an auto-incremented integer primary key. I want to
I have a mysql table which columns are post_id and post_msg. Now I want
by default I have one column in MySQL table to be NULL. I want
Basically, I have multiple URL's stored in a MySQL table. I want to pull
I have the following table: I want to insert values from the MySQL workbench.
I have a DATE datatype mysql column in a table. I want to set

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.