chilicoctail Posted February 26, 2008 Share Posted February 26, 2008 Hi all. I am quite green in PHP and I have one problem. I have table, where I have records: ID col1 col2 col3 col4 1 a b c d 2 e f g h Now I want to get one record from table and I can get it like this: SELECT col1, col2, col3, col4 FROM table where id=1; The question is: How I could write col-names and values to the file like this: col1 a col2 b col3 c col4 d I dont want to get id-column-name or value to the file. Can someone help me ? Link to comment https://forums.phpfreaks.com/topic/93158-how-to-write-mysql-record-to-the-file/ Share on other sites More sharing options...
tinker Posted February 26, 2008 Share Posted February 26, 2008 1) When you say write to file, do you mean writing it to a text file, or serving it as an html file. 2) Do you want to show how you structure your mysql access (so can answer in your style (rather than do it all)) Link to comment https://forums.phpfreaks.com/topic/93158-how-to-write-mysql-record-to-the-file/#findComment-477322 Share on other sites More sharing options...
chilicoctail Posted February 26, 2008 Author Share Posted February 26, 2008 Hi tinker ! 1. I meant a text file. 2. Sure <?php $link = mysql_connect('localhost', 'db_user', 'password'); if (!$link) { die('Cound not connect: ' . mysql_error()); } mysql_select_db('database'); $query="SELECT col1, col2, col3, col4 FROM table WHERE id=1"; $result=mysql_query($query); ?> I really appreciate your help. Link to comment https://forums.phpfreaks.com/topic/93158-how-to-write-mysql-record-to-the-file/#findComment-477329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.