Solved

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

Posted on 2014-07-25
6
207 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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 …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

803 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