Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7491131

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:53:34+00:00 2026-05-29T15:53:34+00:00

I have a MySQL table named relations, as follows: from to count ————- A

  • 0

I have a MySQL table named “relations”, as follows:

from to count
-------------
A    B  456
A    C  233
A    D  463
B    A  766
B    C  215
B    D  142

(In reality, “from” and “to” contain names of people and the table contains 150 rows). I now need to export this table to an excel file (not CSV) in (150×150) matrix form, like this:

  |  A    B    C   D
--+------------------
A |  0   456  233 463
B | 766   0   215 142

I need to do this from within PHP, but don’t know how to go about this. Do I first create an empty Excel file, naming all the rows and columns? (so like this:)

  |  A    B    C   D
--+------------------
A |
B |

If I do this, then how can I connect to the right cell to insert the correct counts? Or do I write the Excel file from within PHP alltogether?

Also, in reality the table is not structured, so it looks something like:

from to
-------
A    C
F    K
F    L
B    Z
M    P
P    A

So I don’t think I’m able to write cell-by-cell, row-for-row. Or I should first query the database to sort by column “from” and then by column “to”, probably.

Any help to get me started would be greatly appreciated.

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Related Questions

I have a MySQL table named relations, as follows: from to count ------------- A
I have multiple columns in a mySQL table. Three of the columns are named
I have two table in mysql named rootpath with only one field 'root' and
If I am calling a list of links from a mysql table named categories
I have a mysql table and a mysql view I'm trying to build relations
I have a mysql table named 'customer'. serialnumber (int), name(varchar), gender(varchar) are the table
I have a mysql table named events. Some events are featured. I want to
I have a MySQL table containing domain names: +----+---------------+ | id | domain |
I have a table in mysql like this Name Result T1_09_03_2010 fail T2_09_03_2010 pass
I have a table in MySQL of contact information ; first name , last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.