Title Help [Quick Help]

Discussion in 'PHP' started by deleted-account, Jul 26, 2008.

  1. #1
    Can any of you help me fix this? No matter what when I am reading any article it will set the title to the latest article rather than the article in question.

    Here is my code:

    while($rows=mysql_fetch_array($sql_result1))
    {
    if (isset($_GET['id']) == false)
    {
      $news_title = "Index";
    }
    else if (isset($_GET['id']) == $rows['id'])
    {
      $news_title = $rows['title'];
    }
    }
    Code (markup):
    <title>Ali Razaqpur - News - ', $news_title, '</title>
    Code (markup):
     
    deleted-account, Jul 26, 2008 IP
  2. Boxerman

    Boxerman Peon

    Messages:
    306
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    would help if you showed your query string...
     
    Boxerman, Jul 26, 2008 IP
  3. deleted-account

    deleted-account Active Member

    Messages:
    655
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    85
    #3
    $sql_query = "SELECT * FROM news_main ORDER BY cat, title DESC";
    $sql_result1 = mysql_query($sql_query);
    Code (markup):
     
    deleted-account, Jul 26, 2008 IP
  4. Boxerman

    Boxerman Peon

    Messages:
    306
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try

    $sql_query = "SELECT * FROM news_main WHERE newsitem=newsitemID ORDER BY cat, title DESC ";[/QUOTE]
     
    Boxerman, Jul 26, 2008 IP
    Ali Razaqpur likes this.
  5. deleted-account

    deleted-account Active Member

    Messages:
    655
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    85
    #5
    [/QUOTE]

    newsitem and newsitemID are what?
     
    deleted-account, Jul 26, 2008 IP
  6. deleted-account

    deleted-account Active Member

    Messages:
    655
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    85
    #6
    Okay well I got it reading the title from the db now and it works except now it won't title the page "index" if it is in the main area.

    $newsitem = $_GET['id'];
    $sql_query1 = "SELECT * FROM news_main WHERE '$newsitem'=id ORDER BY cat, title DESC";
    $sql_result1 = mysql_query($sql_query1);
    
    while($rows=mysql_fetch_array($sql_result1))
    {
    if (isset($_GET['id']) == $rows['id'])
    {
      $news_title = $rows['title'];
    }
    else
    {
      $news_title = "Index";
    }
    }
    Code (markup):
     
    deleted-account, Jul 26, 2008 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    
    if (isset($_GET['id']) == $rows['id'])
    
    PHP:
    isset() returns true or false, and not the ID.
     
    nico_swd, Jul 28, 2008 IP
  8. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yep, your code should be replaced with:
    
    if (isset($_GET['id']) && $_GET['id'] == $rows['id'])
    
    PHP:
    or simply
    if ($_GET['id'] == $rows['id'])
    PHP:
     
    xlcho, Jul 28, 2008 IP
  9. deleted-account

    deleted-account Active Member

    Messages:
    655
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    85
    #9
    Problems already solved guys
     
    deleted-account, Jul 28, 2008 IP