1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Fetch Info From MySQL Database

Discussion in 'PHP' started by tushardhoot1, Nov 5, 2007.

  1. #1
    Hey,

    I know this seems very novice, but I've been in school/on vacation for past 4 months, and I'm very, very rusty.

    Please help me :D

    Okay, so basically I have a table with 3 columns: interestnp, interestrs, and interestwv.

    Each column has 1 row with a number in it. I basically want to know the php script that will let me pull up that number and display it.

    Like, on one part of my site I want only the interestrs number, but on the other I want the interestnp number. So I need to pull them up separately. Do I need to change my table format for this?



    Thanks for the help in advance.
     
    tushardhoot1, Nov 5, 2007 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    nope, you dont have to do anything in the table..

    you will do this in your query

    
    $result = mysql_query("SELECT * FROM tablename");
    // to show all records on those 3 columns
    while($Fresult = mysql_fetch_array($result)) 
    {
    echo $Fresult['interestnp'] . "<br>" . $Fresult['interestrs'] . "<br>" . $Fresult['interestwv'];
    }
    
    PHP:
    to seperate the two columns
    
    $result = mysql_query("SELECT interestnp AS name FROM tablename");
    // to show all records on that columns
    while($Fresult = mysql_fetch_array($result)) 
    {
    echo $Fresult['name'];
    }
    
    PHP:
    this is the simplest way of doing this,, hope this help..
    ive done it in rush,, its lunch time here...
    keep posted if i have a bug on the script... gtg.. eat mode
     
    bartolay13, Nov 5, 2007 IP
    tushardhoot1 likes this.
  3. tushardhoot1

    tushardhoot1 Active Member

    Messages:
    3,013
    Likes Received:
    96
    Best Answers:
    0
    Trophy Points:
    90
    #3
    K thanks.

    Haven't tried it yet, but when I do I'll post (unable to right now).

    Will this script work over and over on the same page? Like, if I put it on the top of the page, can I also run the script at the bottom. Interestnp at the top, and interestrs at the bottom?

    Thanks!
     
    tushardhoot1, Nov 6, 2007 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    yep, you can put this script over and over again..
    gudluck on your project!

    send us some news on your project! keep posted
     
    bartolay13, Nov 6, 2007 IP
  5. tushardhoot1

    tushardhoot1 Active Member

    Messages:
    3,013
    Likes Received:
    96
    Best Answers:
    0
    Trophy Points:
    90
    #5
    It WORKS!

    Thanks a million!

    Rep given.
     
    tushardhoot1, Nov 7, 2007 IP