Búsquedas en cascada de PHP + MySQL a partir de resultados de consultas vinculadas

Apologies in advance for the wall of text; not sure if this is possible but i thought i'd ask. I've looked online and can't quite find what i want. I have been learning a lot of PHP and MySQL and am at the stage where i am starting to write my own database driven websites. A freely available database i have been practicing with is the eve_sdd_crucible_11 database which is freely available from the game website. I have been using it because it's huge and requires the use of a lot of different skills to get the most out of it.

I would like to do a simple database for exploration. This database queries the main one for information, creates a new table based on the search results and also allows the user to add their own comments on what they have found. I have the various queries ready to go but because i don't want a massive user interface, i want to keep the user side as clean as possible. This app needs to query and display results from the 'mapregions', 'mapconstellations', 'mapsolarsystems' and 'mapdenormalize' tables and insert this information into a new database with the retrieved info plus a comment box for each entity.

Now the preamble is done, this is what i am looking to do:

Query 'mapregions' (region name returns region ID to be used in next query) and display results (linked)-> click on linked result, query 'mapconstellations' (constellation name returns constellation ID to be used in next query) and display results (linked)-> click on linked result, query 'mapsolarsystems' (solar system name returns solar system ID to be used in next query) and display results (linked) -> click on linked result, query 'mapdenormalise' and display all entities in that system -> Inject content into new database along with comment boxes per listed entity.

Like i said earlier in the post, i have the queries set up ready to go, i have the beginnings of the php for the page but i am stuck on how to link these displayed results to the next query in the chain. All results have to display the name of the entity and it's the entity's corresponding ID number that is used to execute the next query in the chain.

Not sure if i've explained it particularly well, but it's the best i can do at this time of night... Any help or pointers would be vastly appreciated as it's starting to do my head in ;)

preguntado el 25 de abril de 13 a las 00:04

1 Respuestas

Need to look into joins - from reading through that text, it seems like you're missing a basic understanding of how to join tables - your 4th paragraph, to me, sounds like it should be a single query.

Creating a new database and/or table per search shows that you might still be missing some of the fundamentals - as that approach would never scale and would be a nightmare to manage.

Start reading up on mysql joins: Mysql Joins and go from there, looking at other examples of how joins work and real world examples - that will hugely affect how you continue building this.

Respondido 25 Abr '13, 00:04

The queries I already have are joins like the solar systems query for instance: SELECT solarSystemName, solarSystemID AS systemID FROM mapSolarSystems INNER JOIN mapRegions ON mapSolarSystems.regionID=mapRegions.regionID AND mapRegions.regionName='Essence'; It won't create a new table per search. The table that is created will be a one-off from an 'admin' section and i know what it is i need to do to prevent multiple tables being created for the same regions. I hope this explains it better :) - Sol de agujero negro

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.