Page 1 of 1

sql help needed

PostPosted: Tue Mar 18, 2008 6:33 pm
Author: chopper
When you go to each different category page they all show the same page title.
Google sees this as duplicate pages.
I want to include the category name on the page title.
I put this code in links.php

Code: Select all
if ( isset($HTTP_POST_VARS['cat']) || isset($HTTP_GET_VARS['cat']) ){$sql = "SELECT cat_title, cat_id FROM" . LINK_CATEGORIES_TABLE . "WHERE cat_id =" . $HTTP_GET_VARS['cat'];  $result = $db->sql_query($sql);  $page_name = $result['cat_title'];  $page_title = $lang['Site_links'] . "  -  " . $pagename;} else { $page_title = $lang['Site_links']; }  

just before the line
Code: Select all
include('includes/page_header.'.$phpEx);

what I get is : my_site_name - Links -
I can easily get it to display the cat_id.
How can I get it to display the "$page_name" using a query

Re: sql help needed

PostPosted: Wed Mar 19, 2008 2:55 pm
Author: obiku
Maybe change
Code: Select all
if ( isset($HTTP_POST_VARS['cat']) || isset($HTTP_GET_VARS['cat']) ){$sql = "SELECT cat_title, cat_id FROM" . LINK_CATEGORIES_TABLE . "WHERE cat_id =" . $HTTP_GET_VARS['cat'];  $result = $db->sql_query($sql);  $page_name = $result['cat_title'];  $page_title = $lang['Site_links'] . "  -  " . $pagename;} else { $page_title = $lang['Site_links'];}

into
Code: Select all
if ( isset($HTTP_POST_VARS['cat']) || isset($HTTP_GET_VARS['cat']) ){$sql = "SELECT cat_title, cat_id FROM" . LINK_CATEGORIES_TABLE . "WHERE cat_id =" . $HTTP_GET_VARS['cat'];  $result = $db->sql_query($sql);  $page_name = $result['cat_title'];  $page_title = $lang['Site_links'] . "  -  " . $page_name;} else { $page_title = $lang['Site_links'];}


$pagename ===> $page_name

Re: sql help needed

PostPosted: Thu Mar 20, 2008 6:04 am
Author: chopper
Well I caught that mistake but it didn't help. What I ended
Code: Select all
// Output the basic pageif ( isset($HTTP_POST_VARS['cat']) || isset($HTTP_GET_VARS['cat']) ) { $page=($HTTP_GET_VARS['cat']);$page_title = $lang['Site_links'] . " - Category " . $page;  } else { $page_title = $lang['Site_links']; }  


Now my titles look like this:
chopncrop.com-Photoshop Contests - Links - Category 4
I would rather have the actual category name but at least all pages are different now

Re: sql help needed

PostPosted: Thu Mar 20, 2008 1:40 pm
Author: obiku
To get the name of the category, you have to lookup the category_id in the db, and replace the category_id with the category name.
something like this
Code: Select all
    $page=($HTTP_GET_VARS['cat']);  $sql = "SELECT cat_title FROM " . CATEGORIES_TABLE . " WHERE cat_id=" . $page;     if ( !$result = $db->sql_query($sql) )     {         message_die(GENERAL_ERROR, 'Couldn't access list of Categories', '', __LINE__, __FILE__, $sql);     }

Then $result must be the title of the desired category.

Re: sql help needed

PostPosted: Fri Mar 21, 2008 8:33 am
Author: chopper
Tried integrating above code into .script and get "Resource id=#114" as the page name