The 'Do' method is for prepared statements and returns (by fetchall()). I am also using two looping statements. Is there any better way to fetch two tables in one statement or query? If not, what can I do to improve this code? // 'id' is index in 'userinfo' table and 'id' in 'election' table is a child index(foreign key) // 'ElectionId' is also the index, but it is not connected with othertable (only 'id' is linked) <?php $call = new world(); $get = $call->Do("SELECT Votes, Views, id FROM election WHERE ElectionId = ?", array("electionIdUknwn")); foreach($get as $show) { <div>"Votes is :".$show[0]</div> $add = $call->Do("SELECT username FROM userinfo WHERE id = ?", array($show[2]) ); foreach($add as $display) { <div>"Username is :".$display[0]</div> } <div>"Views are :".$show[1]</div> } ?>