Solved

Button in first row of table does not work in php file

Posted on 2014-07-25
6
205 Views
Last Modified: 2014-07-30
Hi all.

I have a php file (AllWorkSchedule.php) that has a table with rows of records. Each row has a button (button3 - "Job Complete") that when clicked redirects the user to the file myWorkSchedule.php. The problem I'm having is that when the button is clicked from the FIRST ROW it doesn't redirect to myWorkSchedule.php it just reloads the current php file (AllWorkSchedule.php), but when I click the button from the second row and any row that is not the first row it does in fact redirect to myWorkSchedule.php, this is only happening to the first row. Below is the code, what's going on with this code?

Thank you in advance.

<head>
<title>Work Schedule</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css">

<script type="text/javascript" src="js/jquery-latest.js"></script> 
<script type="text/javascript" src="js/jquery.tablesorter.min.js"></script> 
  <link rel="stylesheet" href="js/style.css" type="text/css" />


<script type="text/javascript">
$(document).ready(function() { 
    // call the tablesorter plugin 
    $("#Table").tablesorter({sortList: [[0,0], [1,0],[2,0],[3,0]]} );    
    });

</script>
</head> 

<b>WORK SCHEDULE REPORT for <?php echo $_SESSION['user']['Name'];?><p style="color:red"><-- Moved Up</p><p style="color:green">--> Moved Back</p> </b><p> <form> <input class='button14'  type='submit' formaction='Menu.php' value='Menu'/></p>
<table id="Table" class="tablesorter"> 
<thead> 
<tr> 

	<th>Builder</th>
	<th>Community</th>
	<th>Lot</th>
	<th>Block</th>
	<th>Work</th>
	<th>Schedule Date</th>
	<th>Schedule Date Change</th>
	<th>Action</th>
      
</tr> 
</thead> 
<tbody> 
 <?php foreach ($data as $row){

  if($row['OriginalWorkScheduleDate'] < $row['WorkScheduleDate'])
  {
  echo "<tr>";
  echo "<td>". html_escape($row['Builder']) . "</td>";
  echo "<td>". html_escape($row['Community']) . "</td>";
  echo "<td><a href='mySchedule.php?dataentryid=". html_escape($row['DataEntryID']) ."' >". html_escape($row['Lot']) . "</a></td>";
  echo "<td><a href='mySchedule.php?dataentryid=". html_escape($row['DataEntryID']) ."' >". html_escape($row['Block']) . "</a></td>";
  echo "<td>". html_escape($row['workscheduledescription']) . "</td>";
  echo "<td style='background-color:#00FF00'>".  html_escape($row['OriginalWorkScheduleDate']) . "</td>";
  echo "<td  style='background-color:#00FF00'>". html_escape($row['WorkScheduleDate']) . "</td>";
     echo "<td>
      <form action='myWorkSchedule.php' method='post'>         
         <input type='hidden' name='action_token1' value='" . html_escape($_SESSION['action_token1']) . "'/>
         <input type='hidden' name='DataEntryID' value='" . html_escape($row['DataEntryID']) . "'/>
         <input type='hidden' name='WorkScheduleID' value='" . html_escape($row['WorkScheduleID']) . "'/>
         <input class='button3'  type='submit'  value='Job Complete'/>
      </form>
   </td>";
  echo "</tr>";
  }
  elseif($row['OriginalWorkScheduleDate'] > $row['WorkScheduleDate'])
  {
	echo "<tr>";
  echo "<td>". html_escape($row['Builder']) . "</a></td>";
  echo "<td>". html_escape($row['Community']) . "</a></td>";
  echo "<td><a href='mySchedule.php?dataentryid=". html_escape($row['DataEntryID']) ."' >". html_escape($row['Lot']) . "</a></td>";
  echo "<td><a href='mySchedule.php?dataentryid=". html_escape($row['DataEntryID']) ."' >". html_escape($row['Block']) . "</a></td>";
  echo "<td>". html_escape($row['workscheduledescription']) . "</a></td>";
   echo "<td style='background-color:#FF0000'>". html_escape($row['OriginalWorkScheduleDate']) . "</td>";
  echo "<td style='background-color:#FF0000'>". html_escape($row['WorkScheduleDate']) . "</td>";
  echo "<td>
      <form action='myWorkSchedule.php' method='post'>         
         <input type='hidden' name='action_token1' value='" . html_escape($_SESSION['action_token1']) . "'/>
         <input type='hidden' name='DataEntryID' value='" . html_escape($row['DataEntryID']) . "'/>
         <input type='hidden' name='WorkScheduleID' value='" . html_escape($row['WorkScheduleID']) . "'/>
         <input class='button3'  type='submit'  value='Job Complete'/>
      </form>
   </td>";
  echo "</tr>";  
  }
  else
    {
	echo "<tr>";
  echo "<td>".  html_escape($row['Builder']) . "</td>";
  echo "<td>".  html_escape($row['Community']) . "</td>";
  echo "<td><a href='mySchedule.php?dataentryid=". html_escape($row['DataEntryID']) ."' >". html_escape($row['Lot']) . "</a></td>";
  echo "<td><a href='mySchedule.php?dataentryid=". html_escape($row['DataEntryID']) ."' >". html_escape($row['Block']) . "</a></td>";
  echo "<td>".  html_escape($row['workscheduledescription']) . "</td>";
   echo "<td>". html_escape($row['OriginalWorkScheduleDate']) . "</td>";
  echo "<td>".  html_escape($row['WorkScheduleDate']) . "</td>";
  echo "<td>
      <form action='myWorkSchedule.php' method='post'>         
         <input type='hidden' name='action_token1' value='" . html_escape($_SESSION['action_token1']) . "'/>
         <input type='hidden' name='DataEntryID' value='" . html_escape($row['DataEntryID']) . "'/>
         <input type='hidden' name='WorkScheduleID' value='" . html_escape($row['WorkScheduleID']) . "'/>
         <input class='button3'  type='submit'  value='Job Completes'/>
      </form>
   </td>";
  echo "</tr>";  
  }
  }?> 
