How to reset row in PHP?

How do I print out a single column from a row in my mysql database using php PDO.?

  • I have two pages, Index.php and insertcarbonate.php In my mysql I have a database called "drinks". In that database I have a table called "persons". In that table ...show more

  • Answer:

    Use URL like insertcarbonate.php?fname=NAME with code like: <html> <?php /*** mysql hostname ***/ $hostname = 'localhost'; /*** mysql username ***/ $username = 'username'; /*** mysql ***/ $password = 'password'; try { $dbh = new PDO( "mysql:host=$hostname;dbname=drinks", $username, $password); /*** echo a message saying we have connected ***/ echo 'Connected to database' . "\n"; /*** The SQL SELECT statement ***/ $fname = $_GET['fname']; $STH = $dbh -> prepare( "SELECT * FROM persons WHERE fname LIKE '$fname'" ); $STH -> execute(); $result = $STH -> fetch(PDO::FETCH_OBJ); //1); print $result->fname . " " . $result->lname . " (" . $result->age . ")" ; } catch(PDOException $e) { echo $e->getMessage(); } ?> <head> </head> <body> <p><?php print $result ; ?></p> </body> </html>

KGAEITXCM5MSNYOFZBCOOFOX5A at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.