Im trying to get the queries and results to load quicker. I have 10 of these after each other with slightly different queries, how can i optimize this please, i have tried removing select * and entering the field names require (which is about 9 rather than the 40 with * but it still is very slow).

<?php
$con;
$result = mysql_query("SELECT * FROM table WHERE `Field.1` = '$test' and `Field.2` > $test1 ORDER BY `Field.3` + 0 LIMIT 3") 
or die(mysql_error());  
 
echo "<table class = sample >";
echo "<tr> <th>h1</th> <th>h2</th> <th>h3</th> <th>h4</th> <th>h5</th> <th>h6</th> <th>h7</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
	// Print out the contents of each row into a table
	echo "<tr><td>";
	echo $row['h1'];
	echo "</td><td>";
        echo $row['h2'];
	echo "</td><td>"; 
	echo $row['h3'];
	echo "</td><td>";
	echo $row['h3'];
	echo "</td><td>";
	echo $row['h4'];
	echo "</td><td>";
	echo $row['h5'];
	echo "</td><td>";
	echo $row['h6'];
	echo "</td><td>";
	echo $row['h7'];
	echo "</td><tr>";
} 
 
echo "</table>";
?>

Why is the + 0 in the order by ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.