Wednesday, September 27, 2023

Solved – Chronoforms V5 won’t add database entry because of duplicate id – 1062 – Duplicate entry ’28’ for key ‘PRIMARY’

I had to hard code a URL and pass some parameters to a Chronoform in an article. The form submitted to a database. The form submission was taking the article ID as the form’s unique ID, so I could only submit once.

Bob Janes with Chronoforms totally fixed my issue with unsetting the varible with custom PHP.

https://www.chronoengine.com/faqs/70-cfv5/5234-my-form-data-isnt-saving-to-the-database-correctly-2.html

I hope this helps someone else out there…

 

 

using Join with Joomla 3 select statement

I took a while to get this right.

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query ->select(array(‘a.id’, ‘a.name’, ‘b.user_id’, ‘b.body’))
->from($db->quoteName(‘#__users’, ‘a’))
->join(‘INNER’, $db->quoteName(‘#__user_notes’, ‘b’) . ‘ ON (‘ . $db->quoteName(‘a.id’) . ‘ = ‘ . $db->quoteName(‘b.user_id’) . ‘)’)
->where($db->quoteName(‘b.body’) . ‘ = \'<p>anx001</p> \”);$db->setQuery($query);
$results = $db->loadObjectList();echo ‘<table border=”1″ cellpadding=”5″>’;
echo ‘<tr><td>ID</td><td>NAME</td></tr>’;foreach ($results as $row) {
echo “<tr><td>{$row->id}</td><td>{$row->name}</td></tr>”;
}
echo ‘</table>’;

The double quotes on the echo in the foreach loop was necessary. If I used single quotes it didn’t display the names I was looking for.

I hope this helps someone else out there….

 

Joomla 3 – sample query of the database

Here is a snippet of code I often need to build a database query in Joomla.

 


<?php

<?php

$db = JFactory::getDbo();
 
$query = $db->getQuery(true);

// Individual fields 
//$query->select($db->quoteName(array('firstname', 'lastname')));
 // or all fields
$query->select('*') ;

$query->from($db->quoteName('#__free_month')); 
$db->setQuery($query);   $results = $db->loadObjectList();

 echo '<ul>';

foreach ($results as $row) {

echo "<li>{$row->firstname} {$row->lastname}</li>";

}

echo '</ul>';


?>

Centering a div between a div floating left and a div floating right – Responsively

Here is what I ended up using for the CSS

<style>
#contain {
width: 100%;
padding: 0;
margin: 0;
display: table;
}
#left,
#right {
text-decoration: none;
display: table-cell;
width: 310px;
text-align: center;
background: #FF9000;
color: #FFFFFF;
padding: 2% 0;
}
#filler {
display: table-cell;
width: auto;
background: #F00;
text-align: center;
}

@media (max-width: 800px) {

#contain {
display:block;
width: 100%;
}

#left,
#right {

display: block;
width: 100%;
}

#filler {
display: block;
width: 100%;
}

}

</style>

Here is the HTML.

<div id=”contain”>
<div id=”left”>1</div>
<div id=”filler”>m</div>
<div id=”right”>2</div>
</div>

I used the following link to get this result.

http://stackoverflow.com/questions/21782502/how-to-make-a-divs-width-stretch-between-two-divs

I hope this helps someone else out there…

CSS transitions – Background Color

Here is an example using a class

.someclass {
-webkit-transition: background-color 2s;
-moz-transition: background-color 2s;
-o-transition: background-color 2s;
transition: background-color 2s;
}

.someclass:hover {
background-color: #new color;
}

This page helped me get it working.

transition

Here is a link to all the properties that can be effected.

https://www.w3.org/TR/css3-transitions/#animatable-properties

I hope helps someone else out there…

Make a div / div tag a hyperlink or link

This tip is very helpful with today’s web where a lot of the graphic stuff such as drop shadows and gradients are being done through CSS.

<div onclick="location.href='newurl.html';">&nbsp;</div>

New Window:

<div onclick="window.open('newurl.html','mywindow');" style="cursor: pointer;">&nbsp;</div>

 

I hope this helps someone else out there….

 

Filter Google Analytics by Geo Location such as United States Only

We run Analytics for companies that only operate in the US, so when I see 51 hits from Russia it is worthless to my customers. The answer is to filter their results so we can really understand their web traffic.

Here is how I set it up.

  1. Go into the Analytics account and click on the “Admin” tab at the top, and select “Filters” under the “View” section.
    analytics_1
  2. Click “Add Filter”.
    analytics_2
  3. Hit the “Custom” button, check “Exclude”, and the “Select Field”.
    analytics_3
  4. Scroll down and select “Country”.
    analytics_4
  5. Then type in “United States”, click “Save”.
    analytics_5

You’re done!

I hope this helps someone else out there…