Counter field in database table

Am just thinking about how to solve a little problem which is new to me in PHP, but I'm hoping not to complex.
Basically, I have a database of holiday resorts, and my client would like to keep track of how many people click through to the resorts own website from our website.
So I was thinking if I have a field ClickCounter, initially set to 0, would there be some way to have a link that, once clicked on, would increment the ClickCounter field by 1.
If anyone could help me get started with this, that would be much appreciated.
Thanks.

Thanks for that.
I've got a table - lodges, in the end - with fields LodgeID, Lodge and Hits.
And a page with a couple of links here :
http://www.goodsafariguide.com/countertest.htm
(Am using LodgeID rather than Lodge as the identifier after the ? though).
And a hit_counter.php page which looks like this :
<?php require_once('Connections/databaseConnection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break; 
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
mysql_select_db($database_databaseConnection, $databaseConnection);
$query_rsLodges = "SELECT * FROM lodges";
$rsLodges = mysql_query($query_rsLodges, $databaseConnection) or die(mysql_error());
$row_rsLodges = mysql_fetch_assoc($rsLodges);
$totalRows_rsLodges = mysql_num_rows($rsLodges);
$the_resort = "-1";
if (isset($_GET['LodgeID'])) {
$the_resort = $_GET['LodgeID'];
$query_hits = sprintf("UPDATE lodges
SET Hits = Hits+1
WHERE LodgeID = %s",
GetSQLValueString($the_resort, "text"));}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
<?php
mysql_free_result($rsLodges);
?>
I changed the Hits update part to reflect the different fields, but its not doing anything yet.
Is this along the right lines though?

Similar Messages

  • How to add a value table to a field in database table?

    Dear Experts,
    Normally a value table can be added in the domain.
    And the field of the database table will have the value table, to which this domain is assigned.
    My question is.. Is it possible to assign a value table to any field ina database table, directly?(i.e. <b>without assigning to that domain</b>)
    If yes.. please let me know the <b>step-by-step</b> procedure clearly.
    Thanks to U in advance.

    Hi sr,
    1. what is the purpose of your value table ?
      -- so that the user can select values
       from some master table , for that field !!!!
    2. This is done by
        CHECK TABLE (foreign key concept)
       (and not value table)
    3. When we create a check table for a field,
       then
       some DEFAULT table is PROPOSED
       . that DEFAULT table is nothing
      but PICKED up from the domain of that field,
      and shown from the value of VALUE TABLE.
      (we can change it however)
    4. so for your purpose,
       just create a CHECK TABLE.
    regards,
    amit m.

  • Delete L.H.S spaces from field in database table but not for Report

    Dear Experts
    I m facing a problem...actaually i have replaced 999 by blank in a field of database table record.
    Like :     999 abcde
                 999999 hjklmn
                 9999 klplmj
                 99999 hjsfhh
    I have replaced 9 by blank. and using CONDENSE statement i have avoid the left hand side spaces of 9 in the database table.
    Means the data is updated in database table following below using Condense.
    Like:     abcde
                hjklmn
                klplmj
                hjsfhh
    Now,  the problem is that these spaces is showing in the Report. The left hand side spaces is not deleting from the Report. But these spaces is not showing in the databse table.
    Plz tell me wat is the reason and wat is the solution to avoid these space from the Report.
    Note: That field is Character Field.   KNA1-STRAS
    Thanks and Regards,
    Swapnika

    Hello
    Try to use
    SHIFT c LEFT  DELETING LEADING SPACE.
    instead of
    CONDENSE...

  • Add time field in database table

    Hi Gurus,
    I am trying to add a time field in database table. I know i can add it by using append structure.
    but my problem is when records r creating in database table, the time field also populate with respective system time automatically. i think i need to use events but i have no idea how to use.
    is there any other method available?
    is there any system field for time stamp as date + time?
    Regards
    Giri

    Rob,
    its not updating by table maintainance generator.
    I want to add Time field in table ESTDH. 
    when a new record updated while report version generated the time field also populate with system field.
    is it possible?
    can anybody help me?
    Regards
    Giri

  • What is the Function MOdule that returns the fields in database table order

    Hello Folks
      I have a dynamic internal table with fields ( which are not in order). I want to display them in the order of which they are present in the database table? Is there any function module that returns the fields in database order?
    FAQ. Please search before posting your question.
    Edited by: Suhas Saha on Oct 10, 2011 10:19 PM

    Hi,
    You can use this BAPI.
    <b>BAPI_SALESORDER_GETLIST</b>
    Reward if useful.
    Regards,
    Vimal

  • Hi friends, I have a doubt in inserting a field to database table and inserting the same values in two different tables

    I have a mpp screen for a cd library management system (we are practicing on it).
    We have a main screen where a user should enter the enteries and while clicking a add button it should be inserted in a table, Here the problem rises the table name are ztransaction and zstatus.The fields in mpp are cdid,customerid,transaction id,date of issue and duedate.Now after entering all the values on clicking add button it should be inserted to database table ztransaction and the field cdid alone should be inserted both in ztransaction and zstatus.
    Thank you

    Hi Raghuram R G,
    Check for Primary key and foreign key in the Database table??? Because of this it was not inserting...check and confirm??
    Regds,
    Vijay SR

  • Adding fields to database table and copying data from other fields

    Hi All,
    I am having a database table where in I am having a column 'FIELD1'.
    My requirement is that I want to add two more fields in the table 'FIELD2' and 'FIELD3'.
    I then want to copy all the data in field1 to field2 and field3. then I want to delete the original field1.
    for Ex.
    lets say FIELD1 = 100.
    now I want to add FIELD2 and FIELD3 in the table and make FIELD2 = 100 AND FIELD3 = 100. The FIELD1 will be deleted from table.
    Please suggest the methods to do so.
    It is urgent.

    Hi Gaurav,
    do this way ...
    data : begin of it_ztab occurs 0 with header line,
              fld1 like ztab-fld1,
              fld2 like ztab-fld2,
              fld3 like ztab-fld3,
            end of it_ztab.
    data : wa_ztab like it_ztab.
    it_ztab-fld1 = '100'.
    append it_ztab.
    clear    it_ztab.
    loop at it_ztab.
      wa_ztab-fld2 = it_ztab-fld1.
      wa_ztab-fld3 = it_ztab-fld1.
      wa_ztab-fld1 = ' '.
    * Make sure that the structure of internal table/ workarea and database table shoud be same
      modify ztab from wa_ztab.
    endloop.

  • New Field In Database table

    Dear Gurus,
    If some standard SAP field is added in a standard database table as a part of upgrade. Is there a way we can find out when that field is added to the database table.
    Regards,
    Subhajit

    hi Subhajit,
    use the table DBTABLOG,CDHDR,CDPOS ...it will contain the change made by the responsible person and time...
    hope it helps.....

  • Urgent......  how to select few fields, from database table, (dynamic ita.)

    Dear all experts,
    I am able to populate all fields data from database table, using dynamic table creation.
    eg,
    SELECT *    FROM (w_tabname)    INTO    TABLE <t_itab>.
    where w_tabname is the table name given by the user, and t_itab is field symbol.
    but some requirement is like that i need to pick up only few fields, <b>which user will give at the runtime.</b>
    <b>I can</b> take those fields from file into any internal table,
    but the problem is that instead of <b>select *</b>, i need to put selected the fields given by user.
    i have tried with field symbol, it is not working (as per my knowledge.)
    do i need to create any structures dynamically ?
    Can anybody please help in this regards ?
    Your help will be surely rewarded with points.
    Waiting for reply..
    Regards
    Vinay

    Hi Vinay ,
    Adding to the below code , you can use some more fields in the select stmt as below:-
    REPORT ychatest.
    PARAMETERS : p_field1 LIKE dd03l-fieldname,
                             P_field2 LIKE dd03l-fieldname,
                             p_table LIKE dd03l-tabname.
    FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE.
    SELECT (p_field1) (p_field2) ( FROM (p_table) INTO TABLE <fs>.
    Now p_field1 & p_field2  belong to the same table since you have give the user to enter only one table name.
    This should work fine.
    please try & let me know .
    Thanks & Regards,
    Daniel

  • Significance of Counter field in CATsDB Table

    Dear All,
    What is the significance of OUNTER Field in CATSDB Table?
    Regards,
    Satya.

    Yeah ...
    Absolutely correct.
    Please go through my requirement.
    I need to Update CATSDB table manually.
    Say If an Employee enters the leave data like CL, SL etc., through Portal, that is coming into R/3 and my IT2001 is getting updated.
    But when the Same employee logs in using his Cats Id into CATS for time sheet entries, then those booked as well as approved days are not getting reflected and allowing the user to enter the data. After that it is throwing the error.
    My Requirement is Those records should get displayed in Cat2 T-code defaultly. So, I need to update my CATSDB table manually.
    So, as COUNTER Field is updated by the System itself, I want to know its significance. and please let me know how to do this???
    Regards,
    Satya

  • At run time,ALV table is displaying all fields of database table

    Hi all
    I done one application using ALv I am displaying the ALV Table.my problem is at run time it was fetching and displaying all the fields in the data base table but i need only the fields which are defined in node.
    Please help me.
    Thanks and Regards
    Tulasi Palnati

    Hi,
    May be you have specified the database table as the Dicitonary structure property of the node.
    Check the same and if its there clear the Dictionary structure property of the node.
    Hope this solves your isse!
    Regards,
    Srilatha

  • Updation of 'Z' field in database table VBAP & AUFK

    Hi,
    In my report I wanted to update/modify value in a "Z" field in VBAP and a "Z" field in AUFK table.
    Could anyone please suggest me how to update/modify this field value using a BAPI or FM?
    Or any other method atleast..
    Thanks in Advance,
    Rohan.

    Hi,
    When you want to change the Zfield in VBAP we can go for the BAPI function module-
    BAPI_SALESORDER_CHANGE for the given Zfield get the header data and append it to BAPI header structure.
    I think we may use the same FM for updating the AUFK also.
    Reward points if useful.
    Regards
    Chandralekha

  • Impact of changing data type of a field in Database table

    Hi All,
    I need to change the data type of a field(which is not a key field and it has no dependency with any other field) from NUMC to CHAR by maintaining the same length. Please let me know if there will be any impact in doing this. Hope the following things need to be taken care:
    - Take backup of entire data in the table before doing the change
    - After changing the data type, I need to set the option 'Save Data' and then 'Activate and Adjust Database' in 'Database Utility'.
    - Use 'Where Used List' to check the related objects.
    Please let me know if there is any impact or any thing else need to be taken care apart from the above things.
    Thanks in advance.
    Regards
    Vidhya.

    Hi,
    even if the length is same there would be no impact.
    just v need to adjust the database in the database utility.
    check the table maintenence generator also. if not reflected there u need to delete it and create it again.
    reward if useful,
    teja

  • Problem with Auo Increment field in Database table

    HI...
    I have a table with Auto increment field.
    I am using Sql Server 2000.
    I have a Table Component on front end which is binded with that (auto increment) table.
    When I call commitChanges() I receive following exception :
    Exception Details:  java.lang.RuntimeException
      Number of conflicts while synchronizing: 1 SyncResolver.INSERT_ROW_CONFLICT row 2 [sunm][SQLServer JDBC Driver][SQLServer]Cannot insert explicit value for identity column in table 'Authorization_Book' when IDENTITY_INSERT is set to OFF.Anybody knows the solution...

    The following excerpts are from http://blogs.sun.com/roller/page/jfbrown?entry=using_creator_to_insert_into. Do they help?
    What about IDENTITY or AUTOINCREMENT or other database-generated columns?
    This is highly database dependent. Some databases require you to obtain the key through vendor-specific means. Others say "set the value to null". Some say to not include the column in the INSERT statement.
    So how do I exclude my IDENTITY or other column from the INSERT statement?
    Use the RowSet's advanced insertableColumns property. Create a boolean[] array with one value for each column in the result. Use true to include the column in the INSERT statement, otherwise use false. The RowSet's property sheet doesn't allow you to set this property (in Creator2-EA2), so set the property in your java code.

  • F4 for custom field in database table

    Hello,
    I created a Z-table with a Z-domain attached to a field.
    The domain has only 2 values (Yes and No).
    In the selection-screen of the table, I have an F4 for that field, however, I also want an F4 in the table itself (to know that Y = yes and N = no)
    How can you do this?
    Thanks

    Hi,
    at the Domain side assign the value range yes and no in the fixed values..
    so when ever you use the f4 help refer the data element..
    automatically when ever you press F4 it show the Fixed values in domain..
    Regards,Prabhu

Maybe you are looking for

  • Custom file name when saving

    When my program creates a report, I want to save it as a serial number defined in the report.  I want to use the MS Office Report Express VI to do this but unfortunately it only allows you to save the file name as a time/date and/or incremental numbe

  • TS3297 I keep getting 1004 error message every time I download an app

    I keep getting 1004 error message every time I download an app

  • Installing the factory image from linux

    Currently I have Cianogenmod, since I'm getting tired of it, I want to go back to the factory image, if possible the lollipop one directly. I tried the emma tool, but I'm behind a very ugly firewall and it couldn't connect to the internet. How can I

  • Cancel my membership but Live Chat isn't working!

    Hi, I recently ordered Creative Cloud but I decided to cancel it and te forum says to go through Live Chat but for two days it hasn't been working. Can someone help me cancel it, please? It is an emergency.

  • Not an Apple problem but nowhere else to turn

    Hello, Never had to use to use this site before and the issue isn't actually a Mac one as as far as I can tell but I'm hoping someone can help. I should be contacting the BBC directly but the posting function has vanished from the mressage boards whe