skip to Main Content

I imported a database to my PHPmyadmin in which works well but when I try to display with

my php file, i don’t get true, the only I see is the field’s line on the top.

hier is my app;

<?php

  DEFINE('db_name', 'root');
  DEFINE('db_pass', 'root');
  DEFINE('db_host', 'localhost');
  DEFINE('db_database','SCV_DB');

  $dbcon =mysqli_connect("localhost", "root", "root", "SCV_DB");

  if (mysqli_connect_error()) {
    die('Connect Error ('.mysqli_connect_errno().') '.mysqli_connect_error());
  }
  $color=' well come to mysql';
  echo 'Connected successfully<br>';
  echo 'M. Mori ' . $color.'<br>';
  mysqli_set_charset($dbcon,"utf8");

  echo "<table><tr><th>SECTION</th><th>NAME</th><th>DATE</th><th>COUNTRY</th><th>PREIS</th></tr>";
  $consult="SELECT * FROM TABLE 1"; 

  $result=mysqli_query($dbcon,$consult);

  while($row = mysqli_fetch_row($result)) {
    echo "<tr><td>";
    echo $row[0]."</td><td>";
    echo $row[1]."</td><td>";
    echo $row[2]."</td><td>";
    echo $row[3]."</td><td>";
    echo $row[4]."</td></tr>";
  }

  echo "</table>";

?>

5

Answers


  1. Chosen as BEST ANSWER

    Hier is the database;enter image description here

    I hope this help for solve the problem.


  2. I hate mysqli procedural style, you should be using Object oriented style much more usefull here you can find more.

    Anyway! I was playing with procedural connections and saw your question hope its not a dupliacte one 🙂

    So here is connetction file what I was playing with! you can use your own connection.

    $host = '127.0.0.1';
    $db   = 'SCV_DB';
    $user = 'root';
    $pass = '';
    $port = '3308'; //Or 3307
    $charset = 'utf8mb4';
    
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);  
    $dbcon  = mysqli_connect($host, $user, $pass, $db, $port, $charset);
    
    
    if ($dbcon ->connect_error) {
        die("Connection failed: " . $dbcon ->connect_error);
    }
    

    Here is the query with prepare statements (prepare statements avoid you from sql injections espacialy when updating and inserting data)

    $sql = 'SELECT * FROM YourTableName';
    $stmt = mysqli_prepare($dbcon ,$sql);
    if(mysqli_stmt_execute($stmt)){
    $getResult = mysqli_stmt_get_result($stmt);
        while($rows = mysqli_fetch_assoc($getResult)){
            echo "id: ".$rows['id'];
            echo "<br>";
            echo "First name: ".$rows['first_name'];
            echo "<br>";
            echo "Last name: ".$rows['last_name'];
            echo "<br>";
        }
    }
    mysqli_stmt_close($stmt);
    
    Login or Signup to reply.
  3. <?php
    
      DEFINE('db_name', 'root');
      DEFINE('db_pass', 'root');
      DEFINE('db_host', 'localhost');
      DEFINE('db_database','SCV_DB');
    
      $dbcon =mysqli_connect("localhost", "root", "root", "SCV_DB");
    
      // Check connection
      if (!$dbcon) {
        die("Connection failed: " . mysqli_connect_error());
      }
      echo "Connected successfully";
    
      $color=' well come to mysql';
      echo 'Connected successfully<br>';
      echo 'M. Mori ' . $color.'<br>';
      mysqli_set_charset($dbcon,"utf8");
    ?>
        <table>
            <tr>
                <th>SECTION</th>
                <th>NAME</th>
                <th>DATE</th>
                <th>COUNTRY</th>
                <th>PREIS</th>
            </tr>
    <?php
        $consult="SELECT * FROM TABLE 1";//Please Don't these name for table name  
        $result=mysqli_query($dbcon,$consult);
        while($row=mysqli_fetch_row($result)):?>
    
        <tr>
            <td><?php echo $row[0];?></td>";
            <td><?php echo $row[1];?></td>";
            <td><?php echo $row[2];?></td>";
            <td><?php echo $row[3];?></td>";
            <td><?php echo $row[4];?></td>";
        </tr>
        <?php endwhile;?>
        </table>
    
    ?>
    
    Login or Signup to reply.
  4. I should in the first post explained better my problem. Well this file was an excel file.xls and i use Mac,so to use that in phpmyadmin, first i should convert it to CSV file than importe it, that wasn’t any problem because i can see perfectly the database in phpmyadmin but when I try to display it by php in the browser, I don’t

    get true.

    Login or Signup to reply.
  5. just renaming the table solved the problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search