trying to reduce script size
Posted: Mon May 17, 2010 11:29 am
I currently have a php script set up that executes 25 MySQL queries, creates 25 variables, and then places these into a html table.
They are along the lines of:
So I have $result1, $result2, $result3 . . . and so on up to $result25 (and the same for the $row)
In SQL I could simply use the query:
SELECT colour from db1.squares
and this would give me all the results I need in one go.
Is there a way I could use this query, and simply call the results one after the other, thus much reducing the size of my php script? I'm still new to PHP, so any help would be appreciated.
They are along the lines of:
Code: Select all
$result1 = mysql_query("SELECT colour from db1.squares WHERE row=1 and `column`=1")
$result2 = mysql_query("SELECT colour from db1.squares WHERE row=1 and `column`=2")
$row1 = mysql_fetch_array( $result1 );
$row2 = mysql_fetch_array( $result2 );
<td bgcolor=<?php echo $row1['colour']?>> </td>
<td bgcolor=<?php echo $row2['colour']?>> </td>So I have $result1, $result2, $result3 . . . and so on up to $result25 (and the same for the $row)
In SQL I could simply use the query:
SELECT colour from db1.squares
and this would give me all the results I need in one go.
Is there a way I could use this query, and simply call the results one after the other, thus much reducing the size of my php script? I'm still new to PHP, so any help would be appreciated.