We help IT Professionals succeed at work.
Get Started

Inserting results of While loop to sql server

peter Ojeda
peter Ojeda asked
on
143 Views
Last Modified: 2017-03-23
Hello experts, I am using the while loop below to populate a table with results from my sql server database. The while loop does its purpose of populating the table, but what I am attempting to do is pull the data from this php page to another php page where an update query is located.
I believe a better format for my question would be How to assign values to text inputs generated in a while loop
Below I am posting the code I am using to pull the data from php to populate the table, You can see I am populated text inputs(which is working) , but do not know how to assign a name to the text boxes after the first record is echo'd. I will provide an image to try to clear what I am saying up.

<table width="500" border="1" id="myTable">
  <tr>

    <th width="91" height="50"> <div align="center">DATE</div></th>
    <th width="91"> <div align="center">CREW</div></th>
    <th width="91"> <div align="center">SHIFT</div></th>
    <th width="91"> <div align="center">LINE</div></th>
    <th width="20PX"> <div align="center">#</div></th>
    <th width="91"> <div align="center">Light Station</div></th>
    <th width="91"> <div align="center">Packer</div></th>
    <th width="91"> <div align="center">Packer</div></th>
    <th width="91"> <div align="center">Packer</div></th>
    <th width="91"> <div align="center">Packer</div></th>
    <th width="91"> <div align="center">Palletizer</div></th>
    <th width="91"> <div align="center">Reliever</div></th>



  </tr>

<?php
while($result = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC))
{
?>
  <tr>
	<td align="center"  height="50" width="120PX" nowrap> <?php if ($result["DATE"]!= NULL ){echo $result["DATE"] ->format("Y-m-d") ;}?></td>
	<td align="center" width="120px" height="50"  nowrap> <?php echo $result["CREW"];?></td>
	<td align="center" width="10px" height="50"  nowrap> <?php echo $result["SHIFT"];?></td>
	<td align="center" width="50px" height="50"  nowrap><INPUT TYPE="TEXT" NAME="LINE" VALUE=" <?php echo $result["LINE"];?>"></td>
	<td align="center" width="20px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="LINE_NUM" VALUE="<?php echo $result["LINE_NUM"];?>"></td>
	<td align="center" width="140px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_1" VALUE="<?php echo $result["PERSON_1"];?>"></td>
	<td align="center" width="140px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_2" VALUE="<?php echo $result["PERSON_2"];?>"></td>
	<td align="center" width="140px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_3" VALUE="<?php echo $result["PERSON_3"];?>"></td>
	<td align="center" width="140px"height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_4" VALUE="<?php echo $result["PERSON_4"];?>"></td>
	<td align="center" width="140px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_5" VALUE="<?php echo $result["PERSON_5"];?>"></td>
	<td align="center" width="140px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_6" VALUE="<?php echo $result["PERSON_6"];?>"></td>
	<td align="center" width="140px" height="50"  nowrap> <INPUT TYPE="TEXT" NAME="PERSON_7" VALUE="<?php echo $result["PERSON_7"];?>"></td>





  </tr>

<?php
}
?>

Open in new window

EXPERTEXCHEANGE.PNG
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE