jQuery UI Widgets Forums Grid jqxgrid $_REQUEST[store_name]

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 7 years, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • jqxgrid $_REQUEST[store_name] #90247

    dan123
    Participant

    Hi i have implemented the grid and the simple bootstrap table is what I am trying to achieve. Basically I have this inventory system, where the user is a defined as a session, and the store name is like a $_REQUEST[store_name]. I cant seems to fetch data to my grid with this $_REQUEST[store_name] call. But I have tried and it works in my bootstrap table.
    For example: In the image link: The title says “FoodMart” this is the store, and this should fetch the rows that i request from my select statement.
    Here is a image link below to see what I am talking about.

    https://postimg.org/image/57lid0enz/

    Index.php
    <—This sql connection is just for the bootstrap table example
    <?php
    require(‘dbconnect.php’);
    //session_start();
    include(“verify.php”);
    $store_name=$_REQUEST[‘store_name’];
    ?>
    –>

    Here is the jqxgrid implementation
    <script type=”text/javascript”>
    $(document).ready(function () {
    // ??(??)

    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘id’},
    { name: ‘product_name’},
    { name: ‘quantity’},
    { name: ‘low_quantity’},
    { name: ‘price’},
    { name: ‘total’},
    { name: ‘store_name’},
    { name: ‘addbyuser’}
    ],
    url: ‘productsdata.php’,
    //id: ‘addbyuser’,
    root: ‘Rows’,
    beforeprocessing: function (data) {
    source.totalrecords = data[0].TotalRows;
    }

    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#jqxgrid”).jqxGrid(
    {
    width: ‘100%’,
    autoheight: true,
    source: dataAdapter,
    //keyboardnavigation: false,
    filterable: true,
    sortable: true,
    editable: true,
    editmode: ‘dblclick’,
    showfilterrow: true,
    altrows: true,
    enablehover: true,
    pageable: true,
    showtoolbar: true,
    rowsheight: 40,
    //showstatusbar: true,
    pagesize: 15,
    columnsresize: true,
    columnsreorder: true,
    columnsautoresize: true,
    enablebrowserselection: true,
    theme:’jqx-ar’,
    selectionmode: ‘singlerow’,
    columns: [
    { text: ‘??’, datafield: ‘id’, width: 100, hidden: true},
    { text: ‘Product Name’, datafield: ‘product_name’, width: 180, resizable:false},
    { text: ‘Quantity’, datafield: ‘quantity’, width: 225, resizable:false },
    { text: ‘Low Quantity’, datafield: ‘low_quantity’, width: 100, resizable:false },
    { text: ‘Store Name’, datafield: ‘store_name’, width: 100, resizable:false },
    { text: ‘Zip Code’, datafield: ‘supplier_name’, width: 100, resizable:false, hidden: true },
    { text: ‘Phone Number’, datafield: ‘alert’, width: 150, resizable:false, hidden: true},
    { text: ‘Actions’, datafield: ‘date’, width: 280, editable: false, hidden: true},
    { text: ‘Price’, datafield: ‘price’, width: 280, editable: false},
    { text: ‘Total Price’, datafield: ‘total’, width: 280, editable: false}
    ]
    });

    }); //end ready
    </script>

    <—Here is how I did the select statement for the bootstrap table example. (The sql_query statement with the user session and store name, this retrieves the data based on the user session and on the store)
    <?php
    $count=1;
    $sel_query=”Select *, price * quantity as total from inventory WHERE addbyuser='”.$_SESSION[“username”].”‘ AND store_name='”.$store_name.”‘ ORDER BY ID;”;
    $result = mysql_query($sel_query);
    while($row = mysql_fetch_assoc($result)) { …

    ?>

    End of index page

    Here is my productdata.php page:

    <?php
    #Include the connect.php file
    session_start();
    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”;
    }
    $query =”Select * from inventory WHERE addbyuser='”.$_SESSION[“username”].”‘ AND store_name='”.$store_name.”‘ ORDER BY ID;”;

    if (isset($_GET[‘update’]))
    {

    }
    else
    {
    $result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
    // get data and store in a json array
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $stores[] = array(
    ‘id’ => $row[‘id’],
    ‘product_name’ => $row[‘product_name’],
    ‘quantity’ => $row[‘quantity’],
    ‘low_quantity’ => $row[‘low_quantity’],
    ‘price’ => $row[‘price’],
    ‘total’ => $row[‘total’],
    ‘store_name’ => $row[‘store_name’],
    //’addedbyuser’ => $row[‘addedbyuser’]
    );
    }

    echo json_encode($stores);
    }
    ?>

    jqxgrid $_REQUEST[store_name] #90256

    Hristo
    Participant
    jqxgrid $_REQUEST[store_name] #90280

    dan123
    Participant

    No how would i request store_name in the jqxgrid sql connection?

    jqxgrid $_REQUEST[store_name] #90295

    Hristo
    Participant

    Hello dan123,

    I am not sure I understand your question.
    I would like to ask you what you want to achieve?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.