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 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Link inside echo

    This is a bit of a problem for me. Now, don't hate me for my coding; im still a newbie at this

    Before you guys check the code, this is what I would like:

    Take the information from $row['link'] and make that appear in:
    http://www.google.com/translate?u=ht...&hl=en&ie=UTF8

    So, we remove http%3A%2F%2Fe61life.com and add the information from the database from $row['link']. Can this be done?

    Fig 1 - Initiating database connection and fetching everything

    PHP Code:
    <?php 
    $db 
    mysql_connect($DB_HOST,$DB_USER,$DB_PWD);
        if (!
    $db) { die("Connection failed. Report to daniel@e61life.com.np.spam (remove .no.spam)"); }
    $database mysql_select_db($DB_DATABASE);
        
    $query="SELECT * FROM blogs";
        
    $query_result=mysql_query($query);

    ?>
    Fig 2 - Displaying a table with the collected database information

    PHP Code:
    <div id="table">
    <br />
    <center><table>
        <tr>
            <th><p>Title</p></th>
            <th><p>Category</p></th>
            <th><p>Language</p></th>
            <th><p>Link</p></th>
            <th><p>Translate</p></th>
            <th><p>Other</p></th>
        </tr>
    <?php
    while ($row mysql_fetch_array($query_result)){
       echo 
    "    <tr>\n<td><p>" $row['title'] . "</p></td>\n        <td><center><p>" $row['cat'] . "</p></center></td>\n        <td><center><p>" $row['lang'] . "</p></center></td>\n        <td><center><a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "http://localhost/test/images/world_go.png" "\"></a></center></td>\n        <td><center><a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_it.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_de.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_fr.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_es.gif" "\"></a></center></td>\n        <td><center><img src=\"" "./images/exclamation.png" "\"> <img src=\"" "./images/help.png" "\"> <a href=\"" $row['rss'] . "\" target=\"_new\"><img border=0 src=\"" "./images/feed.png" "\"></a></center></td></tr>\n"
    }
    ?>
    </center></table>
    <?php mysql_close($db); ?>
    </div>
    </div>

  • #2
    Regular Coder
    Join Date
    Sep 2006
    Location
    Colorado
    Posts
    132
    Thanks
    7
    Thanked 1 Time in 1 Post
    PHP Code:
    <?
    $row
    ['link'] = urlencode($row['link']);
    ?>
    http://us3.php.net/manual/en/function.urlencode.php
    -bubbles

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bubbles19518 View Post
    PHP Code:
    <?
    $row
    ['link'] = urlencode($row['link']);
    ?>
    http://us3.php.net/manual/en/function.urlencode.php
    Sorry to say it, but I cannot seem to implement this without getting an error. Would you/anyone mind write a quick example?

  • #4
    Regular Coder
    Join Date
    Sep 2006
    Location
    Colorado
    Posts
    132
    Thanks
    7
    Thanked 1 Time in 1 Post
    I posted that code to show you that you need to urlencode your url. I'm not sure if it will work but from a quick look at your code I think thats what you need to do...
    PHP Code:
    $row['link'] = urlencode($row['link']); 
    echo 
    "    <tr>\n<td><p>" $row['title'] . "</p></td>\n        <td><center><p>" $row['cat'] . "</p></center></td>\n        <td><center><p>" $row['lang'] . "</p></center></td>\n        <td><center><a href=\"http://www.google.com/translate?u=" $row['link'] . "&langpair=en%7Cde&hl=en&ie=UTF8\" target=\"_new\"><img border=0 src=\"" "http://localhost/test/images/world_go.png" "\"></a></center></td>\n        <td><center><a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_it.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_de.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_fr.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_es.gif" "\"></a></center></td>\n        <td><center><img src=\"" "./images/exclamation.png" "\"> <img src=\"" "./images/help.png" "\"> <a href=\"" $row['rss'] . "\" target=\"_new\"><img border=0 src=\"" "./images/feed.png" "\"></a></center></td></tr>\n"
    Try that code, it should work... All I did was urlencode $row['link'] and then put it in the google translate url for the variable "u".
    -bubbles

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bubbles19518 View Post
    I posted that code to show you that you need to urlencode your url. I'm not sure if it will work but from a quick look at your code I think thats what you need to do...
    PHP Code:
    $row['link'] = urlencode($row['link']); 
    echo 
    "    <tr>\n<td><p>" $row['title'] . "</p></td>\n        <td><center><p>" $row['cat'] . "</p></center></td>\n        <td><center><p>" $row['lang'] . "</p></center></td>\n        <td><center><a href=\"http://www.google.com/translate?u=" $row['link'] . "&langpair=en%7Cde&hl=en&ie=UTF8\" target=\"_new\"><img border=0 src=\"" "http://localhost/test/images/world_go.png" "\"></a></center></td>\n        <td><center><a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_it.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_de.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_fr.gif" "\"></a> <a href=\"" $row['link'] . "\" target=\"_new\"><img border=0 src=\"" "./images/flag_es.gif" "\"></a></center></td>\n        <td><center><img src=\"" "./images/exclamation.png" "\"> <img src=\"" "./images/help.png" "\"> <a href=\"" $row['rss'] . "\" target=\"_new\"><img border=0 src=\"" "./images/feed.png" "\"></a></center></td></tr>\n"
    Try that code, it should work... All I did was urlencode $row['link'] and then put it in the google translate url for the variable "u".
    Works perfectly. Thank you.


  •  

    Posting Permissions

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