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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:27:37+00:00 2026-06-19T01:27:37+00:00

I want to display values retrieved from mysql in forms and in row by

  • 0

I want to display values retrieved from mysql in forms and in row by row format.
So i used the following code.

<?php 
  while($rows1 = mysql_fetch_array($result1)){ 
?>
<tr height="30" > 
<?php $elyid = $rows1['id'] ?>
  <form action="leaveactions.php" method="post" name="viewleave">
   <td width="82"><?php echo $rows1['empid'];?></td>
   <td><?php echo $rows1['name'];?></td>
   <td><?php echo $rows1['leavetype'];?></td>
   <td width="82"><?php echo $rows1['startdate']; ?></td>
   <td width="82"><?php echo $rows1['enddate']; ?></td>
   <td><?php echo $rows1['leavetype']; ?></td>
   <td>
     <input type="submit" name="<?php $rows1['id']; ?>" value="accept"/>
   </td>
   <td>
     <input type="submit" name="reject" value="reject"/>
     <input type="hidden" name="emplid" value="<?php echo $rows1['id'] ?>"/>
   </td>
</tr>
<?php       } ?>

and in leaveactions.php

$ii=0;
$query1 = "select * from applied_leaves where supervisorid ='".$employeeId."' and status='not approved'";
$result1 = mysql_query($query1) or die (mysql_error());
$num1 = mysql_numrows($result1);

while($rows1 = mysql_fetch_array($result1)) {
  $ii++;
  echo $_POST["$ii"];
  if(isset($_POST['$ii'])){
    echo "accepted "; echo $_POST['$ii'];
    $updateEmp = "update applied_leaves set status='".$accept."' where id='$ii' " ;
    $uresult = mysql_query($updateEmp) or die (mysql_error());
    if($uresult != null){
      echo "Assignment Added successfully<br>";
?>
      <a href="updateassignment.php">View Added Details</a>
<?php                       
    } else {
      echo "error";
    }
  }
}
?>

but when run i get

 Notice: Undefined offset: 1
 Notice: Undefined offset: 2
.
.
.
.
.
.

like that.
Please help me solving the problem.
Thanks in Advance

EDIT

the new code that is causing exception is

                     $iii=0;
                while($rows1 = mysql_fetch_array($result1))
                {
                  $iii++;

                if(  $_POST["accpt".$iii] ) { 

                  echo "accepted "; 
                  $updateEmp = "update applied_leaves set status='".$accept."' where id='$iii' " ;
                  $uresult = mysql_query($updateEmp) or die (mysql_error());
                  if($uresult != null){
                        echo "Assignment Added successfully<br>";
                        ?>
                        <a href="updateassignment.php">View Added Details</a>
                        <?php   break;                  
                    }

                }

                }
  • 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-19T01:27:38+00:00Added an answer on June 19, 2026 at 1:27 am

    I think your main error lies here:

    <input type="submit" name="<?php $rows1['id']; ?>" value="accept"/>
    

    Here you do not echo $rows1['id'], so if you have a look in the generated code, the name should be empty.

    Correct this to

    <input type="submit" name="<?php echo $rows1['id']; ?>" value="accept"/>
    

    Furthermore in leaveactions.php you have the following code:

    // ...
    echo $_POST["$ii"];
    if(isset($_POST['$ii'])){
      echo "accepted "; echo $_POST['$ii'];
    // ...
    

    Here you should first check, whether the variable (here it is $_POST[$ii] – no " needed) before doing the output.

    As a result of the previous error, $_POST[$ii] is not set, thus you get the notice on the first echo and never enter the if-clause afterward.

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

Sidebar

Related Questions

I want to display different forms in change_form depending on some model field's values.
I am getting Arabic text from server successfully. Retrieved text I want display in
I want to display a timestamp value catched from DB by using a php
I have following json format. I want to display each field in html. How
sources: display data from XML using php simplexml Get attributes and values using SimpleXML
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
I am using QTableView to display data retrieved from QtSql.QSqlQuery I want to know
I want to display three different values allocated to two different headers, in other
I want to display all the possible enum values as Radio buttons. I am
I want to display digits with leading 0s, for values of a single digit,

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.