hi, in the mysql we can fetch data and store them into variables, like the code below:

    if (mysql_num_rows($userquery) != 1) {
    die ("that member could not be found!");
    while($row = mysql_fetch_array ($userquery, MYSQL_ASSOC)){
        $first_name = $row['first_name'];
        $last_name = $row['last_name'];
        $email = $row['email'];
        $password = $row['password'];
        $sex = $row['sex'];
        $dbusername = $row['username'];

but how can i do the same with pdo??

Re: how to fetch data from database and store into variables!! 80 80
Member Avatar


You'll notice that you return a multidimensional array instead of a resource. You can iterate with a foreach loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.