0

I've been using this PLUGIN for representing my data from mysql database.

I am using this script EXAMPLE for server side processing.

Now this script is working perfectly why you have one table. But problem is occurring when I have multitable query.

For example I have:

$sWhere = "a.ID=b.ID AND b.Name=c.Name";

This is only where variable. If you go to the link that I gave you can see the php script that is used to fetch data. When I put more then one table I get unique table error. And the search functions can't work.

Can someone show me how to use this script to be able to have multiple tables included in one query.

If you need more source let me know.

EDIT:

My HTML:

<table id="table_my" width="100%" border="1" cellspacing="2" cellpadding="5" class="chart_1">
                <thead>
                    <tr class="even">
                        <th>A</th>
                        <th>B</th>
                        <th>C</th>
                        <th>D</th>
                        <th>E</th>
                        <th>F</th>
                        <th>G</th>

                    </tr>
                </thead>

              <tbody>
              </tbody>
              </table>

2 Answers 2

0

There should be a change in the HTML Markup, when that multitable query executes. Why don't you compare both and check for the difference in the HTML Markup?

The markup for DataTable jQuery plugin should be this way:

<table>
    <thead>
        <tr>
            <th>Column Name</th>
            <th>Column Name</th>
            <th>Column Name</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Row Value</td>
            <td>Row Value</td>
            <td>Row Value</td>
        </tr>
        <tr>
            <td>Row Value</td>
            <td>Row Value</td>
            <td>Row Value</td>
        </tr>
        <tr>
            <td>Row Value</td>
            <td>Row Value</td>
            <td>Row Value</td>
        </tr>
        <tr>
            <td>Row Value</td>
            <td>Row Value</td>
            <td>Row Value</td>
        </tr>
    </tbody>
</table>

Also remember, it doesn't work with more than one tbody or thead tag and tables without these tags. Also, if you have used colspan and rowspan attributes, it doesn't work.

8
  • My table print I mean columns and data is correct when I use one table in query. Problem is when my query fetches data from multiple tables. My problem is probably with php Jun 6, 2012 at 11:54
  • Is it possible for you to post the rendered HTML for both single table query and multi table query? Jun 6, 2012 at 11:57
  • Maybe I am not explaining as I should I want to represent only one table in html. But my query is fetching data from more then one tables. As you can see in the above question. HTML stay only one table Jun 6, 2012 at 12:07
  • I understand that. But when you fetch from multiple tables, you had issue right, so lets compare that markup of the single HTML table of multiple DB tables so that it doesn't deviate from the required thing. Hope this makes sense. Jun 6, 2012 at 12:13
  • Okay, I am getting a JSON format problem. Something like table needs to be unique Jun 6, 2012 at 12:15
0

from www.facebook.com/Heanock Z behere Ethiopia *

Answer for the above problem

* i just use like i am using in php or other language and i have two tables to be joined tbl_employees **

emp_id

** int(11) auto_increment primary key, emp_name varchar(50), sex enum('female','male'), emp_dept varchar(50), emp_salary double, job int(11) = is foreign key that i will share from the second table

tbl_job

**

job_id

** int(11) primary key, job_name varchar(50), job_cat varchar950)

lastly here is my code in php mysql plus datatable

Emp ID Emp Name Sex Department Salary Job Edit Delete

    $stmt = $db_con->prepare("SELECT emp_id,emp_name,sex,emp_dept,emp_salary,job_name FROM tbl_employees,tbl_job where job=job_id ORDER BY emp_id DESC");
    $stmt->execute();
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    {
        ?>
        <tr>
        <td><?php echo $row['emp_id']; ?></td>
        <td><?php echo $row['emp_name']; ?></td>
        <td><?php echo $row['sex']; ?></td>
        <td><?php echo $row['emp_dept']; ?></td>
        <td><?php echo $row['emp_salary']; ?></td>
        <td><?php echo $row['job_name']; ?></td>

if you have any question related with above problem write me @ [email protected] or My facebook Page listed Above

Thanks very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.