Announcement

Collapse
No announcement yet.

calling mysql fields into a .php webpage

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • calling mysql fields into a .php webpage

    Hey guys,
    I currently am customizing my forum a fair bit.
    And i have got stuck on this problem.

    Situation:
    I have created a .php document that displays a youtube video and it works fine.

    What I want:
    I want this .php document to display a users youtube video, so i need to get the field from the database and make it so the .php document can call it and use the link from it to display the video.

    The server is called: 'localhost'
    The database is called 'db_vbulletin'
    The table is called 'userfield'
    The field is called 'field39'

    But saying this, the youtube video link will be different between users, so im not sure what kind of factor that would have.

    If i am posting in the wrong place or there is a better forum, please direct me.
    Thanks.

    Murty

  • #2
    connect to data base
    PHP Code:
    $dbh=mysql_connect ("localhost""*username*""*password*") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("*Database name*"); 
    select data
    PHP Code:
    $sql "SELECT * FROM `*table*` ";
    $result mysql_query($sql $dbh); 
    display data
    PHP Code:
     
    while($row mysql_fetch_array($result))
      {
       echo 
    $row['field39'] ; // this is only to display the link not formated it in anyway 
      


    then DO NOT FORGET TO CLOSE CONNECTION

    PHP Code:
    mysql_close($dbh); 
    check http://www.w3schools.com/php/php_mysql_intro.asp for sql syntax

    Comment


    • #3
      Sorry to say, but that didnt work. Thanks anyways.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X