0

I have a table with chechbox and submit button. when i select some rows and click submit button, that gives me a xml report. I want the rows I previously selected not to be displayed again when I see the table again. I do not want to delete them in the data bank, I just want them not to be displayed anymore. Is there a way to do that in PHP or javascrypt?

UPDATE: that is my table:

    <form action="companies.php" method="post" onsubmit='checkform()'>
            <table border=2 style="width:1200px";>                
    <tr>
                        <td class="ttd"><input type="checkbox" value="<?php echo $ff['ID']; ?>" name="chk[]"> </td>
                        <td class="ttd"><?php echo htmlentities($ff['ID']); ?> </td>
                        <td class="ttd"><?php echo htmlentities($ff['Invoice_number']); ?> 
                        <input type="hidden" name="Inum[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Invoice_number']; ?>"></td>
                        <td class="ttd"><?php echo htmlentities($ff['Invoice_date']); ?> </td>
                        <td class="ttd"><?php echo htmlentities($ff['Month']); ?> </td>
                        <td class="ttd"><?php echo htmlentities($ff['Space_name']); ?> 
                        <input type="hidden" name="Sname[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Space_name']; ?>"></td>
                        <td class="ttd"><?php echo htmlentities($ff['Company_name']); ?> 
                        <input type="hidden" name="Cname[<?php echo $kunde['ID']; ?>]" value="<?php echo $ff['Company_name']; ?>"></td>
                        <td class="ttd"><?php echo htmlentities($ff['Amount']); ?> 
                        <input type="hidden" name="amount[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Amount']; ?>"></td>
                        <td class="ttd" style="width:200px;"><?php echo htmlentities($x); ?> 
                        <input type="hidden" name="iban[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Iban']; ?>"></td>
                        <td class="ttd"><?php echo htmlentities($ff['BIC']); ?> 
                        <input type="hidden" name="bic[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['BIC']; ?>"></td>
                    </tr>
    </table>
            <button type="submit" name="submit" value="submit" onclick='sendit()'>submit</button>
</form>

UPDATE2: script:

document.forms[0].addEventListener("submit", function(event){
        if ( send == 0 ) { event.preventDefault(); }
    });
    
function myFunction(el) {
  var hidden = el.previousElementSibling;
  hidden.style.display = 'block';
  hidden.select();
  hidden.setSelectionRange(0, 99999)
  document.execCommand("copy");
  alert("Copied the text: " + hidden.value);
  hidden.style.display = 'none';
}
  
var send = 0;

function sendit(){
      send = 1;
     console.log(send);
  }
  
function checkform(){
    if (send == 1){
        console.log(send);
        document.form[0].submit();
    } else {
        return false;
    }

 }
  

and companies.php creat a xml FILE.

Saeed
  • 15
  • 2
  • Probably yes. But without seeing your existing context we can't suggest anything specific. See [ask] for tips on improving your question. Open ended questions like this tend not to attract good answers – ADyson Nov 12 '21 at 08:43
  • Thanks for the code. But that's clearly only part of the picture. What does checkform() do? What does your companies.php code do? Have you researched/tried anything yourself in relation to trying to solve your issue? – ADyson Nov 12 '21 at 09:13
  • If companies.php just produces an XML file and sends it for download directly, then it can never update your page. You'd need to change it to do an AJAX-based download, or open companies.php in a separate tab so you can then use Javascript to update your existing page. – ADyson Nov 12 '21 at 09:22
  • thank you, yes that produces an XML file and sends it for download directly, if i open that in seperate tab, how is java script? – Saeed Nov 12 '21 at 09:33
  • You'd use javascript to open the tab. Then while it's downloading, the same javascript function would continue to update your current page and remove the selected rows. – ADyson Nov 12 '21 at 09:35
  • First step: https://stackoverflow.com/questions/5709590/submit-a-form-in-a-new-tab. Then, after your `document.form[0].submit();` command, write some code to work out what rows were selected, and remove them – ADyson Nov 12 '21 at 09:37

1 Answers1

0

I must just add a boolean column with value null in databank, when i click submit, that to be changed in 1 and with simple if connection, the rows I previously selected not to be displayed again. So, this is table:

<form action="companies.php" method="post" onsubmit='checkform()'>
        <table border=2 style="width:1200px";>
    <?php
     if($ff['checkbox'] == 0){
              
    ?>
                
                <tr>
                    <td class="ttd"><input type="checkbox" value="<?php echo $ff['ID']; ?>" name="chk[]"> </td>
                    <td class="ttd"><?php echo htmlentities($ff['ID']); ?> </td>
                    <td class="ttd"><?php echo htmlentities($ff['Invoice_number']); ?> 
                    <input type="hidden" name="Inum[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Invoice_number']; ?>"></td>
                    <td class="ttd"><?php echo htmlentities($ff['Invoice_date']); ?> </td>
                    <td class="ttd"><?php echo htmlentities($ff['Month']); ?> </td>
                    <td class="ttd"><?php echo htmlentities($ff['Space_name']); ?> 
                    <input type="hidden" name="Sname[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Space_name']; ?>"></td>
                    <td class="ttd"><?php echo htmlentities($ff['Company_Name']); ?> 
                    <input type="hidden" name="Cname[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Company_Name']; ?>"></td>
                    <td class="ttd"><?php echo htmlentities($ff['Amount']); ?> 
                    <input type="hidden" name="amount[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Amount']; ?>"></td>
                    <td class="ttd" style="width:200px;"><?php echo htmlentities($x); ?> 
                    <input type="hidden" name="iban[<?php echo $ff['ID']; ?>]" value="<?php echo $ff['Iban']; ?>"></td>
                    <td class="ttd"><?php echo htmlentities($ff['BIC']); ?> 
                    <input type="hidden" name="bic[<?php echo $kunde['ID']; ?>]" value="<?php echo $kunde['BIC']; ?>"></td>
                </tr>
</table>
        <button type="submit" name="submit" value="submit" onclick='sendit()'>submit</button>
        </form>

and in companies.php before save the xml file add i this query:

if ($_POST['submit']){
#### XML file create  
####..... at the End, when all xml attribute to be created ######
$query = "UPDATE ff SET checkbox = 1 WHERE Invoice_number = '{$invoice_number}'";
            $result = mysqli_query($connection, $query);
         
         
         if($result && mysqli_affected_rows($connection)>= 0){
            $xml->formatOutput = true;
            $xml->save('../includes/xml/'.$filename) or die('XML Create Error') ;
            redirect_to("manage_content.php");
    }
Saeed
  • 15
  • 2
  • 2
    Is this your solution? If so then please show the code which fixed it, otherwise it's not so useful to other people – ADyson Nov 12 '21 at 11:13
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 12 '21 at 13:23