Solved

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

Posted on 2014-07-25
6
196 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
Comment Utility
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
Comment Utility
Can you post the rendered HTML not the PHP
0
 

Author Comment

by:Sim1980
Comment Utility
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
Comment Utility
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
Comment Utility
Solved it myself.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses how to create an extensible mechanism for linked drop downs.
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 …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

744 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

18 Experts available now in Live!

Get 1:1 Help Now