javascript - How to transfer multiple rows output to another php file to process data? -
<form name="myform" action="docontrolacc.php" method="post" onsubmit="return validateform(this);"> <table cellpadding="0" cellspacing="0" border="20" class="display" id="acc" width="200"> <thead> <tr><h2>accessories summary</h2></tr> <tr> <th>type</th> <th>currently - ex factory</th> <th>minimum required stock</th> <th>update by</th> <th>last update</th> <th>re-stock amount</th> <th>stock out</th> </tr> </thead> <tbody> <?php $accessories = array() $query = "select description, current_stock, min_required_stock, c_ex_factory, last_update accessories”; $result= mysqli_query($link, $query) or die(mysqli_error($link)); $row = mysqli_fetch_array($result); while($row = mysqli_fetch_array($result)){ $order = $row['c_ex_factory'] - $row['min_required_stock']; if ($order < 0){ $order = $row['min_required_stock']-$row['c_ex_factory']; $color = "#ff0000"; }else{ $order = 0; $color = "#00ff00"; } ?> <tr> <td name="accessories[]" id="accessories" value=”<?php echo $row['description'] ?>” <?php echo in_array($row['description', $ accessories) > <?php echo $row['description']; ?> </td> <td align="center" name="accessories[]" id="accessories" value=”<?php echo $row[''c_ex_factory '] ?>” <?php echo in_array($row[''c_ex_factory ', $ accessories) > <?php echo $row['c_ex_factory']; ?> </td> <td align="center" name="accessories[]" id="accessories" value=”<?php echo $row[''min_required_stock '] ?>” <?php echo in_array($row[''min_required_stock ', $ accessories) > <?php echo $row['min_required_stock']; ?> </td> <td align="center" name="accessories[]" id="accessories" value=”<?php echo $row[' name '] ?>” <?php echo in_array($row[' name ', $ accessories) > <?php echo $row['name']; ?> </td> <td align="center" name="accessories[]"id="accessories" value=”<?php echo $row['description'] ?>” <?php echo in_array($row['description', $ accessories) > <?php echo $row['up_when']; ?> </td> <td align="center" name="accessories[]" bgcolor="<?php echo $color; ?>" id="accessories" <?php echo in_array($row[' re_stock ', $ accessories) > <input type="text" size="5" name="re_stock" value=" <?php echo $order ?>"/> </td> <td align="center" name="accessories[]"id="accessories" <?php echo in_array($row[' out_stock ', $ accessories) > <input type="text" size="5" name="out_stock" value ="0"/></td> </tr> <?php } ?> <tr> <td> </td> <td> </td> <td></td> <td></td> <td></td> <td><button data-theme="b" id="submit" type="submit">send order</button></td> </tr> </tbody> </table> </form>
hello, i'm new web programming. code above fetch data database create table in php, take user inputs stock-out , restock , send docontrolacc.php file. problem i'm facing need create multiple input lines users can enter stock-out , re-stock different products. , don't know how pass these multiple lines docontrolacc.php file after form filled. (i.e how can access accessories array in docontrolacc.php?).
thank help.
this may not best way, can use session variables. can't quite understand program writing, can't whether or not sessions safe enough, if wanted use sessions, this:
at beginning of file:
<?php session_start(); ?>
and later, when variable set:
$_session['accessories'] = $accessories;
to access in code file, must start session shown above in each code file. then, this;
$accessories = $_session['accessories'];
Comments
Post a Comment