SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Brazil
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for finish dynamic title page script

    Hi,

    I'm tried optimize title of dynamic pages of my site and I'd liked add the name of category ($namecat) in page title of article (../article.php?id=41) but, I can't finish it.

    PHP Code:
    if($_GET['id']) {
            
    $sql mysql_query("SELECT title, subtitle FROM articles WHERE id=".$_GET['id']);
            
    $row mysql_fetch_array($sqlMYSQL_ASSOC);
            
    $title=$row["title"];
            
    $subtitle=$row["subtitle"];
            if (empty(
    $subtitle)) {
            
    $pagetitle "$title | Articles"; } else {
            
    $pagetitle "$title - $subtitle | Articles";   } } 
    liked ($namecat):

    PHP Code:
     $pagetitle "$title | $namecat | Articles"; } else {
         
    $pagetitle "$title - $subtitle | $namecat | Articles";   } } 
    How I do it?


    Code:
    CREATE TABLE `table_articles` (
      `id` tinyint(4) NOT NULL auto_increment,
      `namecat` varchar(255) NOT NULL default '',
      `descat` text NOT NULL,
      PRIMARY KEY  (`id`,`nomecat`)
    ) TYPE=MyISAM AUTO_INCREMENT=85 ;

    Code:
    CREATE TABLE `articles` (
      `id` int(11) NOT NULL auto_increment,
      `cat` int(11) NOT NULL default '0',
      `title` varchar(255) NOT NULL default '',
      `subtitle` varchar(255) NOT NULL default '',
       `article` longtext NOT NULL,
       PRIMARY KEY  (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=49 ;
    Sorry for english!

  2. #2
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Come Again??
    I don't think I understand what you want. Do you want to create the database table or what?
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  3. #3
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you will have to select the category name in your query, for one. Then do another query to use the int of the cat to select the namecat from the other table. Like so:

    PHP Code:
    if($_GET['id']) {
            
    $id mysql_escape_string($_GET['id']);
            
    $sql mysql_query("SELECT cat, title, subtitle FROM articles WHERE id='$id'");
            
    $row mysql_fetch_array($sqlMYSQL_ASSOC);
            
    $cat $row["cat"];
            
    $title=$row["title"];
            
    $subtitle=$row["subtitle"];
             
    $CatQuery mysql_query("SELECT namecat FROM table_articles WHERE id = '$cat'");
    $CatRow mysql_fetch_array($CatQueryMYSQL_ASSOC);
    $namecat $CatRow["namecat"];
            if (empty(
    $subtitle)) {
            
    $pagetitle "$title | $namecat | Articles"; } else {
            
    $pagetitle "$title - $subtitle | $namecat | Articles";   } } 
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  4. #4
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Brazil
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by asp_funda
    ..I don't think I understand what you want...
    I want add the variable namecat in pagetitle.

    Quote Originally Posted by Possibility
    Well, you will have to select the category name in your query, for one. Then do another query to use the int of the cat to select the namecat from the other table.
    Perfect!
    I understand all and it works now.
    Thank you very much Possibility and asp_funda for reply!
    bye.

  5. #5
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ok, glad that you got it working.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  6. #6
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Brazil
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Could you help-me for this again, please? I've tried add the name of category ($cattitle) in page title of category repairs (index.php?view=cat&id=21) and view repair page (index?view=repair&did=67) but, I've got some difficulties.
    The cattitle variable doesn't appear.

    PHP Code:
    if($_GET['did']) {
            
    $did mysql_escape_string($_GET['did']);
            
    $sql mysql_query("SELECT dicastitle FROM repair WHERE dicasid='$did'");
            
    $row mysql_fetch_array($sqlMYSQL_ASSOC);
            
    $dicastitle $row["dicastitle"];
           
            
    $CatQuery mysql_query("SELECT cattitle FROM repair_cat WHERE catid='$dicasid'");
            
    $CatRow mysql_fetch_array($CatQueryMYSQL_ASSOC);
            
    $cattitle $CatRow["cattitle"];
             
            
    $pagetitle "$dicastitle | $cattitle | Repair";   } 
            
    if(
    $_GET['catid']) {    
        
    $catid mysql_escape_string($_GET['catid']);    
        
    $sql mysql_query("SELECT cattitle FROM repair_catWHERE catid='$catid'");
        
    $row mysql_fetch_array($sqlMYSQL_ASSOC);
        
    $cattitle $row["cattitle"];        
           
    $pagetitle "$cattitle | Repair";            
                    } 

    Code:
        CREATE TABLE `repair` (
      `dicasid` bigint(5) NOT NULL auto_increment,
      `catid` bigint(5) NOT NULL default '0',
      `dicastitle` varchar(255) NOT NULL default '',
      PRIMARY KEY  (`dicasid`),
      KEY `catid` (`catid`)
    ) TYPE=MyISAM AUTO_INCREMENT=84 ;

    Code:
    CREATE TABLE `repair_cat` (
      `catid` bigint(5) NOT NULL auto_increment,
      `cattitle` varchar(255) NOT NULL default '',
      PRIMARY KEY  (`catid`),
      KEY `catparent` (`catparent`)
    ) TYPE=MyISAM AUTO_INCREMENT=32 ;
    Thank you!!!

  7. #7
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Brazil
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's working now after some changes in the code. Thank's.
    Last edited by bubbles.br; May 2, 2004 at 18:22.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •