2 ways to edit results

caroline 18 May, 2009
Hi,
I just start using CC to edit datas from a table. Those datas will diplays in a page that can be reached by 2 ways :
- from a research on 2 parameters,
- directly from an menu item and show all datas.
no problem with the 1st way, it work fine. But with the second way, the first call of the page displays no data because the 2 parameters have no value.
How can I do
Thanks in advance
GreyHead 18 May, 2009
Hi caroline,

Set default values for the parameters in the Header block.

Bob
caroline 19 May, 2009
Hi GreyHead,

Must I use session variable ?
How can I see my query ?

Thanks in advance
GreyHead 19 May, 2009
Hi caroline,

I imagine that you can just get the $_GET variables from the URL but it's hard to tell without more specific information.

What URL are you using to make the link?

Bo
caroline 25 May, 2009
Hi GrayHead,

Here is a description of the 2 pages :
1) The search page use 2 dropdown lists : Competences an Regions. Those parameters are POST variables. The query in CC is :
WHERE (Competence1 = '{PARAM_RefCompetence}' or Competence2 = '{PARAM_RefCompetence}' or Competence3 = '{PARAM_RefCompetence}' or '{PARAM_RefCompetence}' = 'ALL') and (SigleRegion = '{PARAM_SigleRegion}' or '{PARAM_SigleRegion}' = 'ALL')
This query works well.

2) a page call directly from an menu item and showing all datas
I try in vain modify the query to create a php paramatrized query in order to get all datas. Can you help me ?
GreyHead 25 May, 2009
Hi caroline,

Can you use an External URL link for the menu and add &search=all to the url. Then you could do this in the Where box:
<?php
$search = JRequest::getString('search', '', 'get');
if ( $search ) {
  $where = '';
} else {
  // drop-down search code here
}
?>

Bob
caroline 25 May, 2009
thanks GrayHead,

The 2nd page (all datas, directly from menu) woks fine, even without &search=all in th url.
But the search by dropdown list Competences an Regions allways shows all datas.
Must I use GET variables instead of POST variables ?

thanks in advance
Caroline
GreyHead 25 May, 2009
Hi caroline,

Please post the code you are using in the Header & Where boxes. In general use GET for parameters in URLs and POST for parameters from forms.

Bob
caroline 25 May, 2009
Hi GreyHead,

here is my code

WHERE SQL:
<?php
$search = JRequest::getString('search', '', 'get');
if ( $search ) {
  $where = '';
} else {
  // drop-down search code here
$where="WHERE (Competence1 ='{PARAM_RefCompetence}'or Competence2 = '{PARAM_RefCompetence}' or Competence3 = '{PARAM_RefCompetence}' or '{PARAM_RefCompetence}' = 'ALL') and (SigleRegion = '{PARAM_SigleRegion}' or '{PARAM_SigleRegion}' = 'ALL')";
}
?>


Header:
<?php
$_POST['PARAM_RefCompetence']='';
$_POST['SigleRegion']='';
?>
<table> ..... </table>


POST Variables:PARAM_RefCompetence,PARAM_SigleRegion

URL from the menu item : index.php?option=com_chronoconnectivity

Thanks in advance
GreyHead 25 May, 2009
Hi caroline.

In a rush but there's a vital line missing at the end of the where box
. . .
'{PARAM_SigleRegion}' = 'ALL')";
}
echo $where; //  <-- add this line
?>

Bob
caroline 25 May, 2009
thanks GreyHead, it works ... but my post variables are not reinitialized.
I have define default values in header code ($_POST['PARAM_RefCompetence']=''; $_POST['SigleRegion']='';).
Can you still help me ?

thanks in advance
caroline
GreyHead 26 May, 2009
Hi Caroline,

I don't understand what those lines in the header are doing? Where are the parameters used?

Bob
This topic is locked and no more replies can be posted.