fluiditystudio
Forum Replies Created
-
Forum: Hacks
In reply to: update custom db table row via a plugin page through http urlOk, I ended up having to include some main files and now what I have clears my previous database number to 0. Here is my code:
<?php include_once("../../../wp-config.php"); include_once("../../../wp-load.php"); include_once("../../../wp-includes/wp-db.php"); global $wpdb; $table_name = $wpdb->prefix . 'ad_counter'; extract( $_GET ); $id = ( isset( $id ) && is_numeric( $id ) ) ? intval( $id ) : false; $clickthrough = $clickthrough +1; $data = array( 'clickthrough' => '$clickthrough' ); $where = array( 'id' => $id ); $format = array( '%s', '%d' ); $where_format = array( '%d' ); $data = $wpdb->update( $table_name, $data, $where, $format, $where_format ); header("location: $adurl"); ?>
I need the field “clickthrough” to get updated in increments of 1 each time the php file is hit with the id number in the URL example in my first post.
Forum: Hacks
In reply to: update custom db table row via a plugin page through http urlok, so I can make it work this way:
<?PHP $hostname="HOST NAME"; // ENTER YOUR HOST NAME HERE. $user="DB NAME"; //ENTER YOUR DATABASE USERNAME HERE. $pass="PASSOWRD"; // ENTER YOUR DATABASE PASSWORD HERE. $database="DB NAME"; //ENTER YOUR DATABASE NAME HERE. //DO NOT EDIT BELOW $connection=mysql_connect($hostname, $user, $pass) or die(mysql_error("cannot connect")); $db=mysql_select_db($database, $connection) or die(mysql_error()); $table_name = "wp_ad_counter"; extract($_GET); $sql = "SELECT * FROM $table_name WHERE id = $id"; $result = @mysql_query($sql, $connection) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $clickthrough = $row['clickthrough']; } //UPDATE VIEW CONNECTION $clickthrough = $clickthrough +1; $query="UPDATE $table_name SET clickthrough = '$clickthrough' WHERE id= $id"; $result=mysql_query($query); header("location: $adurl"); ?>
But, I would rather include the db connection into this php page so that that the user doesn’t have to add the database connection info themselves.
Any thoughts???
I have modified the current “Lightbox 2” plugin for WordPress to have a “Print” option. This option can be turned on and off in the admin. If you would like this plugin, you will find it on my blog here: https://fluiditystudio.com/blog/2011/01/30/lightbox-2-print-wordpress-plugin/