how to display data?

max90 12 Oct, 2011
Hello,
I created a form with several fields.
Each user registered with the site can access the form and send an unlimited number of
"requests".
The data that are sent by users are logged on the database in a table.
so I have a table with many records as many as the number of requests made by users.

But now I can not take the next step.
I want every single user can view the requests made.
then let him see the requests made by the related fields.

how do I?

using joomla 1.7 with the v4
max90 12 Oct, 2011
ho usato questo codice in "custom code":
<?php 

// qualora non fosse globalizzato, recupero il mainframe
global $mainframe;

// istanzio un oggetto di accesso al DB
$db=& JFactory::getDBO();


// questo lo chiami prima della query
$user=& JFactory::getUser();
 
$query ="SELECT * FROM #__chronoforms_data_requests WHERE cf_user_id='".$user->id."'";

// recupero il resultset
$db->setQuery($query);
$row = $db->loadRowList();
print_r($row);

// stampo a schermo l'elenco
foreach($rows as $rows) {
}
?>


But this code shows me the array.
how do I sort the results?
Also how do I put the first list of requests and after having clicked to bring up the list of fields?
GreyHead 12 Oct, 2011
Hi Max90,

Please see the DB Multi Record Loader tutorial in the Download area here and threads about it in the forums.

Bob
max90 13 Oct, 2011
I corrected the code in this way:
<?php 

// qualora non fosse globalizzato, recupero il mainframe
global $mainframe;

// istanzio un oggetto di accesso al DB
$db=&JFactory::getDBO();


// questo lo chiami prima della query
$user=&JFactory::getUser();
 
$query ="SELECT * FROM #__chronoforms_data_requests WHERE cf_user_id='".$user->id."'";

// recupero il resultset
$db->setQuery($query);
$results = $db->loadObjectList();

// stampo a schermo l'elenco
foreach($results as $r) {
echo $r->Motivo,' | ',$r->soggetto,' | ', $r->cognome,' | ', $r->nome,' | ', $r->paese_nascita,' | ', $r->provincia,' | ', $r->data_nascita,' | ', $r->cod_fiscale,' | ', $r->iva,' | ', $r->cciaa,' | ', $r->comune,' | ', $r->indirizzo_noto,' | ', $r->recapiti,' | ', $r->telefono,' | ', $r->coniuge,' | ', $r->garante,' | ', $r->professione,' | ', $r->banca,' | ', $r->note, '<br />';
}
?>


thus I correctly displays all user input array.

The problem is another.
I already read the tutorial so many times but I can not solve the problem.

I want to display a link to each "request" made ​​by the user.
When the user clicks on the link opens the form with data already entered on the request.

for now I'm only able to make them appear all the code that I put on ...
GreyHead 15 Oct, 2011
Hi max90,

The link will be something like this:
echo "<a href='index.php?option=com_chronoforms&chronoform=my_form_name&cf_id{$r->cf_id}'>View</a>";
You can then use the DB Record Load action to get the value of cf_id and display the record.

Bob
max90 26 Oct, 2011
hello, I did as you said, so:
<?php 

// qualora non fosse globalizzato, recupero il mainframe
global $mainframe;

// istanzio un oggetto di accesso al DB
$db=&JFactory::getDBO();


// questo lo chiami prima della query
$user=&JFactory::getUser();
 
$query ="SELECT * FROM #__chronoforms_data_requests WHERE cf_user_id='".$user->id."'";

// recupero il resultset
$db->setQuery($query);
$results = $db->loadObjectList();
?>


<?php foreach($results as $r) { 
echo "<a href='http://localhost/pegaso/index.php?option=com_chronoforms&chronoform=Richiesta&cf_id{$r->cf_id}'>View</a>";
}
?>


but when I click on View is a form not completed...why??

another thing, it is better to put cd_uid instead cd_id?
GreyHead 27 Oct, 2011
Hi max90,

Have you built the form to display the 'View'?

Bob
max90 27 Oct, 2011
hi
then maybe I can not understand some steps ..
I created two forms of the component.
The first form is used for data input by the user (send request), saves the data entered into the database.
Then I created another step through the component in which I put the php code we're talking about. I called this: list requests.

Now if (as if I were a user) I click on the required list are a number of links to "view" equal to the number of requests that I have provided.
But when I click on one of them I see a blank form.

I have to create another form? I do not know what to change or if I have to create another form.
max90 27 Oct, 2011
Now we have finally succeeded!
basically my problem was that I created is not the same as the form for sending data to the database.
Now that I made it work and I filled out the form correctly with the right data!

The problem now is how do I put a button called EDIT to edit and save the data in its records? (not create a new record)
GreyHead 31 Oct, 2011
Hi max90,

If the form data includes a value for the 'primary key' column in the table e.g. cf_id that already exists then the data in that record will be updated. If there's no value, or it's doesn't match an existing record then a new record is created.

Adding the Primary key value in a hidden input should be enough to get this to work.

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