CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 help a newbie please

Print topic Send  topic

Author Message
computerman


Posts: 27
Posted: 09/04/2009, 11:52 PM

Hi everybody,
I'm trying to develop a simple private messaging program for intranet.
In Index php of every user, want to put a notifier message like "you have xx unread message(s)"
I spent last night to make this db lookup but still haven't succeed.
my db:
named: mydb
table: messages
column: message_new
another column: to_user

Select "to_user" from "messages" where "message_new" value "1" and "to_user" value equals "userlogin" variable and collect number of hits which observed.

with help of forum samples and a whole night of going mad :-{} , I ended up with this code which is not working properly:
    
$db = new clsDBConnection1;    
$rec_num = CCDLookUp("Count(*)", "messages","to_user = CCGetUserLogin(), + "message_new = '1' ,  $db);    
unset($db);    
echo You have ", $rec_num; unread message(s) 

can you please tell me how get this code up and running?

btw, I am new to CCS, and have another newbie question, can you please tell me the easiest way to call a value from database to and display any page without coding or with minimum coding.What should I use? Grid or Label? and how to print a value (let's say MessageID) from db? can someone explain it?

Sorry for my bothering questions, but I cannot find any good reference manual for CCS other than limited help files and this forum.

Have a good day,
Thanks in advance.
_________________
"whoever is a cruel, must be an old downtrod who has got authority,
whoever is a downtrod, must be an old cruel who has lost authority. "
An Oriental Saying
View profile  Send private message
ckroon

Posts: 869
Posted: 09/05/2009, 9:11 AM

Quote :
$db = new clsDBConnection1;
$rec_num = CCDLookUp("Count(*)", "messages","to_user = CCGetUserLogin(), + "message_new = '1' , $db);
unset($db);
echo You have ", $rec_num; unread message(s)

This is how i would handle it....
  
global $DBConnection1;   
$rec_num=CCDLookUp('Count(*)', 'messages', 'to_user='.CCGetUserID()  .' AND message_new  = 1 ', $DBConnection1));   
echo "You have $rec_num unread message(s)"; 

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/05/2009, 9:49 AM

Just a thought, since i try to stay away from as much custom code as possible,

Why not create a lable on the page, in before show do a Dlookup action using ckroons parameters and putting the result into the label???

Or not. LOL




_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
computerman


Posts: 27
Posted: 09/05/2009, 10:27 AM

Quote jjrjr1:
Just a thought, since i try to stay away from as much custom code as possible,

Why not create a lable on the page, in before show do a Dlookup action using ckroons parameters and putting the result into the label???

Or not. LOL


Thank you for replies, I appreciate.
Because I am not very familiar with CCS, I only managed to make simple grid/record queries with help of wizards.Maybe It is because my approach to program like a WYSWYG editor.I know It is not a "drag and drop and done program", but a coding accelerator.Also need to confess that I am new in that database and web area.But I have wish to learn.I have a past relation with pascal from last century when still DOS was alive :-)

Anyway, That Label solution I tried numerous of times, but the question is how to formulate AND parameter in DLOOKUP properties box of that label
and how to let that label to show value.

Lets say I put a label named Label1 but how to give `intelligence` to that Label so It can show me value of related query? This is the most difficult part for me. Because I placed Label, from properties, beforeshow events I placed code, but It still stays there without any value. I mean that Label displays no result when Prewieved.If I could find any instructable for that Labels and DLOOKUPs syntax and usage, I need to get that logic. then I would be stepping much faster.
I will tell you very funny thing happened me because I still did not get the usage and syntax logic of CCS, In order to get just a totalsum value of any column, I am running the grid/record builder creating a complete page of searchs recordsets etc etc with help of wizard, then from html mode I am cleaning out the table but totalsum label. It looks funny from someone from outside but believe me It is just only way where there is no way.
So this forum platform very important for me, and thanks indeed who is sharing with someone some knowledge.

ps: sorry for my not-very-literal English as It is not my own language.

_________________
"whoever is a cruel, must be an old downtrod who has got authority,
whoever is a downtrod, must be an old cruel who has lost authority. "
An Oriental Saying
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/05/2009, 11:18 AM

Hi

You would build your dlookup using the parameters ckroon pointed out

Here are the steps to do it with a label

First from the forms tab in the toolbox pane add a label to your page

Now click on the label and look at the properties pane.

Select the events tab
select before show
click the + icon and add action DLookup

You will now get a list of things that need to be entered for that action

in expression put 'COUNT(*)'
in domain put the table name 'members'
in criteria put 'to_user='.CCGetUserID() .' AND message_new = 1 '
in connection click the down arrow and select your DB connection
In convert result click the drop down and select text
In Type of Target Drop down and select control
In Target Drop down and select the name of your new label control.

That should work for you and no custom code is required.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 09/05/2009, 11:29 AM

This is of course you are using MySQl as your DB. If not replace the parameters in the Dlookup to match your database

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
Gery_Atric


Posts: 7
Posted: 09/07/2009, 2:35 PM

I built something similar some time back
In the grid where the message is displayed I give the user an option to mark a message as read so check box checked = 2 . default in table is 1 so unread message = 1 .

Now your bit.
In your Grid select from table where records = 1
Use the total records ie You have " total records" Messages

PM me and i might have a demo to show
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.