</tbody> 
</table> 
</html>

Open in new window

0
Comment
Question by:Sim1980
  • 3
6 Comments
 
LVL 11

Expert Comment

by:Radek Baranowski
ID: 40219571
compare what is inside the $row corresponding to the first (not working ) and subsequent rows - there must be difference in there causing the first button to fail. maybe no data ? what does generated HTML code (in browser "show source") contain in the first row ?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40219578
Can you post the rendered HTML not the PHP
0
 

Author Comment

by:Sim1980
ID: 40219609
Ah I found what was going on: I have an opening <form> tag but did not close it. It's towards the top of my code:

Original Code:
<b>WORK SCHEDULE REPORT for <?php echo $_SESSION['user']['Name'];?><p style="color:red"><-- Moved Up</p><p style="color:green">--> Moved Back</p> </b><p> <form> <input class='button14'  type='submit' formaction='Menu.php' value='Menu'/></p>

Open in new window


Corrected Code:
<b>WORK SCHEDULE REPORT for <?php echo $_SESSION['user']['Name'];?><p style="color:red"><-- Moved Up</p><p style="color:green">--> Moved Back</p> </b><p> <form> <input class='button14'  type='submit' formaction='Menu.php' value='Menu'/>[b]</form>[/b]</p>

Open in new window

0
 

Accepted Solution

by:
Sim1980 earned 0 total points
ID: 40219614
Oops:

Corrected code:

<b>WORK SCHEDULE REPORT for <?php echo $_SESSION['user']['Name'];?><p style="color:red"><-- Moved Up</p><p style="color:green">--> Moved Back</p> </b><p> <form> <input class='button14'  type='submit' formaction='Menu.php' value='Menu'/></form></p>

Open in new window

0
 

Author Closing Comment

by:Sim1980
ID: 40228666
Solved it myself.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS grid style change 2 34
Bootstrap 3 with accordion menu 2 46
Bootstrap 3 website error 14 46
Poster Video HTML 5 Scale to fit video 3 37
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now