Soldato
at the moment this is the rough structure of my site.
1. first i include the files i need that connect to the db, have all the variables that will be used to query the database, such as the below, and then close the db connection
2. i then have the header section of the site
3. and then the main content which will have lines like
now this usually works fine when there is just one while loop. it grabs what i need and i do what i want with it. the issue i have is when i do the above and have a while loop inside a while loop as the second loop is returning nothing.
as best i can i've figured this out to be because of the way it's structured and the query line coming before the first while loop, so before the $comId is figured out, but i can't think how else to structure this so that the database query variables are in another file, able to be used by other pages.
i also understand i could join the 2 database queries into one using the join ability, but am lost how to do this. anyone able to simplify it and explain what i should be doing?
1. first i include the files i need that connect to the db, have all the variables that will be used to query the database, such as the below, and then close the db connection
PHP:
$result_comsingle = mysqli_query($con,"SELECT * FROM commercial WHERE comId = '$comId'");
3. and then the main content which will have lines like
PHP:
while($row = mysqli_fetch_array($result_stafftimes_repeat)) {
$comId =$row['comId'];
$frequency =$row['frequency'];
$amount =$row['amount'];
while($rowcom = mysqli_fetch_array($result_comsingle)) {
$comName = ucwords($rowcom['name']);
$comColor = ucwords($rowcom['color']);
}
$tableTimes .= "<tr><td>Location:".$comName."</td></tr>";
$tableTimes .= "<tr><td>Frequency:".ucwords($frequency)."</td></tr>";
}
now this usually works fine when there is just one while loop. it grabs what i need and i do what i want with it. the issue i have is when i do the above and have a while loop inside a while loop as the second loop is returning nothing.
as best i can i've figured this out to be because of the way it's structured and the query line coming before the first while loop, so before the $comId is figured out, but i can't think how else to structure this so that the database query variables are in another file, able to be used by other pages.
i also understand i could join the 2 database queries into one using the join ability, but am lost how to do this. anyone able to simplify it and explain what i should be doing?