SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help me to fix this code,please

    hello my friends ,
    i come here when i got some problems because i know that i got answers and help here

    pelase help me to fix this code

    PHP Code:
    <?php
    include("db.php");
    $user=$_SESSION['username'];


      
    mysql_select_db("mydb"$con);
      
    $result mysql_query("SELECT ebname FROM ebooks");
     
     while(
    $row mysql_fetch_array($result))
      {
      echo 
    $row['ebname'] . " " "<a href="$row['link']">Download</a>";
      echo 
    "<br />";
      }

    mysql_close($con);
    ?>
    What i want to do i to select the list of ebooks from the data base with a download link

  2. #2
    SitePoint Guru silver trophy JamesColin's Avatar
    Join Date
    May 2009
    Location
    Jomtien, Pattaya, Thailand
    Posts
    910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you want to use $row['link'] you need to get it from the database, at the moment you're only getting ebname:
    $result = mysql_query("SELECT ebname FROM ebooks");

    so either add link:
    $result = mysql_query("SELECT ebname,link FROM ebooks");

    or take everything:
    $result = mysql_query("SELECT * FROM ebooks");

    Hope it helps.
    Do you really need traffic? Where to? What for?
    If you really do need traffic then stop messing around!
    Advertise on my sites today: She Told Me & Best Reviewer :
    200,000+ UV / Month

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JamesColin View Post
    Since you want to use $row['link'] you need to get it from the database, at the moment you're only getting ebname:
    $result = mysql_query("SELECT ebname FROM ebooks");

    so either add link:
    $result = mysql_query("SELECT ebname,link FROM ebooks");

    or take everything:
    $result = mysql_query("SELECT * FROM ebooks");

    Hope it helps.
    is it working if i add the link at the query?

  4. #4
    SitePoint Guru silver trophy JamesColin's Avatar
    Join Date
    May 2009
    Location
    Jomtien, Pattaya, Thailand
    Posts
    910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'd have to test.
    Do you really need traffic? Where to? What for?
    If you really do need traffic then stop messing around!
    Advertise on my sites today: She Told Me & Best Reviewer :
    200,000+ UV / Month

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JamesColin View Post
    You'd have to test.
    OK,will do that,hope it works

  6. #6
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JamesColin View Post
    Since you want to use $row['link'] you need to get it from the database, at the moment you're only getting ebname:
    $result = mysql_query("SELECT ebname FROM ebooks");

    so either add link:
    $result = mysql_query("SELECT ebname,link FROM ebooks");

    or take everything:
    $result = mysql_query("SELECT * FROM ebooks");

    Hope it helps.
    In Query like
    Code MySQL:
    SELECT * FROM ebooks
    there may be performance issues. So good advice is: don't be lazy and use the field that you want to fetch.


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
  •