sql help needed

Support for IntegraMOD 141

Moderator: Integra Moderator

sql help needed

PostAuthor: chopper » Tue Mar 18, 2008 6:33 pm

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
Last edited by chopper on Wed Dec 31, 1969 5:00 pm, edited 1 time in total.
[url=http][img=left]http://chopncrop.com/forum_images/album/albums/userpics/10002/banner.jpg[/img][/url]
[url=http]Homestead Country[/url]
User avatar
chopper
Members
Members
 
Posts: 39
Likes: 0 post
Liked in: 0 post
Joined: Wed Jan 23, 2008 9:53 am
Cash on hand: 0.00

Re: sql help needed

PostAuthor: obiku » Wed Mar 19, 2008 2:55 pm

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
Last edited by obiku on Wed Dec 31, 1969 5:00 pm, edited 1 time in total.
http://www.familie-smit.nl
http://portfolio.familie-smit.nl

Do not tsunami my inbox... instead use the forums...
Hard work may not kill me, but why take a chance?

[hr]
User avatar
obiku
Dev Team
Dev Team
 
Posts: 218
Likes: 0 post
Liked in: 0 post
Joined: Tue May 02, 2006 11:22 am
Cash on hand: 0.00
Location: level 8

Re: sql help needed

PostAuthor: chopper » Thu Mar 20, 2008 6:04 am

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
Last edited by chopper on Wed Dec 31, 1969 5:00 pm, edited 1 time in total.
[url=http][img=left]http://chopncrop.com/forum_images/album/albums/userpics/10002/banner.jpg[/img][/url]
[url=http]Homestead Country[/url]
User avatar
chopper
Members
Members
 
Posts: 39
Likes: 0 post
Liked in: 0 post
Joined: Wed Jan 23, 2008 9:53 am
Cash on hand: 0.00

Re: sql help needed

PostAuthor: obiku » Thu Mar 20, 2008 1:40 pm

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.
Last edited by obiku on Wed Dec 31, 1969 5:00 pm, edited 1 time in total.
http://www.familie-smit.nl
http://portfolio.familie-smit.nl

Do not tsunami my inbox... instead use the forums...
Hard work may not kill me, but why take a chance?

[hr]
User avatar
obiku
Dev Team
Dev Team
 
Posts: 218
Likes: 0 post
Liked in: 0 post
Joined: Tue May 02, 2006 11:22 am
Cash on hand: 0.00
Location: level 8

Re: sql help needed

PostAuthor: chopper » Fri Mar 21, 2008 8:33 am

Tried integrating above code into .script and get "Resource id=#114" as the page name
Last edited by chopper on Wed Dec 31, 1969 5:00 pm, edited 1 time in total.
[url=http][img=left]http://chopncrop.com/forum_images/album/albums/userpics/10002/banner.jpg[/img][/url]
[url=http]Homestead Country[/url]
User avatar
chopper
Members
Members
 
Posts: 39
Likes: 0 post
Liked in: 0 post
Joined: Wed Jan 23, 2008 9:53 am
Cash on hand: 0.00


Return to IntegraMOD 141

Who is online

Registered users: App360MonitorBot, Bing [Bot], Google [Bot]