473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Need Help with Query

155 100+
I have a table that records (suppose to) the number of times a resume is viewed.

When someone clicks on a Send Resume link from a job ad, an email is sent to the employer telling him/her that someone has responded to their ad and sent a resume. This email contains a link that will open my website and display a page containing the job-seeker's resume. When this page is opened (resume viewed) I want it to be recorded in the resume_stats table.

The query on this page is supposed to do one of two things, check if this resume has already been put into the stats table (by being viewed before) and if not add it and set the row "viewed" to 1. If there is already a record of it then it should increase the number in the row "viewed" by 1 - to track how many times the resume has been viewed. Basically, if someone sends their resume to an employer they might like to know if the employer has looked at it or not.

Here's the query (it's not working of course):
[PHP]$file = $_GET['file']; // resume id # - $r_id
$nic = $_GET['nic']; // job-seeker id # - $js-user_id

include("includes/dbstats.php");
$query = "SELECT * FROM resume_stats where r_id='$file'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0)
{
$query = "INSERT INTO resume_stats VALUES ('', '$nic', '$file', '1', '')";
}
else
{
$query = "SELECT r_id,viewed FROM resume_stats where r_id='$file'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$r_id = $row['r_id'];
$viewed = $row['viewed'];
$viewed = $viewed + 1;
}
$query = "UPDATE resume_stats SET viewed='$viewed' WHERE r_id=$file";
}[/PHP]

Here's the resume_stats table - stat_id, js_user_id, r_id, viewed, accessed.

viewed = if the resume is viewed when the job-seeker sends it.
accessed = if the resume is viewed by an employer from the resume database.

Any help here would be appreciated.
Mar 25 '08 #1
4 1455
dlite922
1,584 Expert 1GB
I have a table that records (suppose to) the number of times a resume is viewed.

When someone clicks on a Send Resume link from a job ad, an email is sent to the employer telling him/her that someone has responded to their ad and sent a resume. This email contains a link that will open my website and display a page containing the job-seeker's resume. When this page is opened (resume viewed) I want it to be recorded in the resume_stats table.

The query on this page is supposed to do one of two things, check if this resume has already been put into the stats table (by being viewed before) and if not add it and set the row "viewed" to 1. If there is already a record of it then it should increase the number in the row "viewed" by 1 - to track how many times the resume has been viewed. Basically, if someone sends their resume to an employer they might like to know if the employer has looked at it or not.

Here's the query (it's not working of course):
[PHP]$file = $_GET['file']; // resume id # - $r_id
$nic = $_GET['nic']; // job-seeker id # - $js-user_id

include("includes/dbstats.php");
$query = "SELECT * FROM resume_stats where r_id='$file'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0)
{
$query = "INSERT INTO resume_stats VALUES ('', '$nic', '$file', '1', '')";
}
else
{
$query = "SELECT r_id,viewed FROM resume_stats where r_id='$file'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$r_id = $row['r_id'];
$viewed = $row['viewed'];
$viewed = $viewed + 1;
}
$query = "UPDATE resume_stats SET viewed='$viewed' WHERE r_id=$file";
}[/PHP]

Here's the resume_stats table - stat_id, js_user_id, r_id, viewed, accessed.

viewed = if the resume is viewed when the job-seeker sends it.
accessed = if the resume is viewed by an employer from the resume database.

Any help here would be appreciated.
Why is it now working? do you get an error? Have you tried troubleshooting it by placing the die() statement and observing what has happened up to that point?

We dont' have your database, setup, in front of us to trouble shoot it for you. Find the problem, when you can't fix it, we're here to help.

Your logic is right, although not perfect.

Why make a separte table? can't you add a column to the resume table and hit it there?

So all resume counts will be set to 0 on insert. Each time they're accessed you'll just need to execute one simple query instead of doing 3.

UPDATE tableName SET count = (SELECT count+1 FROM tableName WHERE id = '$file') WHERE id = '$file';.

and Voila! you just increased it by one.

Also consider that if the employer views it more than one time, it will increase it. If you want to increase the count by one for each employer no matter how many times they go to the link, then we've got more complications.

Let me know if you need help doing that.

Happy Coding and Good Luck,



DM
Mar 27 '08 #2
dlite922
1,584 Expert 1GB
Don't know why this shows no replies when i can see my reply above ^^
Mar 27 '08 #3
Markus
6,050 Expert 4TB
Don't know why this shows no replies when i can see my reply above ^^
"2 Replies" To me :)

Now i guess it's 3

;)
Mar 27 '08 #4
We do a similar thing with urls in an email
the url looks somthing like this

http://youdomain.com/product.php?id=23&emailview=Y

this way we can test the $_GET['emailview'] and do something.

why not create a transation table that purely counts the views of that particular resume rather than increment or
$emailview = $_GET['emailview'];
if($emailview == "Y"){
sql to increment $_GET['id'];
}

Am I hleping ...or telling you something you already know?
Mar 28 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
6
by: paii | last post by:
I have a table that stores job milestone dates. The 2 milestones I am interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18. All jobs have TypeID 1 only some jobs have TypeID 18....
3
by: pw | last post by:
Hi, I am having a mental block trying to figure out how to code this. Two tables: "tblQuestions" (fields = quesnum, questype, question) "tblAnswers" (fields = clientnum, quesnum, questype,...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
10
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only...
7
by: Rnykster | last post by:
I know a little about Access and have made several single table databases. Been struggling for about a month to do a multiple table database with no success. Help! There are two tables. First...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.