general_paton99 Posted December 20, 2006 Share Posted December 20, 2006 I am new to MySQL and PHP so please forgive me if this is a stupid questions.How can I flip a tables data using a query?Current table (actual table has more fields)field_id user_id xdata24 5 Bob25 5 Villa26 5 1970-06-1224 6 Susan 25 6 Summers26 6 1970-06-10How can I get it to look like below using a query? I can't change the actual table, because it's called on by a much bigger system.user_id 24 AS first_name 25 AS last_name 26 AS birthday5 Bob Villa 1970-06-126 Susan Summers 1970-06-10Once queried, I then need to get it into a form which an admin can edit and update the respective fields.Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/31419-flipping-data-in-a-table-using-a-mysql-query-and-posting-to-a-php-form/ Share on other sites More sharing options...
jcbarr Posted December 21, 2006 Share Posted December 21, 2006 Once you query the database you can display the contents of the query where ever you you want by simply echoing them at the right places. For example;[code=php:0]$query=mysql_query("SELECT field_id, user_id, xdata FROM table_name");$data=mysql_fetch_assoc($query);//you can then echo the valuesecho $data['user_id'];[/code]Not sure exactly what you want to do with the information. But that is a simple way. Once you get the data from the table you can dump it into variables and display it however you want. Link to comment https://forums.phpfreaks.com/topic/31419-flipping-data-in-a-table-using-a-mysql-query-and-posting-to-a-php-form/#findComment-145572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.