I want that update button should be in that field which I choose.But it appears only in first row and is updating for first row quantity field.
<form action="cart.php?action=update" method="post">
<table>
<tr>
<th colspan="2">ITEM</th>
<th>QUANTITY</th>
<th>PRICE</th>
<th>SUBTOTAL</th>
<th>REMOVE</th>
</tr>
<?php
$query = "select * from cart where customer_id='$user' ";
$result = mysqli_query($con,$query);$b = 0;$c = 0;
while($row = mysqli_fetch_array($result))
{
$productid = $row['product_id'];
$query2 = "select * from product where product_id='$productid'";
$result2 = mysqli_query($con,$query2);
while($row2=mysqli_fetch_array($result2))
{
?>
<tr>
<td rowspan="3"><img src="upload/<?php echo $row2['pimage']; ?>" height="50px" width="50px"></td>
<td rowspan="3"><?php echo $row2['pname']; ?></td>
<td rowspan="3">
<input tpe="text" name="newqty" value="<?php echo $qty = $row['quantity']; ?>" onkeypress="showsubmit()">
<input style="visibility:hidden;width:80px;border-radius:10px;background-color:green;border:none;padding:5px;color:white;" type="submit" name="sub1" id="sub1" value="UPDATE">
<input type="hidden" name="hidcartid" value="<?php echo $row['cart_id'] ?>"/>
<input type="hidden" name="hidproductid" value="<?php echo $row['product_id']; ?>"/>
<script>
function showsubmit()
{
document.getElementById("sub1").style.visibility = "visible";
}
</script>
</td>
<td>Price:<?php echo $sp = $row2['psellingprice']; ?></td>
<?php
$total = $sp * $qty;
?>
<td rowspan="3">
<?php
echo $t = $total;
$b = $b + $t;
?></td>
<td rowspan="3">REMOVE</td>
</tr>
<?php
$action = ( array_key_exists( 'action', $_REQUEST) ? $_REQUEST['action'] : "" );
if($action =="delete")
{
deletecart($_REQUEST['cid']);
}
if($action=="update")
{
echo "update function called";
updatecart();
echo "update function executed";
}
?>
<tr>
<td>Selling Price:<?php echo $p = $row2['pprice']; ?></td>
</tr>
<tr>
<td>You Saved:
<?php
$d = $row2['pdiscount'];
$s = ($p*$d)/100;
echo $q = $s * $qty;
$c = $c + $q;
?> rs.</td>
</tr>
<?php
}
}
?>
</table>
and cart2.php
<?php
function deletecart($cartid)
{
include 'connection.php';
$sql1="delete from cart where cart_id=$cartid";
$executequery = mysqli_query($con,$sql1);
header('location:cart.php');
}
function updatecart()
{
include 'connection.php';
$cartId = $_POST['hidcartid'];
$productId = $_POST['hidproductid'];
$newqty = $_POST['newqty'];
echo("inside update function");
// update product quantity
$sql = "UPDATE cart
SET quantity = $newqty
WHERE cart_id = $cartId";
mysqli_query($con,$sql);
header('location:cart.php');
}?>
For row onw everything is fine.But for row2 update button appears in row1 and not updating at all.
<input tpe="text" name="newqty" value="<?php echo $qty = $row['quantity']; ?>" onkeypress="showsubmit(<?php echo $row['cart_id'] ?>)">
<input style="visibility:hidden;width:80px;border-radius:10px;background-color:green;border:none;padding:5px;color:white;"
type="submit"
name="sub_<?php echo $row['cart_id'] ?>"
id="sub_<?php echo $row['cart_id'] ?>"
value="UPDATE">
<script>
function showsubmit(id)
{
document.getElementById("sub_"+id).style.visibility ="visible";
}
</script>
Related
I want to show a sweetalert after clicking the set button but it won't function. This is my index page and the set button can function but it won't show the sweet alert. what might be the problem and what should I do?
index.php
<form method='post' action='updataStatus.php'>
<button type='submit' name='but_update' class="inline-block float ml-2 mt-1 btn-group pull-right btn-danger btn-sm">SET</button><button type="submit" id="dataExport" name="dataExport" value="Export to excel" class="inline-block float ml-2 mt-1 btn-group pull-right btn-info btn-sm">Export</button>
<div class="table-responsive">
<br>
<tbody><table class="table table-hover table-bordered" id="sampleTable2">
<thead>
<tr>
<th><input type="checkbox" class="select-all checkbox" name="select-all" id="checkAll" /></th>
<th>Name</th>
<th>Scholarship Program</th>
<th>Course</th>
<th>Semester</th>
<th>Allowance</th>
</tr>
</thead>
<?php
require_once "connection.php";
$query = "SELECT * FROM allowance";
$result = mysqli_query($conn,$query);
while($row = mysqli_fetch_array($result) ){
$id = $row['id'];
$Name = $row['Name'];
$Scholarship = $row['Scholarship'];
$Course = $row['Course'];
$Semester = $row['Semester'];
$statusAllowance = $row['statusAllowance'];
?>
<tr>
<!-- Checkbox -->
<td><input type='checkbox' name='update[]' value='<?= $id ?>' ></td>
<td><p name="Name"><?php echo $row['Name']; ?></p></td>
<td><p name="Scholarship"><?php echo $row['Scholarship'] ?></p></td>
<td><p name="Course"><?php echo $row['Course'] ?></p></td>
<td><p name="Semester"><?php echo $row['Semester'] ?></p></td>
<td><p name='statusAllowance_<?= $id ?>'><?php echo $row['statusAllowance'] ?></td>
</tr>
<
?php
}
?>
</table>
</tbody>
<?php
if(isset($_SESSION['success']) && $_SESSION['success'] !='')
{
?>
<script type="text/javascript">
swal({
title: "<?php echo $_SESSION['success']; ?>",
icon: "<?php echo $_SESSION['status_code']; ?>",
button: "yissh",
});
</script>
<?php
unset($_SESSION['success']);
}
?>
This is my code on the edit part and this works, only the alert won't show up.
updataStatus.php
<?php
require_once "connection.php";
if(isset($_POST['but_update'])){
if(isset($_POST['update'])){
foreach($_POST['update'] as $id){
$statusAllowance = 'Received';
if($statusAllowance != '' ){
$updateUser = "UPDATE allowance SET statusAllowance='".$statusAllowance."' WHERE id=".$id;
$query_run = mysqli_query($conn,$updateUser);
if($query_run){
$_SESSION['success'] = "YOUR DATA UPDATED";
header('Location: tracking.php');
}else{
$_SESSION['success'] = "YOUR DATA IS NOT UPDATED";
header('Location: tracking.php');
}
}
}
}
}
?>
considering you have not implemented another function to call sweetalert; by default, it should be Swal.fire({}) not just swal({})
https://sweetalert2.github.io/
I am working on a website database system that I am able to edit each of the content listed in the table inline. I just click on it, type to add new data, and then clicking off of it saves the new data to the database. I am able to click on each one of the entries, and begin to type, but it does not save the updated information. I feel like it has an easy solution, but I haven't been able to find it. I have been looking over it for sometime now and cannot seem to figure it out. Any help is much appreciated..
index.php
<?php
include 'db.inc.php';
$sql= "SELECT * FROM crosswalk";
$query = $db->prepare($sql);
$query->execute();
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function activate (element) {
// alert('clicked')
}
function updateValue(element, column, id){
var value = element.innerText
$.ajax({
url:'backend.php',
type: 'post',
data:{
value: value,
column: column,
id: id
},
success:function(php_result){
console.log(php_result);
}
})
}
</script>
<table>
<th>Category</th>
<th>Product Category</th>
<th>NIGP</th>
<th>NIGP Short Description</th>
<th>NIGP Full Description</th>
<th>P-Group</th>
<th>Category Specialist</th>
<th>GL Unit Price < $500</th>
<th>GL Unit Price < $500 - $4,999</th>
<th>GL Unit Price - $5000 +</th>
<?php
while($row = $query->fetch()){
$c = $row['Category'];
$p = $row['Product Category'];
$n = $row['NIGP'];
$s = $row['NIGP Short Description'];
$f = $row['NIGP Full Description'];
$g = $row['P-Group'];
$gl1 = $row['GL Unit Price<$500'];
$gl2 = $row['GL Unit Price<$500-$4,999'];
$gl3 = $row['GL Unit Price-$5000+'];
$id = md5($row['id']);
?>
<tr>
<td><div contenteditable="true" onBlur="updateValue(this, 'Category','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $c; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'Product Category','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $p; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'NIGP','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $n; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'NIGP Short Description','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $s; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'NIGP Full Description','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $f; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'P-Group','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $g; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'GL Unit Price<$500','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $gl1; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'GL Unit Price<$500-$4,999','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $gl2; ?></div></td>
<td><div contenteditable="true" onBlur="updateValue(this, 'GL Unit Price-$5000+','<?php echo $id; ?>')" onClick="activate(this)"><?php echo $gl3; ?></div></td>
</tr>
<?php
}
?>
</table>
backend.php
<?php
include 'db.inc.php';
if(isset($_POST['id'])){
$value = $_POST['value'];
$column = $_POST['column'];
$id = $_POST['id']; //md5
$sql="UPDATE crosswalk SET $column = :value WHERE md5(id) = :id LIMIT 1";
$query = $db->prepare($sql);
$query->bindParam('value',$value);
$query->bindParam('id',$id);
if($query->execute()){
echo "Update Successful";
}else{
echo "Failure";
}
}
?>
Here are the error messages I am getting
Error Pics
I have some problem in looping to make an action if radio with value = 1 then input field is enable.
here is my code, but imagine that the field and radio in a looping :
<form name="form" id="form">
<table>
<?php
$arr = array(0=>"Disable", 1=>"Enable");
for($i=0; $i<5; $i++):
?>
<tr>
<td><input type='text' name='input[]' id='input'></td>
<td>
<?php
foreach($arr as $key=>$val):
?>
<input type='radio' name='ans[<?php echo $i; ?>]' id='ans' value='<?php echo $key; ?>' onClick="d_e(this.value)"> <?php echo $val;
<?php endforeach; ?>
</td>
</tr>
<?php endfor; ?>
</table>
<script>
function d_e(id){
var i = document.form.input;
for(var c=0; c<i.length; c++){
if(id==1){
i[c].disabled = false;
}else{
i[c].disabled = true;
}
}
}
</script>
Problem is in administration console of wordpress in plugin 'woocommerce xml feeds'. There is button to add parameter for category. This button do nothing when I click it.
I tried to contact the author of plugin, he only told me to check debug console, but there is nothing. He also told me that function of this button depends on jQuery.
This is the button element:
<span class="btn btn-danger btn-sm add-param" data-par="80">Přidat parametr</span>
The whole PHP file for context:
<?php
/**
*
* #package woo_xml_feeds
* #author Vladislav Musilek
* #license GPL-2.0+
* #link http://musilda.cz
* #copyright 2014 Vladislav Musilek
*
* Version 1.0.0
*
*/
if(isset($_POST['update'])){
//Save Heureka.sk Shipping values
$this->save_heureka_delivery($name = 'woo_heureka_delivery');
//Save Heureka.cz CPC value
$this->save_single_option('heureka-cpc','heureka-cpc');
/**
* Save Heureka category
*/
$heureka_assing_categories = get_option('woo_heureka_assing_categories');
if(empty($heureka_assing_categories)){ $heureka_assing_categories = array(); }
$heureka_excluded_categories = get_option( 'woo_heureka_excluded_categories');
if(empty($heureka_excluded_categories)){ $heureka_excluded_categories = array(); }
$heureka_categories_cpc = get_option( 'woo_heureka_categories_cpc');
if(empty($heureka_categories_cpc)){ $heureka_categories_cpc = array(); }
foreach($_POST['termid'] as $key => $item){
if(!empty($_POST['heurekaid'])){
if(!empty($_POST['heurekaid'][$key])){
$heureka_assing_categories[$_POST['termid'][$key]] = $_POST['heurekaid'][$key];
}else{
if(!empty($heureka_assing_categories[$_POST['termid'][$key]])){
unset($heureka_assing_categories[$_POST['termid'][$key]]);
}
}
}
if(!empty($_POST['excluded'][$key])){
$heureka_excluded_categories[$_POST['termid'][$key]] = $_POST['termid'][$key];
}else{
if(!empty($heureka_excluded_categories[$_POST['termid'][$key]])){
unset($heureka_excluded_categories[$_POST['termid'][$key]]);
}
}
if(!empty($_POST['termvar'][$key])){
$heureka_categories_cpc[$_POST['termid'][$key]] = $_POST['category_cpc'][$key];
}else{
if(!empty($heureka_categories_cpc[$_POST['termid'][$key]])){
unset($heureka_categories_cpc[$_POST['termid'][$key]]);
}
}
}
update_option( 'woo_heureka_assing_categories', $heureka_assing_categories );
update_option( 'woo_heureka_excluded_categories', $heureka_excluded_categories );
update_option( 'woo_heureka_categories_cpc', $heureka_categories_cpc );
//Parametry pro kategorie
$cat_params = get_option( 'woo_heureka_cat_params');
if(empty($cat_params)){ $cat_params = array(); }
foreach($_POST['termvar'] as $key => $item){
$cat_params[$item]['term_id'] = $item;
$cat_params[$item]['parametry'] = array();
if(!empty($_POST['nazev_parametru_'.$item])){
foreach($_POST['nazev_parametru_'.$item] as $lit => $var){
$cat_params[$item]['parametry'][$lit]['nazev_parametru'] = $_POST['nazev_parametru_'.$item][$lit];
$cat_params[$item]['parametry'][$lit]['hodnota_parametru'] = $_POST['hodnota_parametru_'.$item][$lit];
}
}
}
update_option( 'woo_heureka_cat_params', $cat_params );
if(isset($_GET['catoffset'])){
wp_redirect(admin_url().'admin.php?page=heureka-cz&catoffset='.$_GET['catoffset']);
}else{
wp_redirect(admin_url().'admin.php?page=heureka-cz');
}
}
$cat_params = get_option( 'woo_heureka_cat_params');
//Get heureka cz categories
$heureka_categories = get_option( 'woo_heureka_categories');
$heureka_assing_categories = get_option( 'woo_heureka_assing_categories');
$heureka_excluded_categories = get_option( 'woo_heureka_excluded_categories');
$heureka_categories_cpc = get_option( 'woo_heureka_categories_cpc');
$catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC'));
$cat_list = custom_taxonomy_walker('product_cat');
$use_select2 = get_option( 'woo_xml_feed_use_select2' );
/**
* Cat pagging
*
*/
$limit = 50;
if(isset($_GET['catoffset'])){
$catstart = (($_GET['catoffset'] * $limit) - $limit)+1;
$catend = $_GET['catoffset'] * $limit;
}else{
$catstart = 1;
$catend = $limit;
}
$i = 1;
$ii = 1;
?>
<div class="wrap">
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
<form method="post" action="">
<?php
//Include Heureka CPC table
include('modules/heureka_cz_cpc.php');
//Include Heureka Shipping table
include('modules/heureka_cz_shipping.php');
//Display category setting paggination
echo tax_pagination($cat_list, 50);
?>
<!-- Heureka kategorie -->
<div class="t-col-12">
<div class="toret-box box-info">
<div class="box-header">
<h3 class="box-title"><?php _e('Přiřazení kategorií','woo-xml-feeds'); ?></h3>
</div>
<div class="box-body">
<p><?php _e('Zde můžete přiřadit všechny kategorie ve vašem obchodu, k jednotlivým kategoriím Heuréky. Pokud máte v eshopu větší množství kategorií, buďte prosím trpěliví, načtení může chvíli trvat. Po rozkliknutí výběru Heuréka kategorie, můžete do řádku zapsat počáteční písmena hledané kategorie a použít našeptávač.','woo-xml-feeds'); ?></p>
<p><?php _e('Pokud nechcete zobrazovat zboží z určité kategorie v XML feedu, zaškrtněte "Vyloučit kategorii".','woo-xml-feeds'); ?></p>
<table class="table-bordered">
<tr>
<th><?php _e('Vyloučit kategorii', 'woo-xml-feeds'); ?></th>
<th><?php _e('Kategorie obchodu', 'woo-xml-feeds'); ?></th>
<th><?php _e('Kategorie na Heuréce', 'woo-xml-feeds'); ?></th>
<th><?php _e('CPC kategorie', 'woo-xml-feeds'); ?></th>
</tr>
<?php
$catTerms = explode(',',$cat_list);
$aa = 0;
foreach($catTerms as $c_item) :
if(!empty($c_item) && $i >= $catstart){
if($i > $catend){ break; }
?>
<tr>
<td class="td_center"><input class="icheck_red" type="checkbox" name="excluded[<?php echo $aa; ?>]" <?php if(!empty($heureka_excluded_categories[$c_item])){ echo 'checked="checked"'; } ?> value="<?php echo $c_item; ?>" ></td>
<td>
<?php
$aa++;
$catTerm = get_term_by( 'id', $c_item, 'product_cat' );
if(!empty($catTerm->parent)){
$p_name = get_term_by( 'id', $catTerm->parent, 'product_cat' );
echo $p_name->name.' >> ';
}
?> <?php echo $catTerm->name; ?>
<input type="hidden" name="termid[]" value="<?php echo $catTerm->term_id; ?>" />
</td>
<td>
<?php
if(!empty($use_select2) && $use_select2 == 'no'){}else{
?>
<script>
jQuery(document).ready(function() { jQuery("#heureka<?php echo $i; ?>").select2(); });
</script>
<?php } ?>
<style>#s2id_heureka<?php echo $i; ?>{min-width:800px;}</style>
<select name="heurekaid[]" id="heureka<?php echo $i; ?>">
<option value="default"></option>
<?php
foreach($heureka_categories as $key => $item){
if(!empty($item['category_fullname'])){
?>
<option <?php if(!empty($heureka_assing_categories[$catTerm->term_id]) && $heureka_assing_categories[$catTerm->term_id]==$key){ echo 'selected="selected"'; }; ?>value="<?php echo $key; ?>"><?php echo $item['category_fullname']; ?></option>
<?php }
}
?>
</select>
</td>
<td><input type="text" name="category_cpc[]" value="<?php if(!empty($heureka_categories_cpc[$c_item])){ echo $heureka_categories_cpc[$c_item]; } ?>" style="width:40px;" /></td>
</tr>
<?php
}
$i++;
endforeach;
?>
</table>
</div>
</div>
</div>
<!-- Heureka kategorie parametry -->
<div class="t-col-12">
<div class="toret-box box-info">
<div class="box-header">
<h3 class="box-title"><?php _e('Vlastní parametry pro kategorie','woo-xml-feeds'); ?></h3>
</div>
<div class="box-body">
<table class="table-bordered">
<tr>
<th><?php _e('Kategorie eshop', 'woo-xml-feeds'); ?></th>
<th style="width:80%;"><?php _e('Vlastní parametry', 'woo-xml-feeds'); ?></th>
</tr>
<?php
$catTerms = explode(',',$cat_list);
foreach($catTerms as $c_item) :
if(!empty($c_item) && $ii >= $catstart){
if($ii > $catend){ break; }
?>
<tr>
<td>
<?php
$catTerm = get_term_by( 'id', $c_item, 'product_cat' );
if(!empty($catTerm->parent)){
$p_name = get_term_by( 'id', $catTerm->parent, 'product_cat' );
echo $p_name->name.' >> ';
}
?> <?php echo $catTerm->name; ?>
<input type="hidden" name="termvar[<?php echo $catTerm->term_id; ?>]" value="<?php echo $catTerm->term_id; ?>" />
</td>
<td class="category_params">
<?php
if(!empty($cat_params[$catTerm->term_id]['parametry'])){
foreach($cat_params[$catTerm->term_id]['parametry'] as $lit => $var){ ?>
<fieldset>
<input type="text" name="nazev_parametru_<?php echo $catTerm->term_id; ?>[]" placeholder="Název parametru" value="<?php echo $var['nazev_parametru']; ?>" />
<input type="text" name="hodnota_parametru_<?php echo $catTerm->term_id; ?>[]" placeholder="Hodnota parametru" value="<?php echo $var['hodnota_parametru']; ?>"/>
<span class="btn btn-danger btn-sm remove-param"><i class="fa fa-times"></i></span>
</fieldset>
<?php }
}
?>
<div class="clear"></div>
<span class="btn btn-danger btn-sm add-param"data-par="<?php echo $catTerm->term_id; ?>">Přidat parametr</span>
</td>
</tr>
<?php
}
$ii++;
endforeach;
?>
</table>
<input type="hidden" name="update" value="ok" />
<input type="submit" class="btn btn-lg btn-warning" value="<?php _e('Uložit nastavení','woo-xml-feeds'); ?>" />
</div>
</div>
</div>
</form>
</div>
I really tried to google it I found similar problems with some simple advice to switch to default theme or to put define('CONCATENATE_SCRIPTS', false); to wp-config.php. No luck with any of these.
I'm trying to pull data from database into selectboxes, but when the data is pulled it goes into one 'td' and not into separate td's. I'm trying to achieve result as shown below
but I keep getting this result
here is my code
<?php
$data_array = array();
$result2 = mysql_query("SELECT * FROM `firefightersonscene`
JOIN `firefighterinfo` ON `firefightersonscene`.`FireFighterInfo_fighterID` = `firefighterinfo`.`fighterID`
JOIN `stationlocation` ON `firefighterinfo`.`StationLocation_locationID`=`stationlocation`.`locationID`
WHERE `IncidenceOfFire_incidentID`='$getIncID' ORDER BY `firstName`");
if(mysql_num_rows($result2) > 0)
{
while($rows2 = mysql_fetch_object($result2))
{
$data_array[] = $rows2;
}
}
?>
<form action="core_viewfireoccurrence.php?incidentID=<?php echo $rows->incidentID; ?>" method="post" class="view_occurrence_form">
<table id="myTable">
<thead>
<tr>
</tr>
</thead>
<tbody>
<tr>
<td class="count">1</td>
<td>
<?php
foreach($data_array as $rows2):
$fighterID = $rows2->FireFighterInfo_fighterID;
$results = mysql_query("SELECT `fighterID`, `firstName`, `middleName`, `lastName`, `stationlocation`.`exactlocation`
FROM `firefighterinfo`
JOIN `stationlocation` ON `firefighterinfo`.`StationLocation_locationID`=`stationlocation`.`locationID` ORDER BY `firstName`");
echo '<select name="fireman[]" required><option value=""></option>';
while($row = mysql_fetch_array($results))
{
if($row['fighterID'] == $fighterID)
echo '<option selected>'. $row['firstName']." ".$row['middleName']." ".$row['lastName'].", ".$row['exactlocation'].'</option>';
else
echo '<option>'. $row['firstName']." ".$row['middleName']." ".$row['lastName'].", ".$row['exactlocation'].'</option>';
}// end while
echo '</select><br>';
endforeach;
?>
</td>
<td>
<input type="button" value="X" class="removeVar"/>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>
<input type="button" id="addVar" value="Add Item"/>
</tr>
</tfoot>
</table>
</form>
JS CODE
<script type="text/javascript">
$('form').on('click', '.removeVar', function(){
$(this).closest('tr').remove();
$('.count').each(function(i){
$(this).text(i + 1);
});
});
//add a new node
$('#addVar').on('click', function(){
var varCount = $('#myTable tr').length - 1;
$node = ['<tr>',
'<td class="count">'+varCount+'</td>',
'<td><select name="fireman[]" class="ctlGroup" required>',
'<option value=""></option>',
'<?php require("php/fireman_list.php"); ?>',
'</select></td>',
'<td><input type="button" value="X" class="removeVar"/>',
'</td></tr>'].join('\n');
$('#myTable > tbody:last').append($node);
});
</script>
You need to put your whole table row in the loop. You will also need to add a variable to count the row number for you.
<?php
$row =1;
foreach($data_array as $rows2):
?>
<tr>
<td class="count"><?php echo $row; ?></td>
<td>
<?php
$fighterID = $rows2->FireFighterInfo_fighterID;
$results = mysql_query("SELECT `fighterID`, `firstName`, `middleName`, `lastName`, `stationlocation`.`exactlocation`
FROM `firefighterinfo`
JOIN `stationlocation` ON `firefighterinfo`.`StationLocation_locationID`=`stationlocation`.`locationID` ORDER BY `firstName`");
echo '<select name="fireman[]" required><option value=""></option>';
while($row = mysql_fetch_array($results))
{
if($row['fighterID'] == $fighterID)
echo '<option selected>'. $row['firstName']." ".$row['middleName']." ".$row['lastName'].", ".$row['exactlocation'].'</option>';
else
echo '<option>'. $row['firstName']." ".$row['middleName']." ".$row['lastName'].", ".$row['exactlocation'].'</option>';
}// end while
echo '</select><br>';
?>
</td>
<td>
<input type="button" value="X" class="removeVar"/>
</td>
</tr>
<?php
$row++;
endforeach;
?>