Forums

Display data in rows :: some issues

sofia 11 Mar, 2008
God morning Bob,

I have been reading some posts about data retrieval using chronoforms, and followed the instructions, but i'm missing something.

I have a pets site, and i have an area called Blood Bank. I want people to register theirs pets, as blood-donors. This way, whenever a pet needs surgery and a blood transfusion, the owner, can come to my site and look for donors in their region.

STEP 1
So, i have a form to collect inscriptions from blood-donors.
I called this form, bancodesangue_collect and put it inside a content item (http://cp03.buyhttp.com/~insidepd/index.php?option=com_content&task=view&id=391&Itemid=104)

In the form i inserted this code in html form:
(read only i temporarily disabled for test purposes)

<?php
global $my,$mosConfig_live_site;
// verifica se o utilizador fez login
// o nome e email são preenchidos automáticamente e definidos como read only
//$readonl="";
if ($my->id) {
//$readonl=" readonly='readonly'";
} 
?>


<table cellspacing="5">

<tr><td colspan="2" valign="top"><h1>Dados do animal</h1></td></tr>			

<tr><td valign="middle"><label for="nomeanimal">Nome</label></td>
    <td valign="middle"><input name="nomeanimal" type="text" id="nomeanimal" /></td></tr>
    
<tr><td valign="middle"><label for="especie">Espécie</label></td>
    <td valign="middle"><select name="especie" size="1" id="especie">
  					    <option selected>Cães</option>
                        <option>Gatos</option>
    </select></td></tr>
    
<tr><td valign="middle"><label for="raca">Raça</label></td>
    <td valign="middle"><input name="raca" type="text" id="raca" value="Raça não definida" /></td></tr>        

<tr><td valign="middle"><label for="idade">Idade</label></td>
    <td valign="middle"><input name="idade" type="text" id="idade" size="5" /> anos</td></tr>

<tr><td valign="middle"><label for="peso">Peso</label></td>
    <td valign="middle"><input name="peso" type="text" id="peso" size="5" /> kg</td></tr>
    
<tr><td valign="middle"><label for="altura">Altura</label></td>
    <td valign="middle"><input name="altura" type="text" id="altura" size="5" /> cm</td></tr>    

<tr><td colspan="2" valign="top"> </td></tr>

<tr><td colspan="2" valign="middle"><h1>Reside com ...</h1></td></tr>
  
<tr><td valign="middle"><label for="user">Nome</label></td>
    <td valign="middle"><input name="user" type="text" id="user" value="<?php echo $my->name?>"<?php echo $readonl?> /></td></tr>
    
<tr><td valign="middle"><label for="email">Email</label></td>
    <td valign="middle"><input name="email" type="text" id="email" value="<?php echo $my->email?>"<?php echo $readonl?> /></td></tr>
    
<tr><td valign="middle"><label for="telefone">Telefone</label></td>
	<td valign="middle"><input name="telefone" type="text" id="telefone" /></td></tr>
    
<tr><td valign="top"><label for="distrito">Distrito</label></td>
    <td valign="top"><select name="distrito" size="1" id="distrito">
                      <option>Aveiro</option>
                      <option>Beja</option>
                      <option>Braga</option>
                      <option>Bragança</option>
                      <option>Castelo Branco</option>
                      <option>Coimbra</option>
                      <option>Évora</option>
                      <option>Faro</option>
                      <option>Guarda</option>
                      <option>Leiria</option>
                      <option selected>Lisboa</option>
                      <option>Portalegre</option>
                      <option>Porto</option>
                      <option>Santarém</option>
                      <option>Setúbal</option>
                      <option>Viana do Castelo</option>
                      <option>Viseu</option>
                      <option>Açores</option>
                      <option>Madeira</option></select></td></tr>

<tr><td colspan="2" valign="top"> </td></tr>

<tr><td valign="middle"><label for="data">Data</label></td>
    <td valign="middle"><input name="data" type="text" id="data" value="<?php echo(gmstrftime("%d/%m/%Y"«»)); ?>" /></td></tr>
       
<tr><td valign="middle"> </td>
    <td valign="middle"><input type="submit" value="Enviar" class="button"> <input type="reset" value="Limpar" class="button" /></td></tr>			
</table>


I tested through mail and everything is ok. Validation is working also.



STEP 2
In the same form (bancodesangue_collect) is have created a table. Filled the form again and send it so at the moment i have one record in my table.



STEP 3
I edited the form and checked the autogenerated code:
<?php 
	global $database;
	
$database->setQuery( "INSERT INTO #__chronoforms_2 VALUES  (
'' , '". date('Y-m-d')." - ".date("H:i:«»s"«»)."', '".$_SERVER['REMOTE_ADDR']."' , '".mosGetParam($_POST,'nomeanimal','')."' , '".mosGetParam($_POST,'especie','')."' , '".mosGetParam($_POST,'raca','')."' , '".mosGetParam($_POST,'idade','')."' , '".mosGetParam($_POST,'peso','')."' , '".mosGetParam($_POST,'altura','')."' , '".mosGetParam($_POST,'user','')."' , '".mosGetParam($_POST,'email','')."' , '".mosGetParam($_POST,'telefone','')."' , '".mosGetParam($_POST,'distrito','')."' , '".mosGetParam($_POST,'data','')."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>




STEP 4
I have created a second form, called bancodesangue_display and put it inside a content item (http://cp03.buyhttp.com/~insidepd/index.php?option=com_content&task=view&id=447&Itemid=104)



STEP 5
I went to Profile page for bancodesangue_display form, and filled this way:
Table: chosed "jos_chronoforms_2" from the list
REQUEST Parameter name: typed "bancodesangue_id"
Target field name: typed "cf_id"


I believe this is where i have the mistake, because, i don't really understand REQUEST Parameter name.


STEP 6
Last, i went to the form bancodesangue_display, and typed in html for the following code:
<?php
// initialise the database code
global $database;
$sql = "SELECT * FROM #__chronoforms_2;";
$database->setQuery($sql);
$rows = $database->loadObjectList();
echo "<table><tr>
  <td>Dadores</td></tr>";
foreach ( $rows as $record ) {
  echo "<tr>
    <td>".$nomeanimal."<br />
        ".$especie."<br />
        ".$raca."<br />
		".$idade."<br />
		".$peso."<br />
		".$altura."<br />
		".$user."<br />
		".$email."<br />
		".$telefone."<br />
		".$distrito."<br />	
        ".$data."</td>
  </tr>";
}
echo "</table>";
?>


I'm not sure of this step too. I'm not sure if this piece of code should be in html form or other place ...

Anti-spam and validation are set to no on this form.

When i check the content item that as bancodesangue_display, i received this error message:
Fatal error: main() [function.require]: Failed opening required '' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/insidepd/public_html/components/com_chronocontact/plugins/cf_profile.php on line 4


Can you help me?
GreyHead 12 Mar, 2008
Hi sofia,

I can help with the REQUEST parameter name. The PlugIn assumes that you are going to call it with a url that will identify the record you want displayed so you might have [someurl]&record_id=999

The REQUST parameter here is 'record_id'

The error message is more baffling, maybe if you fix the REQUEST id it will go away - or maybe Max can explain.

Bob
Max_admin 12 Mar, 2008
Hi Sofia,

a quick fix may be by commenting this line :

require_once( $mainframe->getPath( 'class' ) );


However, the code you are using will not work with the profiler plugin, basically the profiler plugin was made to make it easy for user to retrieve one row data only from the table without using any code, so, using code cant make your job to retrieve many rows easier, instead you can only use a normal form and put the same code you have and edit your table cells to have values like this :

$record->nomeanimal instead of $nomeanimal only😉

Please try my 2nd suggestion above before hacking the cf_profile file, just turn the cf_profiler for this form OFF and take the 2nd way.

Cheers,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sofia 12 Mar, 2008
Thanks a lot Max.

It's so much simple than i thought. I canceled the plugin profile page on the form bancodesangue_display. After all, as you say, i don't need it to display data from other form.

Edited the form html code, and replaced $nomeanimal for $record->nomeanimal, and it worked at first.

You and Bob are great. The best support team i found since i work with joomla.

I will remember to say a word about you in joomla extensions.
You deserve.

And i would like to make a small donation, because i truly believe that good work should be paid. I would like to donate $50. It's not much, but it´s what i can give😛
Is there any way i can make it directly or shall i simply buy 2 licences to make that value?

Big hug for both of you😉

Sofia
Max_admin 12 Mar, 2008
Thank you so much Sofia, you can buy 2 licenses, this way you get more sites licenses and at the same time help the project!🙂

Sincerely,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sofia 13 Mar, 2008
Done!

Kiss,

Sofia
Max_admin 14 Mar, 2008
Thanks so much Sofia!!🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.