Single PHP file to extract and display MySQL data in a report format

Is there is simple way to use a single PHP file to extract and display MySQL data in a report format?

I want a PHP file in it I will add the database connection credentials (db name, user name, password etc) and I want to run the following query and result the data in a report format.

[php]SELECT * FROM users WHERE allowed_user=1;[/php]

What kind of report format? If you just want a comma separated list you can out to csv
http://php.net/manual/en/function.fputcsv.php

I just need to display the result in a html display

I don’t know of any plug and play solutions for generating a “html report”. It’s trivial to output the data and there are so many use cases for how you want it displayed (list, table, custom elements, own styles, bootstrap, etc)

Something like this will work fine

Here is another simple tutorial on how to display data from a row of data… Hope it helps…

http://www.w3schools.com/php/php_mysql_select.asp

Many thanks, I tried this codes and it works fine.

I need to know how to make a condition to display only the LASTNAME = PETER. I tried like the below but not working

$stmt = $conn->prepare(“SELECT id, firstname, lastname FROM MyGuests WHERE lastname =PETER”);

You need to quote the string. If it is an integer, then no quotes needed…

WHERE lastname=‘PETER’" (Note quote quote double-quote…

BUT, that is for just a query, not a prepared statement. You do not need a prepared statement to
just make a standard query… Did that make sense?

Sponsor our Newsletter | Privacy Policy | Terms of Service