Solved

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

Posted on 2014-07-25
6
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
alert on input text 2 40
Hide and Unhide Table 6 42
Calculating percentage 2 47
center text in div with CSS3 2 29
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 i…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

737 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