Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Need Help In Displaying Confirm Button On The Last Loop Data

align loop

  • Please log in to reply
3 replies to this topic

#1 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 16 May 2012 - 12:42 AM

Hi..

I have while loop inside while loop and I need to add confirm button on the last loop data.

here is my code:

<?php
error_reporting(0);
date_default_timezone_set("Asia/Singapore"); //set the time zone
$con = mysql_connect('localhost', 'root','');
if (!$con) {
echo 'failed';
die();
}
mysql_select_db("mes", $con);
$Date_Shelve =date('Y-m-d H:i:s');
?>
<html>
<head>
<title>Job Order</title>
<link rel="stylesheet" type="text/css" href="kanban.css" />
<style type="text/css">
#SR_date{
position: relative;
font-family: Arial, Helvetica, sans-serif;
font-size: .8em;
margin-left: 10px;
margin-right: 770px;
width: auto;
height: auto;
float: left;
top : 10px;
}
#disp_btn{
position: relative;
font-family: Arial, Helvetica, sans-serif;
font-size: .8em;
margin-left: 10px;
top: 10px;
}

#disp{
position: relative;
font-family: Arial, Helvetica, sans-serif;
font-size: .8em;
margin-left: 10px;
top: 10px;
}
table {
margin: 12px;
margin-left: 3px;
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
border: 1px solid #DDD;
}
th {
font-family: Arial, Helvetica, sans-serif;
font-size: .9em;
background: #694;
color: #FFF;
padding: 2px 6px;
border-collapse: separate;
border: 1px solid #000;
}
td {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
border: 1px solid #DDD;
text-align: left;
}
table.mytable { margin: 12px;
margin-left: 3px;
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
border: 1px solid #678b3f;
}
table.mytable th { font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
background: #694;
color: #FFF;
padding: 2px 6px;
border-collapse: separate;
border: 1px solid #000; }
table.mytable td { font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
/* border: .1em solid #DDD;*/
border:none;
text-align: left; }
</style>
</head>
<body>
<div style="position: fixed;width: 1012px;">
<table>
<th style="width:72px;position: fixed;"> JO No.</th>
<th style="width:72px;position: fixed;"> ETD </th>
<th style="width:195px;position: fixed;"> PO No. </th>
<th style="width:108px;position: fixed;"> SKU Code </th>
<th style="width:220px;position: fixed;"> Description </th>
<th style="width:72px;"> Qty Req </th>
<th style="width:55px;"> Lines </th>
<th style="width:80px;"> Status</th>
</table>
</div>
<div style='overflow:auto; height:200px;'>
<table class="mytable">
<?php
$sql = "SELECT jo_number, ETD, PO_No, SKUCode, Description, POQty, Priority, Status, line
FROM job_order ORDER BY jo_number, ETD";
$res_jo = mysql_query($sql,$con);
while($row_job = mysql_fetch_assoc($res_jo)){
// echo "<tbody>";
echo "<tr>
<td><input type='text' name='JO_No_' id='JO_No_' value='$row_job[jo_number]' style='border:none;width:auto;' size='10' readonly='readonly'></td>
<td><input type='text' name='ETD_' id='ETD_' value='$row_job[ETD]' style='border:none;width:auto;' size='10' readonly='readonly'></td>
<td><input type='text' name='PO_No_' id='PO_No_' value='$row_job[PO_No]' style='border:none;' size='32' readonly='readonly'></td>
<td><input type='text' name='SKUCode_' id='SKUCode_' value='$row_job[SKUCode]' style='border:none;' size='15' readonly='readonly'></td>
<td><input type='text' name='Description_' id='Description_' value='$row_job[Description]' style='border:none;' size='35' readonly='readonly'></td>
<td><input type='text' name='POReq_' id='POReq_' value='$row_job[POQty]' style='border:none;width:auto;' size='10' readonly='readonly'></td>
<td><input type='text' name='line' id='line' value='$row_job[line]' style='border:none;width:auto;' size='7' readonly='readonly'></td>
<td><input type='text' name='priority_' value='$row_job[Priority]' id='priority_' style='border:none;width:auto;' size='11' readonly='readonly'></td>
</tr>" ;

$sql = "SELECT pcode, lotcode, qty FROM jo_dump WHERE jo_number = '$row_job[jo_number]' ORDER BY date_entry ASC";
$res_dump = mysql_query($sql, $con);
while($row_dump = mysql_fetch_assoc($res_dump)){
echo "<tr>";
echo "<td>&nbsp;</td>";
echo "<td>&nbsp;</td>";
echo "<td><input type='text' name='lotcode' value='$row_dump[lotcode]' style='border:none;width:auto;' size='10' readonly='readonly'></td>";
echo "<td><input type='text' name='pcode' value='$row_dump[pcode]' style='border:none;width:auto;' size='15' readonly='readonly'></td>";
echo "<td>&nbsp;</td>";
echo "<td><input type='text' name='qty' value='$row_dump[qty]' style='border:none;width:auto;' size='10' readonly='readonly'></td>";
echo "</tr>";
}

}
echo "</table>";
echo "</div>";
?>
</body>
</html>

and I attach the image of output of this code.
Thank you

Attached Thumbnails

  • loop.JPG

  • 0

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 16 May 2012 - 01:36 AM

you could replace the while for a for lool, like this :

. you have to use a counter, so at any row you use a row accumulater, that could be called $row_job_number, and $row_dump_number
. you compare the row counters with the query results lenght ( with count( ) )

so, in the las </TR> print you check for the end of both arrays, and if so you do your confirm button print

something like this :

// if it is the last row
if ( $row_job_number >= (count($res_jo)-1) &&
$row_dump_number >= (count($res_dump) )
{
// do the echo of the confirm button
}

echo "</tr>";
  • 0

#3 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 16 May 2012 - 04:41 AM

you can put the Confirm button after all the loop and just use absolute positioning in CSS so you can place it in anywhere you would like.

something like this


while {

    while {

     }
}

//confirm button here

that's the simplest solution that you can use :)
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#4 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 16 May 2012 - 06:39 PM

Thank you
  • 0





Also tagged with one or more of these keywords: align, loop

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download