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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:18:46+00:00 2026-06-11T02:18:46+00:00

$q1 = mysql_query(select in_time, out_time from $att_tbl where fk_eid = ‘$e_id’ and a_date =

  • 0
$q1 = mysql_query("select in_time, out_time  from $att_tbl where fk_eid = '$e_id' and a_date = '$dts'");
$r1 = mysql_fetch_array($q1);
$intime = $r1['in_time'];
$outtime = $r1['out_time'];

In the above code ‘$e_id’ is a normal id used to specify users and ‘$dts’ is date in the format YYYY-MM-DD . But when i use this code it halts my parent while loop and if i comment this code my while loop runs fine. I have never seen such behavior. Why is this happening? What is wrong with this code ?

EDIT : this is the full rough code

$q1 = mysql_query("select ids from $emp_data where lft = '0' order by emp_id");
while($r1 = mysql_fetch_array($q1))
{
$e_id = $r1['ids'];
$htmldata = '';
$filename = "$e_id-$months-$years.html";
$date =time () ;
$day = date('d', $date) ;
$month = date('m', $date) ;
$year = date('Y', $date) ;
$first_day = mktime(0,0,0,$month, 1, $year) ;
$title = date('F', $first_day) ;
$day_of_week = date('D', $first_day) ; 
$today = date('Y-m-d', strtotime('today'));
$yesterday = date('Y-m-d', strtotime('yesterday')); 
$day_before_yesterday = date('Y-m-d', strtotime('yesterday - 1 day'));

switch($day_of_week)
{   
 case "Sun": $blank = 0; break; 
 case "Mon": $blank = 1; break; 
 case "Tue": $blank = 2; break; 
 case "Wed": $blank = 3; break; 
 case "Thu": $blank = 4; break; 
 case "Fri": $blank = 5; break; 
 case "Sat": $blank = 6; break; 
}
$days_in_month = cal_days_in_month(0, $month, $year) ; 
$htmldata.="<link rel=\"stylesheet\" href=\"/cal.css\" type=\"text/css\"><table id=\"mct1\" class=\"ct1 cl1 cp4 cd2 mct\" cellspacing=0>";
$htmldata.="<tr><th> $title $year </th></tr>";
$htmldata.="<tr><td class=\"cbm cba cmi\"><table class=\"ca ca2\"><tr class=\"cl\"><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td class=\"cr\">Sat</td></tr>";
$day_count = 1;
$htmldata.="<tr>";
while ( $blank > 0 ) 
{ 
    $htmldata.="<td>&nbsp;</td>"; 
    $blank = $blank-1; 
    $day_count++;
} 
$day_num = 1;
while ( $day_num <= $days_in_month ) 
{ 
    $dts = date("Y-m-d", strtotime("$year-$month-$day_num"));
    if(strtotime($dts) <= strtotime($today))
    {
        // $q1 = mysql_query("select in_time, out_time  from $att_tbl where fk_eid = '$e_id' and a_date = '$dts'");
        // $r1 = mysql_fetch_array($q1);
        // $intime = $r1['in_time'];
        // $outtime = $r1['out_time'];
    }
    $bgclr = '';
    $weekday = date('D', strtotime($year."-".$month."-".$day_num));
    if($weekday == 'Sun')
    {
        $bgclr = "bgcolor = \"pink\"";
    }
    $htmldata.="<td class=\"cr\" $bgclr><div class=\"ccd co4\">$day_num <br><font size=\"2\"> $intime <br> $outtime </font></div></td>"; 
    $day_num++; 
    $day_count++;
    if ($day_count > 7)
    {
        $htmldata.="</tr><tr>";
        $day_count = 1;
    }
} 
while ( $day_count >1 && $day_count <=7 ) 
{
    $htmldata.="<td>&nbsp;</td>"; 
    $day_count++; 
} 
$htmldata.="</tr></tbody></table></td></tr></table>"; 

$myFile = "$filename";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $htmldata;
fwrite($fh, $stringData);
fclose($fh);
}

I have commented the code that is halting the whole while loop so that it can be easily seen

  • 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-11T02:18:48+00:00Added an answer on June 11, 2026 at 2:18 am

    Your script could have been halted due to the fact that in_time and out_time do not exist in your array. Otherwise, there is no problem to your query unless you tell us what you have been assigning to the variables.

    As I have mentioned in the comments, check in the error_log file, which resides in the same directory as this PHP script.

    Also, is your parent loop also something along the lines of:

    while ($foo = @mysql_fetch_array($q1))

    If it is, then that might be your error. You are resetting the value of $q1 inside the while loop, therefore possibly terminating the loop.

    UPDATE: Now that you posted your code, I know your exact error:

    These are your first two lines of code, used to run the main while loop:

    $q1 = mysql_query("select ids from $emp_data where lft = '0' order by emp_id");
    while($r1 = mysql_fetch_array($q1))
    

    Notice that you used $q1 to reference the query. Now down in that piece of code, inside a nested while loop:

    $q1 = mysql_query("select in_time, out_time  from $att_tbl where fk_eid = '$e_id' and a_date = '$dts'");
    

    You used $q1 again. The interpreter thought that you meant to change the variable value, but instead you wanted to initialize another variable called $q1.

    Okay, after all that, all you need to do is write this for your code:

    $q2 = mysql_query("select in_time, out_time  from $att_tbl where fk_eid = '$e_id' and a_date = '$dts'");
    $r2 = mysql_fetch_array($q2);
    $intime = $r2['in_time'];
    $outtime = $r2['out_time'];
    

    And just change your references anywhere else.

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

Sidebar

Related Questions

My code $sql=SELECT * FROM `room_lists`; $sqlquery = mysql_query($sql); while($result = mysql_fetch_array($sqlquery)){ $toDay =
I create a json encode in PHP like this: $get = mysql_query(SELECT * FROM
I am using mysql_query(INSERT INTO imaegs_backup SELECT * FROM images); in order to copy
include(conn.php); $result = mysql_query(SELECT * FROM sggame); while($row = mysql_fetch_assoc($result)); { $id = $row['id'];
Is it possible to write this query in codeigniter active records? $Main_Nav_Query = mysql_query(SELECT
How can i display variable only once in the table. <?php $sql = mysql_query(SELECT
GOT error for the following query in MYSQL(version5.1) SELECT year,month,sum(fact_1),sum(fact_2),sum(fact_3),sum(fact_4) from( select year,month,fact_1,fact_2,0 as
Possible Duplicate: How to select all records from table apart from the last 100
I have a nested SQL query : SELECT DISTINCT(topic_id) FROM bb_posts WHERE topic_id NOT
I am interested in theoretical Big-O analysis of the following MySQL query: SELECT id,

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.