jQuery UI Widgets Forums Grid not able to BIND – rowdata of image in updaterow: / update command.

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 6 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • akshayyes
    Participant

    # I am not able to BIND – rowdata of PHOTO/Image in updaterow: / update command. Other remaining data is updated excluding the Image/Photo column.
    # As a result, the name & extension of (file name) PHOTO/Image is not inserted into mysql database table.

    +++++ HTML CODE ++++++

    <!DOCTYPE html>
    <html lang=”en”>
    <head>
    <link rel=”stylesheet” href=”../jqwidgets/styles/jqx.base.css” type=”text/css” />
    <link rel=”stylesheet” href=”../jqwidgets/styles/jqx.classic.css” type=”text/css” />
    <script type=”text/javascript” src=”../scripts/jquery-1.10.2.min.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxcore.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxbuttons.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxscrollbar.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxmenu.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxcheckbox.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxlistbox.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxdropdownlist.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxgrid.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxdata.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxgrid.selection.js”></script>
    <script type=”text/javascript” src=”../jqwidgets/jqxgrid.edit.js”></script>
    <script type=”text/javascript”>
    $(document).ready(function () {
    // prepare the data
    var data = {};
    var theme = ‘classic’;
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘id’ },
    { name: ‘brand’ },
    { name: ‘part_no’ },
    { name: ‘size’ },
    { name: ‘resolution’ },
    { name: ‘aspect_ratio’ },
    { name: ‘contrast_ratio’ },
    { name: ‘brightness’ },
    { name: ‘outline_dimension’ },
    { name: ‘production_status’ },
    { name: ‘photo’ }

    ],

    id: ‘id’,
    url: ‘data.php’,
    updaterow: function (rowid, rowdata, commit) {
    // synchronize with the server – send update command
    var data = “update=true&brand=” + rowdata.brand + “&part_no=” + rowdata.part_no + “&size=” + rowdata.size;
    data = data + “&resolution=” + rowdata.resolution + “&aspect_ratio=” + rowdata.aspect_ratio + “&contrast_ratio=” + rowdata.contrast_ratio ;
    data = data + “&brightness=” + rowdata.brightness + “&outline_dimension=” + rowdata.outline_dimension + “&id=” + rowdata.id;
    data = data + “&production_status=” + rowdata.production_status;

    $.ajax({
    dataType: ‘json’,
    url: ‘data.php’,
    data: data,
    success: function (data, status, xhr) {
    // update command is executed.
    commit(true);
    },
    error: function () {
    // cancel changes.
    commit(false);
    }
    });
    }

    };

    // initialize jqxGrid
    $(“#jqxgrid”).jqxGrid(
    {
    width: 1200,
    height: 350,
    selectionmode: ‘singlecell’,
    source: source,
    theme: theme,
    editable: true,
    columns:
    [
    { text: ‘id’, datafield: ‘id’, width: 100 },
    { text: ‘Brand’, columntype: ‘dropdownlist’, datafield: ‘brand’, width: 100 },
    { text: ‘Part No’, columntype: ‘dropdownlist’, datafield: ‘part_no’, width: 100 },
    { text: ‘Size’, datafield: ‘size’, width: 180 },
    { text: ‘Resolution’, datafield: ‘resolution’, width: 180 },
    { text: ‘AspectRatio’, datafield: ‘aspect_ratio’, width: 100 },
    { text: ‘ContrastRatio’, datafield: ‘contrast_ratio’, width: 140 },
    { text: ‘Brightness’, datafield: ‘brightness’, width: 140 },
    { text: ‘OutlineDimension’, datafield: ‘outline_dimension’, width: 140 },
    { text: ‘production_status’, datafield: ‘production_status’, width: 140,columntype: ‘checkbox’},
    {
    text: ‘Upload’, width: 250, columntype: ‘custom’, datafield: ‘photo’,
    cellsrenderer: function (row, column, value) {
    if (value == “”) {
    return “Select a file”;
    };
    },
    createeditor: function (row, cellvalue, editor, cellText, width, height) {
    // construct the editor.
    editor.html(‘<input id=”fileInput’ + row + ‘” type=”file” name=”fileInput” />’);
    },
    geteditorvalue: function (row, cellvalue, editor) {
    // return the editor’s value.
    var value = $(“#fileInput” + row).val();
    //return value.substring(value.lastIndexOf(“\\”) + 1, value.length);
    return value.substring(value.lastIndexOf(“\\”) + 1, value.length);
    }
    }

    ]
    });
    });
    </script>
    </head>
    <body class=’default’>
    <div id=”jqxgrid”>
    </div>
    </body>
    </html>

    ++++++++++ PHP Code +++++++++++

    <?php
    #Include the connect.php file
    include(‘connect.php’);
    #Connect to the database
    //connection String
    $connect = mysql_connect($hostname, $username, $password)
    or die(‘Could not connect: ‘ . mysql_error());
    //Select The database
    $bool = mysql_select_db($database, $connect);
    if ($bool === False){
    print “can’t find $database”;
    }
    // get data and store in a json array
    $query = “SELECT * FROM beyond_lcdpanel”;
    if (isset($_GET[‘update’]))
    {

    //$target = “../image/” ;
    //$target = $target . basename( $_FILES[‘fileInput’][‘name’]);
    // UPDATE COMMAND
    $update_query = “UPDATE beyond_lcdpanel SET brand='”.$_GET[‘brand’].”‘,
    part_no='”.$_GET[‘part_no’].”‘,
    size='”.$_GET[‘size’].”‘,
    resolution='”.$_GET[‘resolution’].”‘,
    aspect_ratio='”.$_GET[‘aspect_ratio’].”‘,
    contrast_ratio='”.$_GET[‘contrast_ratio’].”‘,
    brightness='”.$_GET[‘brightness’].”‘,
    production_status= ‘”.$_GET[‘production_status’].”‘,
    outline_dimension= ‘”.$_GET[‘outline_dimension’].”‘,
    outline_dimension= ‘”.$_GET[‘outline_dimension’].”‘ WHERE id='”.$_GET[‘id’].”‘”;
    //photo= ‘”.$_GET[‘photo’].”‘ WHERE id='”.$_GET[‘id’].”‘”;
    //photo='”.$_FILES[‘fileInput’][‘name’].”‘ WHERE id='”.$_GET[‘id’].”‘”;
    $result = mysql_query($update_query) or die(“SQL Error 1: ” . mysql_error());
    // move_uploaded_file($_FILES[‘fileInput’][‘tmp_name’], $target);
    echo $result;

    }
    else
    {
    // SELECT COMMAND
    $result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $beyond[] = array(
    ‘id’=>$row[‘id’],
    ‘brand’ => $row[‘brand’],
    ‘part_no’ =>$row[‘part_no’],
    ‘size’ => $row[‘size’],
    ‘resolution’ => $row[‘resolution’],
    ‘aspect_ratio’ => $row[‘aspect_ratio’],
    ‘contrast_ratio’ => $row[‘contrast_ratio’],
    ‘brightness’ => $row[‘brightness’],
    ‘outline_dimension’ => $row[‘outline_dimension’],
    ‘production_status’ => $row[‘production_status’],
    ‘photo’ => $row[‘photo’]

    );
    }
    echo json_encode($beyond);
    }
    ?>


    Dimitar
    Participant
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.