• hellman.c

    (@hellmanc)


    oki

    i am new and i have tried all the information i found all over the web..

    i have 1 wordpress site att my host and a mysql db for wp (DB1)

    now i have a custom member page wher i am trying to get some information frome a second database (DB2)..

    i am truin too user current user id to grab only the data for that user from the second database..

    here is the code

    [insert_php]
    $servername = "host";
    $username = "user";
    $password = "pass";
    $dbname = "domsand_org_db_1";
    
    // Create connection
    $conn = mysqli_connect($servername, $username, $password, $dbname);
    // Check connection
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    $sql = "SELECT * FROM Medlemar WHERE Medl_nr = [current user id]";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
      echo "Medl_nr: " . $row['Medl_nr']. " - Namn: " . $row["namn"]. " " . $row["efternamn"]. "<br>";;
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    
    [/insert_php]

    what i want is too use [current user id] thath is number 25 .. grab the date frome the the table Medlemmar in the database domsand_org_db_1

    but with all test i only get array or 0 results printed—

    neeed serius help pleas

  • The topic ‘query in query or what it is’ is closed to new replies.