PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have inherited a site written using PHP. I am new to this and have found that part of the code doesn't do what it is meant to. The code is meant to pull teams from the mysql database and order them by team name. However the only entries that are displayed are those belonging to the first team name no others display. Could someone tell me what is wrong with the code. The code before and after this works ok. Thanks in advance.
hi there - to test what's happening, i'd suggest echoing the number of rows (echo $num_records; and echo $num_recordlist;) each sql query retrieves. If it's only 1, then the sql statement is going to be your problem (or the actual data in your database), if not, it's probably the way the data is being looped through, displayed.
benniss wrote:I have inherited a site written using PHP. I am new to this and have found that part of the code doesn't do what it is meant to. The code is meant to pull teams from the mysql database and order them by team name. However the only entries that are displayed are those belonging to the first team name no others display. Could someone tell me what is wrong with the code. The code before and after this works ok. Thanks in advance.
...
[color=#008040]$query="SELECT * FROM entries WHERE eventcode='$eventcode' AND school='$schoolname' GROUP BY 'eventteam'";[/color]
...
[color=#008040]$querylist="SELECT * FROM entries WHERE eventcode='$subeventcode' AND eventteam='$subeventteam'";
...[/color]
The 2 lines I have highlighted in green form two queries to the database. The first one will retrieve records from the table "entries" which contain specific values in 2 fields named "eventcode" and "school", and group them by a field named "eventteam". The second one will retrieve records from the same table which contain specific values for the "eventcode" field and the "eventteam" field. If the table contains records for more than one "eventteam", the first query should retrieve all of them that match the "eventcode" and "school" data values. The second query will never retrieve records for any "eventteam" except the one it is searching for.