Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Link New thread

  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Link New thread

    Hey. I want the image to link to whatever ID the question_id is. EXAMPLE:
    newthread.php?question_id=(WHATEVERID)

    Can you please help?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    What? Rephrase your question and provide more information.

  • #3
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    <a href="/forum/viewthreads.php?question_id="><img src="images/newthread.jpg" alt="newthread" width="100" height="35" border="0" /></a></a></td>

    I want that to link to whatever ID it is.

    EGZAMPLE@@@!

    This board ID is 9, So the image link should be: newthread.php?question_id=9

    But all boards are not ID 9. I want it to be whatever ID it is.


    The same thing as:
    PHP Code:
    echo '<a href="/forum/viewthreads.php?question_id=' $row['id'] . '">'.$row['name'].'</a>'
    But this is an image link.

  • #4
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Maybe this will help - I did the same thing just the other day while making a Guitar Tabs website. I wanted to list all of the songs that an artist did, so I wrote the following code:

    PHP Code:
            function get_songs_by_artist($artistid) {
                    
    $dbh $this->dbc();
                    
    $sth $dbh->prepare("SELECT song.id,song.title,artist.value FROM song INNER JOIN artist ON song.artist=artist.id WHERE song.artist=?");
                    
    $sth->execute(array($artistid));
                    
    $data $sth->fetchAll();
                    
    $string '<p class="content-head">All songs by artist <b>'$data[0]['value'].'</b></p>';
                    
    $string .= '<table border="0" width="100%"><tr><td>';
                    
    $i 0;
                    foreach(
    $data as $row) {
                                    if(
    $i%15==&& $i != 0) {
                                            
    $string .= '</td><td>';
                                    }
                                    
    $string .= '<a href="index.php?action=showtab&tabid='.$row['id'].'" target="_blank">'.$row['title'].'</a><br/>';
                                    
    $i++;
                    }
                    
    $string .= '</td></tr></table>';
                    return 
    $string;
            } 
    Pretty much: you need to query your database and get the tabid (or threadid in your case) so that you can display it with each row. I hope my example helps...

  • #5
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Yeah that's what I have on another page but I'm talking about a Image. You click the image and it does the same thing, just with an image.

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by NightFlyer View Post
    The same thing as:
    PHP Code:
    echo '<a href="/forum/viewthreads.php?question_id=' $row['id'] . '">'.$row['name'].'</a>'
    But this is an image link.
    Just replace the $row['name'] with your image code.

  • #7
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Doesn't work

    Hover your mouse over the new reply and you'll see something like: newreply.php?do=newreply&p=690574 See, That's an image but I cannot get mine to do that.

  • #8
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by NightFlyer View Post
    Doesn't work
    Again, the lack of information is only preventing you from finding a solution. Post the code you tried.


  •  

    Posting Permissions

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