php කාපරයෙක් වෙමු

gahasitha

Well-known member
  • Oct 29, 2008
    1,115
    775
    113
    38
    <?php
    $host="localhost";
    $dbuser="root";
    $pass="";
    $dbname="student";
    $conn=mysqli_connect($host,$dbuser,$pass,$dbname);
    if(mysqli_connect_errno())
    {
    die ("Connection Failed!" .mysqli_connect_error());
    }

    ?>
    <html>
    <head></head>
    <title>Quarying database assoc</title>
    <body>

    <?php
    $sql="SELECT * FROM student_info";
    $res =mysqli_query($conn,$sql);

    if(!$res)
    {
    die("Query Failed");
    }

    while($row=mysqli_fetch_assoc($res))
    {

    foreach($row as $key=>$val)
    {
    echo "($key):" ."{$val}<br/>";
    }
    echo "<br/><br/><br/>";
    }
    mysqli_free_result($res);
    ?>
    </body>
    </html>
    <?php
    mysqli_close($conn);
    ?>
    මේ code එකේ mysql output එක display කරන්නේ නෑ browser එකේ. database එක හදල තියෙන්නේ එක connect වෙනවත් එක්ක මොකක්ද මේකේ අවුල ?
     
    Last edited:

    mfdo90

    Well-known member
  • Jan 6, 2009
    1,160
    168
    63
    PHP for Beginners – Become a PHP Master – CMS Project
    මේ කෝස් එකේ.. ප්‍රොජෙක්ට් එක්සසයිස් ෆයිල් ටික හොයලා දෙන්න බැරිද?
    හොයලාම මහන්සී