Jump to content
Server Maintenance This Week. ×

Problem updating record using FMEdit


This topic is 4464 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I'm attempting to update the number of times a Knowledge Base Article has been viewed when they click to view the article, however being new to using FX.php I can't seem to get this to work correctly. I would appreciate any insight and feedback on how to set this up correctly. Thank you in advance.

<?php

$kb_articles = $_GET['id'];

// Inialize session

session_start();

error_reporting (E_ALL ^ E_NOTICE);

define("DEBUG", false);

include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/FX.php");

include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/server_helpdesk.php");

$returncount = 1;

$query = new FX($serverIP, $webCompanionPort, $dataSourceType);

$query->SetDBData ("HelpDesk.fp5", "Main", "$returncount");

$query->SetDBUserPass ($webUN, $webPW);

$query->AddDBParam('ID',$kb_articles,'eq');

$result = $query->FMFind();

?>

In the body section of the php page I have:

<?php

foreach ($result['data'] as $key => $value) {

echo '<div id="popupevents">';

echo '<h2>Knowledage Base Article: '.$value['ID'][0].'</h2>';

echo '<table id="kba_table" cellspacing="0" summary="Knowledge Base Article Information" border="1">';

echo '<caption>Knowledge Base Article: '.$value['ID'][0].'</caption> ';

echo '<tr>';

echo '<th scope="col" abbr="Title" class="title" width="25%">Title:</th>';

echo '<td>&nbsp;'.$value['Title'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Category ID">Category:</th>';

echo '<td>&nbsp;'.$value['Category1'][0].', '.$value['Category2'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Summary">Summary:</th>';

echo '<td>&nbsp;'.$value['Summary'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Description">Description:</th>';

echo '<td>&nbsp;'.nl2br($value['Description'][0]).'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Creation Date">Creation Date:</th>';

echo '<td>&nbsp;'.$value['Creation_Date'][0].' by '.$value['Created_By'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Modification Date">Modification Date:</th>';

echo '<td>&nbsp;'.$value['Modification_Date'][0].' by '.$value['Modified_By'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Keywords">Keywords:</th>';

echo '<td>&nbsp;'.$value['Keywords'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Platform">Platform:</th>';

echo '<td>&nbsp;'.$value['Platform'][0].'</td>';

echo '</tr>';

echo '<tr>';

echo '<th scope="col" abbr="Operating System">Operating System:</th>';

echo '<td>&nbsp;'.$value['Operating_System'][0].'</td>';

echo '</tr>';

echo '</table>';

echo '<p class="space"></p>';

echo '<a href="javascript:window.close();">Close This Window</a>';

echo '</div>';

$viewcount = ++$value['Views'][0];

$queryadd = new FX($serverIP, $webCompanionPort);

$queryadd->SetDBData ("HelpDesk.fp5", "Main");

$queryadd->AddDBParam('-recid', $viewcount);

$queryadd->AddDBParam('Views', $viewcount);

$updateResult = $queryadd->FMEdit();

echo $viewcount;

}

?>

When I echo the $viewcount; it returns the correct value but the 'Views' field in the database isn't being adjusted. I'm sure I have something wrong in the italicized section. Again thanks for your help. -Ken

Link to comment
Share on other sites

  • Newbies

After doing some more research and experimenting with code I got it to work today. Here is the change that I made:

$recordPointers = explode ('.', $key);

$updateResult = $recordPointers[0];

$viewcount = ++$value['Views'][0];

$queryadd = new FX($serverIP, $webCompanionPort);

$queryadd->SetDBData ("HelpDesk.fp5", "Main");

$queryadd->SetDBUserPass ($webUN, $webPW);

$queryadd->AddDBParam('Views', $viewcount);

$queryadd->AddDBParam('-recid', $updateResult);

$updateResult = $queryadd->FMEdit();

Items in red have been added/modified. If anyone has an easier or cleaner way of doing this please let me know. Thanks.

-Ken

Link to comment
Share on other sites

This topic is 4464 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.