General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 6th, 2003, 03:39 AM
Freddy Freddy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 Freddy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
UPDATE $variable OnClick?

Being my second day programming in over three years, I'm a little lost at this point.

I'm starting on my first function and I know this code is just HORRIBLY written up to this point, to which I am sorry.

My main concern is the function 'clickcount' and how it would interact with the link at the lower end of the code. I can't get the click value to increment and I'm not sure if the link doesn't recognize the call or if the function is written incorrectly.

I'm still a little shady on the syntax of things, so I expect plenty of nodding heads when people look at this code.


Code:


<?php require_once('Connections/senior.php'); ?>

<?php
function clickcount($x, $y, $z) 
{ 

mysql_query("UPDATE $x SET $y = $y + 1 WHERE linkName= '$z'");
}
?>


<?

/* declare some relevant variables */
$hostname = "localhost";
$username = "root";
$password = "********";
$userstable = "names";
$tableLinks = "links";
$dbName = "senior";




/* make connection to database */
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");



@mysql_select_db( "$dbName") or die( "Unable to select database"); 


$query = "SELECT views FROM $tableLinks WHERE linkType = 'main'";
$result = MYSQL_QUERY($query);
$views = mysql_result($result,$i,"views");
$views=$views+1;
mysql_query("UPDATE $tableLinks SET views = '$views' WHERE linkType = 'main'");
PRINT "This form of navigation has been viewed ";
PRINT "$views";
PRINT " times";
PRINT "<BR><BR>";



$queryV = "SELECT views FROM $userstable WHERE linkName = 'cats'";
$queryC = "SELECT clicks FROM $userstable WHERE linkName = 'cats'";
$resultV = MYSQL_QUERY($queryV);
$resultC = MYSQL_QUERY($queryC);
$views = mysql_result($resultV,$i,"views");
$clicks = mysql_result($resultC,$i,"clicks");
$views=$views+1;

mysql_query("UPDATE $userstable SET views = '$views' WHERE linkName = 'cats'");


PRINT "This page has been accessed or reloaded ";
PRINT "$views";
PRINT " times";
PRINT "<BR><BR>";
PRINT "This system won't work however since the counter is not tracking from what link this page was accessed from";
PRINT "<BR><BR>";
PRINT "However, this could be a rudamentry system for setting a heirarchy within each separate type of navigation.";
PRINT "<BR><BR>";
PRINT "Clicks = $clicks";
PRINT "<BR><BR>";
?>
<a href="cats.php" OnClick="clickcount($usertable, $clicks, cats)";>clik me</a>



</html>
<?php

?>





Thank you to anyone willing to help any little bit at all.

Reply With Quote
  #2  
Old February 9th, 2003, 10:57 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Freddy,

I've been looking at the code... Can't seem to find anything wrong with the PHP side of things.. But I'm wondering if this line has something to do with it:

Code:
?>
<a href="cats.php" OnClick="clickcount($usertable, $clicks, cats)";>clik me</a>



</html>


You're referring to PHP variables ($usertable, $clicks, and cats)... But cats is missing the $ and you're also referencing the variables OUTSIDE of the PHP code... Try something like this:

Code:
?>
<a href="cats.php" OnClick="clickcount(<?php echo($usertable, $clicks, $cats ?>)";>clik me</a>

[/code]

If that doesn't work, revert to your original code, but use the $ for the "cats" variables.

Hope that helps.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old February 9th, 2003, 04:11 PM
Freddy Freddy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 2 Freddy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Oh man, thank you so much.

I'll give that a shot tonight and see how that goes.

Really, MUCH appreciated.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > UPDATE $variable OnClick?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap