?
Solved

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

Posted on 2014-07-25
6
Medium Priority
?
225 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

765 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