SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with file linking.

    Hi Master

    I am using following code to gather a list of files from my mysql table and showing that on page.

    on the page i can see the file name with extension. But when i open that link by right click or try to save it do now show me full file name. Please help

    Like on page it shows 119021_file_zeeshan.pdf
    but the link is http://www.site.com/files/119021_file_zee
    u can see the link is not complete.

    Please guide



    Code:
    <?php
    	include("conn.php");
    	global $conn;
    
    	$email = $_SESSION['useremail'];
    	$password = $_SESSION['userpassword'];
    	
    	$query ="SELECT * FROM documents where email ='$email' and password='$password'";
        $result = mysql_query($query,$conn);
    	$totalfiles = @mysql_num_rows($result);
    	$row="";
    	
    	if($totalfiles > 0) 
    	{
    		while ($rows = mysql_fetch_array ($result, MYSQL_ASSOC))
    		{?>
    			<tr><td><a href=http://www.site.com/files/<?php echo $rows['documentid'];?>><?php echo $rows['documentid'];?></a></td></tr>
    		 <?	
    		}
        }	 //
    ?>
    Last edited by zeeshanhashmi; Jul 29, 2007 at 07:38. Reason: humm

  2. #2
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SOMEBODY HELP MEEEEEEEEEEEEEEEEEEEE i

  3. #3
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <tr><td><a href="http://www.site.com/files/<?php echo $rows['documentid'];?>><?php echo $rows['documentid'];?>">TEXT HERE</a></td></tr>
    try putting that line like this, you had some HTML errors i think.

  4. #4
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no no , i have <?php thing where u mentioned TEXT HERE. that i a dynamic text
    you are not correct !

  5. #5
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look, i'll put it with echos, i dont like using ?> <?php too much

    PHP Code:
    echo '<tr><td><a href="http://www.site.com/files/'.$rows['documentid'].'">TEXT HERE</a></td></tr>'
    Anyway.. Why do you have two simillar echos here:

    <tr><td><a href="http://www.site.com/files/<?php echo $rows['documentid'];?>><?php echo $rows['documentid'];?>">TEXT HERE</a></td></tr>


    i dont get it.

  6. #6
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh Mojo

    look, first echo is for the file link for HREF

    and the 2nd is for TEXT HERE. so no need to put TEXT HERE. and it will put it from the database. and there is nothing wrong with that. The only problem is that the ECHO in HREF is not showing the full file name while the same echo at TEXT HERE showing the full name.

  7. #7
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe thats because you have href=http://... and not href="http://..."

    I may be wrong but i think that if you add the quotes "" it wont kill the last DOT of the file extension.

    Result:

    PHP Code:
    <tr><td><a href="http://www.site.com/files/<?php echo $rows['documentid'];?>"><?php echo $rows['documentid'];?></a></td></tr>

  8. #8
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    humm i think i tried that. but let me check again !

  9. #9
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any news?

  10. #10
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it

    i need to put
    \" before HREF and before closing > of this.

  11. #11
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks MoJO !!

  12. #12
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem!


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
  •