My poll results for my coloured bars don't work - javascript

I am trying to make a poll with two pink bars to show the percentages of the results. I made my percentage bars images, although when I used the poll, they stay the same size and don't get any smaller/bigger according to their %. How should I change the code so that the % bars change their lengths?
HMTL code:
<html>
<head>
<script>
function getVote(int) {
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("poll").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","poll_vote.php?vote="+int,true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="poll">
<h3>Do you like PHP and AJAX so far?</h3>
<form>
Yes: <input type="radio" name="vote" value="0" onclick="getVote(this.value)"><br>
No: <input type="radio" name="vote" value="1" onclick="getVote(this.value)">
</form>
</div>
</body>
</html>
PHP file:
<?php
$vote = $_REQUEST['vote'];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0) {
$yes = $yes + 1;
}
if ($vote == 1) {
$no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2>Result:</h2>
<table>
<tr>
<td>Yes:</td>
<td><img src="images/poll.png"
width='<?php echo(100*round($yes/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($yes/($no+$yes),2)); ?>%
</td>
</tr>
<tr>
<td>No:</td>
<td><img src="images/poll.png"
width='<?php echo(100*round($no/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($no/($no+$yes),2)); ?>%
</td>
</tr>
</table>

You should not use image for indicating progress. Use <progress> or other HTML element with CSS.
I have changed your poll_vote.php file to use <progress> element.
<?php
$vote = $_REQUEST['vote'];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0) {
$yes = $yes + 1;
}
if ($vote == 1) {
$no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
$yesProgress = 100*round($yes/($no+$yes),2);
$noProgress = 100*round($no/($no+$yes),2);
?>
<h2>Result:</h2>
<table>
<tr>
<td>Yes:</td>
<td>
<progress id="file" max="100" value="<?= $yesProgress ?>">
<?= $yesProgress ?>
</progress>
<?= $yesProgress ?>%
</td>
</tr>
<tr>
<td>No:</td>
<td>
<progress id="file" max="100" value="<?= $noProgress ?>">
<?= $noProgress ?>
</progress>
<?= $noProgress ?>%
</td>
</tr>
</table>
Refer below Links:
HTML Element
Bootstrap 4 Progress Bars

Related

Can you guide me with a question, I am trying to change the color every time I press a button

My problem is that I call my function within my for, but only a part changes color and not above each record, the buttons work but the color of the corresponding row does not change, it had occurred to me to send a value that could be the pk of my table and this one that is changing in the for, if you know any way to achieve that I would really appreciate it
<!doctype html>
<html lang="es">
<head>
<body>
<?php
if (isset($_POST['submit']) && !hash_equals($_SESSION['csrf'], $_POST['csrf'])) {
die();
}
$error = false;
$config = include 'ClientesBeta/conexion/config.php';
try {
$dsn = 'mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['name'];
$conexion = new PDO($dsn, $config['db']['user'], $config['db']['pass'], $config['db']['options']);
if (isset($_POST['marca'])) {
$consultaSQL = "SELECT * FROM zonas WHERE idZonas <> 1 and nombreZona LIKE '%" . $_POST['marca'] . "%'";
} else {
$consultaSQL = "SELECT * FROM zonas where idZonas <> 1";
}
$sentencia = $conexion->prepare($consultaSQL);
$sentencia->execute();
$alumnos = $sentencia->fetchAll();
} catch(PDOException $error) {
$error= $error->getMessage();
}
?>
<table class="table table-bordered table-striped" style="margin-top:20px;">
<thead>
<th>ID</th>
<th>Zona</th>
<th>Acción</th>
</thead>
<tbody>
<?php
if ($alumnos && $sentencia) {
foreach ($alumnos as $row) {
?>
<tr>
<td id="prueba2"></td>
<td id="prueba"></td>
<td id="prueba1"></td>
<td >
<button type="button" onclick="cambiarColor2();">Inicio</button>
<button type="button" onclick="cambiarColor();">Proceso</button>
<button type="button" onclick="cambiarColor1();">Fin</button>
</td>
<script>
function cambiarColor(){
document.getElementById('prueba').style.backgroundColor = "blue";
}
</script>
<script>
function cambiarColor1(){
document.getElementById('prueba1').style.backgroundColor = "red";
}
</script>
<script>
function cambiarColor2(){
document.getElementById('prueba2').style.backgroundColor = "green";
}
</script>
</tr>
<tr>
<td><?php echo $row['idZonas']; ?></td>
<td><?php echo $row['nombreZona']; ?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
It is difficult to understand your question. But I believe you are looking for the below answer. Let me know if it helps you.
I think you have placed the ID in the wrong tags, though. Changed the id to where you want to change the colour. I haven't tested the code also.
<?php
if ($alumnos && $sentencia) {
foreach ($alumnos as $key => $row) {?>
<tr>
<td id="prueba2_<?php echo $key; ?>"></td>
<td id="prueba0_<?php echo $key; ?>"></td>
<td id="prueba1_<?php echo $key; ?>"></td>
<td>
<button type="button" onclick="cambiarColor(<?php echo $key; ?>, 2, 'green');">Inicio</button>
<button type="button" onclick="cambiarColor(<?php echo $key; ?>, 0, 'blue');">Proceso</button>
<button type="button" onclick="cambiarColor(<?php echo $key; ?>, 1, 'red');">Fin</button>
</td>
</tr>
<tr>
<td><?php echo $row['idZonas']; ?></td>
<td><?php echo $row['nombreZona']; ?></td>
<td> </td>
</tr>
<?php
}
}
?>
<script>
function cambiarColor(id, eleid color){
document.getElementById('prueba'+eleid+'_'+id).style.backgroundColor = color;
}
</script>

How to enable disable field with radio in looping

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>

Wordpress button in wo-xml feed administration not working

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.

Updating quantity in cart table

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>

I'm trying to pull data from database into selectboxes

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;
?>

Categories