How to Customize Select From?

How to Customize Select From?

hugocubhugocub Posts: 4Questions: 0Answers: 0
edited June 2011 in General
What I want to do is select from the database where id="$id" But I can't find what part of the code I need to change.

Replies

  • hugocubhugocub Posts: 4Questions: 0Answers: 0
    Anyone?
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi hugocub,

    How are you getting your data into the table - is it with server-side processing? Or are you using a DOM source or Ajax source?

    If you are using server-side processing, then working with the code here: http://datatables.net/development/server-side/php_mysql , what you want to do just after line 96 is something like this:

    [code]
    if ( $where != "" ) {
    $where .= ' AND id = '.$id;
    } else {
    $where = 'id ='.$id;
    }
    [/code]
    If one of the other options, then where are you pulling the information from your database? That is where the extra condition would need to go.

    Regards,
    Allan
  • hugocubhugocub Posts: 4Questions: 0Answers: 0
    I am using the server side processing with the detail drop down. http://datatables.net/examples/server_side/row_details.html

    Will this still work with that?
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Yes indeed - the row details example's server-side processing script is based off the linked PHP script - so the basic idea still applies. Basically what you want to do is to get the ID into the server so that it can be processed on each draw. Where is the ID variable coming from?

    Allan
  • hugocubhugocub Posts: 4Questions: 0Answers: 0
    It is being taken from the user database in the functions.php file. Which I am including in details_col.php
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    I don't know what your functions.php file looks like, but presumably if you have an SQL query, then the same basic ideal still applies. You just need to add a WHERE condition on your id.

    Allan
This discussion has been closed.