Skip to main content

Posts

Showing posts with the label mysql

MYSQL FORMATED OUTPUT

Most of the time when we run select statement in mysql command line if number of columns are more then we get output that is unread able from that command line ,get mysql select output formated sql select output vertically formated using following command select * from test\G; by appending \G at the end of your select statement you will get result as following *************************** 1. row *************************** column1: abc column2: test column3: admin column4: 2012-11-15 column5: test@gmail.com column6: test column7: test2 7 rows in set (0.00 sec)

PHP DATABASE CONNECTION

//connecting to db $conn = mysql_connect("localhost","peter","abc123"); if (!$conn) { die('Could not connect: ' . mysql_error()); } // some code mysql_close($conn); // closing connection //query db $data=$conn->query("SELECT * FROM myTable "); foreach($data as $row) { print_r($row); }