2 SQL Queries
2 SQL Queries
yskapell
Posts: 47Questions: 14Answers: 3
Hello guys,
I have a question....
Can I run 2 different queries in 1 PHP file and return the data ?
To have sometthing like https://datatables.net/examples/api/row_details.html but without to read from txt file.
Answers
Sure. Run as many as you want (although less will be faster of course). As long as the JSON that is returned is valid, DataTables doesn't "care" what is happening at the backend
Hello Allan,
I use this
but it return no data instead of 7 rows.
Also if I hit the button second time I get the below error
You are going to have to give me a bit more than that . All I see is a string which contains an SQL statement. I don't see how it is executed, the data processed and then returned.
Please link to a test case showing the issue and show the full PHP code.
Thanks,
Allan
Hello Allan,
Test case is https://live.datatables.net/gawekelu/1/edit
PHP Code is
Thank you - I had no idea you were using the demo server-side processing class. The
$table
variable is intended to just be a table name, not a whole query itself. I suspect you would need to modify the SSP class if you needed to do that. I presume you've done that for the join?You've got three options:
This of course is assuming you need server-side processing (you have tens of thousands of rows of data).
Allan
Hello Allan,
I have the editor so I will use it.
Now what about the second issue, when I click it on second time I get error about the table
I'd need to see a test case demonstrating that issue. There is nothing wrong with the code you have shown on the live site.
The error suggests that
var table
(orlet table
) is being defined multiple times.Allan
Hello Allan,
I check the editor, but in the join one of the table is created dynamically.
Will it work properly? How will I pass the fileds with variable to json?
As in
$student_vocabulary_table
would be a value posted from the client-side? Or a session variable or something else?If you want to send the table name from the client-side use
ajax.data
for DataTables andajax.data
for Editor. Be very certain that you validate the submitted table name though! Otherwise you've got a sure fire security hole!Allan
Hello Allan,
I see that there is a security hole, thus I change it to static tables.
I have the below PHP code on which I use before and I get error on line 33
Until the line which I get the error (I see it as line 33) I copy/paste it from other file which is on same directory and it work fine.
Could you change:
to:
Which would just mean that if that include / require fails, then it will throw a fatal error at that point. That file not being included / required would explain the error you are seeing.
Allan