Hi hope someone can help
I can't seem to figure out how to query the database using a name value pair from the calling URL.
My table is 4 columns, ID, Course, Date and Location and I want to filter the table by Course, i.e. call the table using something like schedule.php?course=Excel I saw on one post that you can use qf1 but it doesnt work and just returns all the data.
Any help gratefully received, thanks
Bats
|
| Batninja Napísal: |
Hi hope someone can help
I can't seem to figure out how to query the database using a name value pair from the calling URL.
My table is 4 columns, ID, Course, Date and Location and I want to filter the table by Course, i.e. call the table using something like schedule.php?course=Excel I saw on one post that you can use qf1 but it doesnt work and just returns all the data.
Any help gratefully received, thanks
Bats |
Hi, after dredging through the online docs this how I found a way to do it.
place your URL on the column you wish to use as the filter, in your case Course...
| Kód: |
$opts['fdd']['Course'] = array(
'name' => 'Course',
'select' => 'T',
'maxlen' => 10,
'URL' => 'courses.php?course=$value',
'URLtarget' => '_blank',
'sort' => true
); |
$value is the value of the field your mouse is hovering over.
Now inside courses.php place the following in between your !Doctype and html tags
| Kód: |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<?php
// Use this to filter for Course
$course = @$_REQUEST['course'];
?>
<html>
<head>
|
Now scroll down until you find
| Kód: |
// Set default prefixes for variables
$opts['js']['prefix'] = 'PME_js_';
$opts['dhtml']['prefix'] = 'PME_dhtml_';
$opts['cgi']['prefix']['operation'] = 'PME_op_';
$opts['cgi']['prefix']['sys'] = 'PME_sys_';
$opts['cgi']['prefix']['data'] = 'PME_data_'; |
We add a persist prefix to the end of this list so our URL data is available across all screens, ie Add, Change, Copy and Delete. So append to bottom, this line.
| Kód: |
$opts['cgi']['persist'] = array('course' => $course);
|
And finally we apply a Filter to our value - the Filters are usually commented out under the Langauge option - uncomment one and set it so.
| Kód: |
/* Table-level filter capability. If set, it is included in the WHERE clause
of any generated SELECT statement in SQL query. This gives you ability to
work only with subset of data from table.
*/
$opts['filters'] = 'Course REGEXP "^'.$course.'"';
|
Now when you call your courses.php, all you should see is a list of the single course.
Hope it helps..
|