Php is printing only one row

how to fetch single row data from database in php
php for loop
php print to printer
php println
php array
php print page to printer
rowcount php
php print to console

As you can see, i'm selecting user from data base, but its only printing one! I have like 10 users that needs to be printed.

      $currentgroup = $_SESSION['groupname'];
      $sql1 = "SELECT * FROM hjuma_users WHERE group1 ='$currentgroup' OR group2 ='$currentgroup' OR group3 ='$currentgroup' OR group4 ='$currentgroup' OR group5 ='$currentgroup';";
      if($result1 = mysqli_query($conn, $sql1)){
        if(mysqli_num_rows($result1) > 0){
            while($row1 = mysqli_fetch_array($result1)){ ?>

<div id="id01" class="modal">
  <form class="modal-content animate" action="/action_page.php">
    <div class="imgcontainer">
      <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span>
    <div class="container">
      <?php echo $row1['username']; ?>


<?php   }

it looks like you are not incrementing $result1

How I can print just one row select from mysql PHP?, PDOStatement::rowCount() returns the number of rows affected by a DELETE, print("Return number of rows that were deleted:\n"); Great, while using MySQL5 , the only way to get the number of rows after doing a PDO SELECT query is to� Hi :) I have a HP Envy 4524 that insists on only printing one line (normally the fourth/fifth line) of any document. We have tried printing from two mac-books and a "windows" based Dell and get the same results. I have re-installed & updated the software from HP, "cleaned the printheads" -

Please check the value of $currentgroup.

If you can give the screenshot of the database table hjuma_users and the value of $currentgroup.

I think you are getting one value due to the condition

WHERE group1 ='$currentgroup' OR group2 ='$currentgroup' OR group3 ='$currentgroup' OR group4 ='$currentgroup' OR group5 ='$currentgroup

PDOStatement::rowCount - Manual, The major differences to echo are that print only accepts a single argument and always returns 1. Parameters �. arg. The input data. Return Values �. Returns 1,� How to print or echo all the values of an array in PHP. Topic: PHP / MySQL Prev|Next Answer: Use the PHP foreach loop. There are so many ways of printing an array values, however the simplest method is using the foreach loop.

You should use mysqli_fetch_assoc as below code:

$currentgroup = $_SESSION['groupname'];
$sql1 = "SELECT * FROM hjuma_users WHERE group1 ='$currentgroup' OR group2 ='$currentgroup' OR group3 ='$currentgroup' OR group4 ='$currentgroup' OR group5 ='$currentgroup';";
if ($result1 = mysqli_query($conn, $sql1)) {
    if (mysqli_num_rows($result1) > 0) {
        $modalId = 1;
        while ($row1 = mysqli_fetch_assoc($result1)) { ?>
            <div id="id<?php echo $modalId; ?>" class = "modal">
            <form class = "modal-content animate" action = "/action_page.php">
            <div class = "imgcontainer">
            <span onclick = "document.getElementById('id<?php echo $modalId; ?>').style.display='none'" class = "close" title = "Close Modal">&times;
            <div class = "container">
            <?php echo $row1['username'];



print - Manual, Row number in result to fetch. Rows are numbered from 0 upwards. If omitted, next row is fetched. field. A string representing the name of� Here there are two ways to use PHP drivers to connect to MySQL and execute the functions for getting records. One is using Portable Data Object ( PDO ) Second one is MySQLI ( MysQL Improved ) We will learn both here. We will first use PDO and at the end we will use MySQLI. You can use any one for your script. Displaying Links to individual records

pg_fetch_result - Manual, Prints all rows from a result identifier produced by odbc_exec(). The result is printed in HTML table format. Parameters �. result_id. The result identifier. format. Definition and Usage The fetch_row () / mysqli_fetch_row () function fetches one row from a result-set and returns it as an enumerated array.

odbc_result_all - Manual, (PHP 4, PHP 5). mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both. Warning. This extension was deprecated in PHP 5.5.0,� Returns an numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows. mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

mysql_fetch_array - Manual, Steps to reproduce the issue. I write PHP script to tracerout some IP addr on article but only print one raw output. On the other hand,I copy the� Many developers have submitted bugs to the PHP development team with regards to print_r showing protected and private properties of objects (PHP 5). This is not a bug; sensitive information (ex. database connection object) should be encapsulated within a private member function of your class.

  • Just a note that each row will have <div id="id01", so the id will be repeated and then you use getElementById('id01') which will have a few to choose from.
  • i dont understand, can you give me some code for example? i think that is the problem, how can i fix it?
  • Can you echo record's data without HTML?
  • yes i can, i just tried it
  • According to the php documentation there is no function mysqli_fetch_array(), so I'm surprised you even get one result.
  • Using mysqli_fetch_array() will automatically move the result set onto the next row.
  • mysqli_fetch_all returns all rows in one call.
  • have you tried mysql_fetch_assoc?? Please check the updated answer. Also, if it doesn't work, then you should print your query directly and try to execute that in sql directly. May be your query is only returning one row
  • I did print my query directly and it worked, but it doesnt work inside a modal, how is that possible.... Inside the modal its printing only one user, but outside all of them..
  • @RohitMittal mysql_fetch_array is not compatible with mysqli_query.
  • @JurajJaušovec use mysqli_fetch_assoc array as above updated answer. I have checked it and it is working fine on my system.