Hi Bob & Max !
Recap : Using CCV5 to create a listing of static category info from a specially created DB table called 'undatecnames'. On click CCV5 loads a CFV5 form & passes that form the variable 'gcb'. The CFV5 form uses that variable to call in a row from 'undatecnames' as follows :
CFV5 setup :
CFV5 > Setup > On Load > DB Read > Table Name : dbprefix_updatecnames | ModelID : category | Conditions : < ? php return array('id' => $form->data['gcb']); ? >
CFV5 > Setup > HTML (Render Form) > Submit event : submit | Form method : Post
CFV5 > Code > Custom Code :
(Above - name='category[published]' - I'm not sure that this the value to pass to 'Submit' ? And is this the right way to use 'On Submit' ? Do I need to incorporate the Action Label in some way ?
CFV5 > Setup > On Submit > Custom Code > Action Label : update_cats_now
CFV5 > Setup > On Submit > Custom Code > Content
As always - any advice / help appreciated.
Cheers Paulzero
Whole story at www.chronoengine.com/forums/posts/t102871/update-4-different-db-tables-with-2-common-values.html
Recap : Using CCV5 to create a listing of static category info from a specially created DB table called 'undatecnames'. On click CCV5 loads a CFV5 form & passes that form the variable 'gcb'. The CFV5 form uses that variable to call in a row from 'undatecnames' as follows :
CFV5 setup :
CFV5 > Setup > On Load > DB Read > Table Name : dbprefix_updatecnames | ModelID : category | Conditions : < ? php return array('id' => $form->data['gcb']); ? >
CFV5 > Setup > HTML (Render Form) > Submit event : submit | Form method : Post
CFV5 > Code > Custom Code :
< ? php
$catid = $form->data['gcb'];
echo "<h4>'Category ID = $catid</h4>";
? >
<table style="width:100%;" >
<tbody>
< ? php
foreach ( $form->data['category'] as $p ) {
echo "<tr>
<td colspan='2' width='100%' ><h4>Category Name | {$p['name']}</h4></td>
</tr>
<tr>
<td style='padding: 8px;' width='27%' >Com_Con db-ID</td>
<td style='padding: 8px;' width='73%'>{$p['com_con']}</td>
</tr>
<tr>
<td style='padding: 8px;' width='27%' >Published 0=Unpub 1=Pub</td>
<td style='padding: 8px;' width='73%'>{$p['published']}</td>
</tr>
</tbody>
</table>";
}
? >
< ? php
$pubstate = $form->data['published'];
if ( $pubstate = "1" ) { echo "Current Category State | Published"; } // OK
? >
< ? php
if ( $pubstate = "1" )
{ $p['published'] = "0";
echo " | $ p-published | " . $p['published'] ; // OK - get 0
echo "<input type='hidden' name='category[published]' /><br>
<input class='button' style='background-color:red;' type='submit' value='Un-Publish This Category' /><br>" ;}
? > "
(Above - name='category[published]' - I'm not sure that this the value to pass to 'Submit' ? And is this the right way to use 'On Submit' ? Do I need to incorporate the Action Label in some way ?
CFV5 > Setup > On Submit > Custom Code > Action Label : update_cats_now
CFV5 > Setup > On Submit > Custom Code > Content
< ? php
// Update - com_con categories
$query = "
UPDATE `dbprefix_categories`
SET
`title` = '{$form->data['cat_name']}',
`published` = $form->data['published']
WHERE `id` = 'com_con' ;
";
$db->setQuery($query);
$save = $db->execute();
? >
As always - any advice / help appreciated.
Cheers Paulzero
Whole story at www.chronoengine.com/forums/posts/t102871/update-4-different-db-tables-with-2-common-values.html