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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:49:48+00:00 2026-06-16T08:49:48+00:00

my query is very simple. I have a table containing name, id, date, time,

  • 0

my query is very simple.

I have a table containing name, id, date, time, in, out

all i want php to check if
salman, 001, 12/12/2012, 12:12:12, 1, 0

then insert
salman, 001, 12/12/2012, 05:12:12, 0, 1

only in and out value need to change depending if employee is in then give value in = 0 and out = 1
else if employee is out then give value to in = 1 and out = 0

i’m stuck at some place

    $insertqr = mysql_query("SELECT * FROM at_daily where daily_qr = '".$q."' and daily_date = '$today' and daily_in = '0'");//'".$today."'");
    $daily = mysql_fetch_array($insertqr);


    if($daily['daily_in'] == 0){
        mysql_query("INSERT INTO at_daily (daily_name, daily_qr, daily_date, daily_time, daily_in, daily_out)
        VALUES ('$name', '$q', '$today', '$ttime', '$myzero', '$myone')");
        echo "record entered of In";
    }
    else if($daily['daily_in'] == 1)
   {
        mysql_query("INSERT INTO at_daily (daily_name, daily_qr, daily_date, daily_time, daily_in, daily_out)
        VALUES ('$name', '$q', '$today', '$ttime', '$myone', '$myzero')");
        echo "record entered of Out";
    }
  • 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-16T08:49:50+00:00Added an answer on June 16, 2026 at 8:49 am

    I would recommend to create a single column called status instead of daily_in and daily_out columns. Use 1 for in and 0 for out in status. that way u just have to toggle between 0 and 1 using an update query.

    To toggle a value, we can make use of the common SQL control flow function IF. The IF function takes three parameters, first the test expression, the second the term to return if the test expression is true and the third being term to return if the test expression fails.

    UPDATE table SET column = IF(column = 1, 0, 1) WHERE id = ‘userid’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a very simple thing. Check out the normal sql query below
I have the following problem: on a very simple php-mysqli query: if ( $result
Hello I have a very simple question, how do we query by field name??
I have a very simple mysql query, I want to fetch some 'data' from
I have a very simple query: The variable '_dc' is the Entity Framework Code
I have a very simple query that's giving me unexpected results. Hints on where
I have a very simple query $this->db->select('id, title'); $this->db->order_by('id', 'DESC'); $query = $this->db->get('journal'); foreach($query->result()
I have a very simple linq to sql query in C#: int acctNum =
The following simple query takes a very long time (several minutes) to execute. I
I have a very simple query that I am trying to optimize. issues_notes is

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.