0

I want to redirect with a array row to a page when I click editbutton.

    $sQuery = " SELECT SQL_CALC_FOUND_ROWS " . str_replace(" , ", " ", implode(", ", $aColumns)) . " FROM $sTable $sWhere $sOrder $sLimit ";
    $rResult = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
    $sQuery = " SELECT FOUND_ROWS() ";
    $rResultFilterTotal = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
    $aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
    $iFilteredTotal = $aResultFilterTotal[0];
    $sQuery = " SELECT COUNT(" . $sIndexColumn . ") FROM $sTable ";
    $rResultTotal = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
    $aResultTotal = mysql_fetch_array($rResultTotal);
    $iTotal = $aResultTotal[0];
    while ( $aRow = mysql_fetch_array($rResult) ) {
        $row = array();
        for ( $i = 0 ; $i < count($aColumns); $i++ ) {
            if ( $aColumns[$i] == "version" ) $row[] = ( $aRow[$aColumns[$i]] == "0" ) ? '-' : $aRow[$aColumns[$i]];
            else if ( $aColumns[$i] != ' ' ) $row[] = $aRow[$aColumns[$i]];
        }
        $output['aaData'][] = array_merge($row, array('<a data-id="row-' . $row[0] . '" href="javascript:editRow(' . $row[0] . ');" class="btn btn-md btn-success">edit</a>&nbsp;<a href="javascript:removeRow(' . $row[0] . ');" class="btn btn-default btn-md" style="background-color: #c83a2a;border-color: #b33426; color: #ffffff;">remove</a>'));
    }

    // RETURN IN JSON
    die(json_encode($output));
}




    // ATW
            if ( top.location.href != location.href ) top.location.href = location.href;

            // Initialize datatable
            $('#example').dataTable({
                "aProcessing": true,
                "aServerSide": true,
                "ajax": "add.php?ajax"
            });

            // Save edited row
            $("#edit-form").on("submit", function(event) {
                event.preventDefault();
                $.post("add.php?edit=" + $('#edit-id').val(), $(this).serialize(), function(data) {
                    var obj = $.parseJSON(data);
                    var tr = $('a[data-id="row-' + $('#edit-id').val() + '"]').parent().parent();

                    $('#edit-modal').modal('hide');
                }).fail(function() { alert('Unable to save data, please try again later.'); });
            });

        });

        // Edit row
        function editRow(id) {
            if ( 'undefined' != typeof id ) {
                $.getJSON('add.php?edit=' + id, function(obj) {

                    $('#edit-modal').modal('show')
                }).fail(function() { alert('Unable to fetch data, please try again later.') });
            } else alert('Unknown row id.');

I want is to redirect in new page when I click edit button. To view data in a new page not on modal. Please help. I can donate.

Direct in new page and create new webpage to edit not on modal. thank you very much.

  • That's a lot of code to go through if most of it works. Please read [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and consider creating a minimal reproducible test case. "tour" and "help" links for using Stack Overflow may be found in the page footer below. – traktor Mar 23 '17 at 21:56

1 Answers1

0

Hey John Smith if that is your real name... hmmm (¬_¬)

Sounds like you want to do a redirect like so:

window.location.href = "http://stackoverflow.com";

or inside a button click

$('#some-html-tag-id').cl
.click(function() {
    window.location.href = "http://stackoverflow.com";
});

Also this might be a good answer to your question. How to redirect to another webpage in JavaScript/jQuery?

Community
  • 1
  • 1
BlueYama
  • 44
  • 4