I have a very small sqlite3 database with one row consisting of three columns but I can get the page to display the row to save my life. So far all I've been able to get the page to display is the first column of the one row that's in my DB using querySingle and echo $result. $entry doesn't seem to be doing anything neither does the bottomw while loop. Any ideas. All I want to do here is display the one row that's in my DB to the screen.

<?php
echo "<html>";
echo "<body>";
// get variable from html form
//$fName = $_POST['fname'];
//$lName = $_POST['lname'];
//$address = $_POST['email'];

$db = new SQLite3('./et.sqlite3', SQLITE3_OPEN_READWRITE);

if(!$db)
{
    echo "Could not open/access DB";
}
else
{
    echo "Database is here";
    //$result = $db->query('select * from customers');
    //var_dump($db->querySingle('select * from customers'));
    //print_r($db->querySingle('select * from customers', true));
    $result = $db->querySingle('select * from customers');
    echo $result;
    $query = sqlite_query($db, 'select * from customers');
    while($entry = sqlite_fetch_array($query, SQLITE_NUM))
    {
        echo $entry[0]." ".echo $entry[1]." ". echo $entry[2];
    }

    $i = 0;

    while($i < strlen($result))
    {
        echo $result[$i];
        $i++;
    }
}

echo "</body>";
echo "</html>";
?>

Recommended Answers

All 3 Replies

Try to run a small example to check if there is any output from this.Also check if there is any data in table.

 <?php
$db = new SQLite3('database.db');

var_dump($db->querySingle('select * from customers'));
print_r($db->querySingle('select * from customers', true));
?>

IIM thanks, your suggestion, it sort of worked but I want it to display all the columns in order in one line without all the technical mumbo jumbo '=>', just simply, I want it to print out "Fisrtname, LastName, EmailAddress"

string(7) "FirstName" Array ( [fname] => Firstname [lname] => LastName [email] => myEmailAddress )

pritaeas sorry, I post in more than one forum and sometimes forget that I already have a post in one forum or another.

Be a part of the DaniWeb community

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