Forums

View details

PicoPaco 20 May, 2010
Hi, I have a database table that I by ChronoConnectivity view a list of records from. In the list I've created a view details link that I try to get to show the details of the record. For the detail view I created a new connectivety where all the data will be shown from just one record. To make it to just show one record I try to use the WHERE SQL field, where I write WHERE id = '{id}'. But I dont get this to work. What am I doing wrong? Isn't this the way to go?


Regards

Markus
GreyHead 20 May, 2010
Hi Marcus,

That might work but I use a ChronoForm instead - it's easier to get that to display one record.

In the View Details url add &task=extra&tmpl=component then use the Extra Code 1 box of the form to add the code to display the detail view.

Bob
PicoPaco 20 May, 2010
Hi GreyHead,

Thanks for a quick answer. But how do I get data from the table into ChronoForms? I have now created a new ChronoForm named details. What would the code be like in the extra code field?


Thanks!
GreyHead 20 May, 2010
Hi Marcus,

Load it directly from the database. Here's a (simplified) copy of some code I'm using right now to display a detail view.
<?php
$task  = JRequest::getString('task', '', 'get');
$cf_id = JRequest::getString('cf_id', '', 'get');
if ( !$task || !$cf_id ) {
    global $mainframe;
    $mainframe->enqueuemessage("Sorry, the record was not found");
    return;
}
$db =& JFactory::getDBO();
$query = "
	SELECT *
		FROM `#__chronoforms_job_list`
		WHERE `cf_id` = $cf_id ;
";
$db->setQuery($query);
$j = $db->loadObject();

$title_bar = "$j->job_title | $j->location ";
echo "	<div id='view-details'>
	<div id='top_bar' style='border-bottom:1px solid silver; padding:3px; font-weight:bold;'>$title_bar</div>
	<div id='mid_bar' style='padding:3px;'>
		<div style='padding-bottom:6px;' >Job title : $j->job_title</div>
		<div style='padding-bottom:6px;' >Location : $j->location</div>
		<div style='padding-bottom:6px;' >Closing date : $j->closing_date</div>
		<div style='padding-bottom:6px;' >Company : $j->company</div>
		<div style='padding-bottom:6px;' >Type : : $j->job_type</div>
		<div style='padding-bottom:6px;' >Job description : $j->job_description</div>
	</div>
</div>";
?>

Bob
PicoPaco 25 May, 2010
Thanks alot GreyHead this works perfect!

Another question regarding Chronoforms.
I have a ChronoForm where the name of the user currently inlogged will be stored in the database. To do this I created a disabled field like this:
<input type="text" name="createdBy" value="<?php echo $user->name; ?> " id="createdBy" disabled="disabled" />


The name of the user shows in the field, but when I run the form the name do not stores in the database. All other information in this ChronoForm stores as it should, but not the name. Do you or anyone else know why this is?
GreyHead 25 May, 2010
Hi PicoPaco,

Disabled inputs don't send anything back when the form is submitted. User readonly='readonly' and you'll get the result. Or use a input with type='hidden'.

You may not need this at all as ChronoForms tables will save the User Id in the cf_user_id column for you.

Bob
CalandraPhotos42 22 Jun, 2010
I have the same situation also and thank you for this queers I don't have to research more and the instructions are great. so thank you!
blackersoul 14 Jul, 2010
Hi all😀
I had some troubles with the GreyHead's code. I'm just a beginer and I've never seen some code like this, ' Cause I only know sql basics.

SO It runs but I'm not able to maintain the styles , It only loads a white page and the text printed on the Echo's php code.
I did some changes, That's my code:
<?php
$task  = JRequest::getString('task', '', 'get');
$nom= JRequest::getString('nom', '', 'get');


if ( !$task || !$nom) {
    global $mainframe;
    $mainframe->enqueuemessage("Sorry, the record was not founded");
    return;
}
$db =& JFactory::getDBO();
$query = "
   SELECT *
      FROM `jos_chronoforms_insercio_bestia`
      WHERE `nom` = $nom;
";



$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("hordes", $con);

$result = mysql_query(" SELECT * FROM `jos_chronoforms_insercio_bestia` WHERE `nom` LIKE 'joan' ");

while($row = mysql_fetch_array($result))
  {
  
  }

mysql_close($con);
?>


Could someone explain me a litle bit what Greyshead's code say or at least , why me code loses the style & template ?


Thank's in advance !
GreyHead 14 Jul, 2010
Hi blackersoul ,

Hmmm . . . I can recognise that as my code up to the $query line . . . after that you are doing something of your own.

Your code doesn't appear to output anything so it's a bit hard to know what to suggest. But the first part could look like this:
<?php
$task  = JRequest::getString('task', '', 'get');
$nom= JRequest::getString('nom', '', 'get');


if ( !$task || !$nom) {
    global $mainframe;
    $mainframe->enqueuemessage("Sorry, the record was not founded");
    return;
}
$db =& JFactory::getDBO();
$query = "
   SELECT *
      FROM `#__chronoforms_insercio_bestia`
      WHERE `nom` = ".$db->quote($nom)." ;
";
$db->setQuery($query);
$result = $db->loadArrayList();

foreach ( $result as $v ) {
  // do something
}
?> 


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