Note that there are some explanatory texts on larger screens.

plurals
  1. POsend php text output to client browser and run rest in server side
    primarykey
    data
    text
    <p>I have a straight forward php script thats performs one mysql query. Based on this i then run about 10 more mysql queries. I then return the result via echo to the client.</p> <p>But to save time for the client I can echo the result out THEN run the remaining 10 mysql queries server side so the client gets a quicker response.</p> <p>can this be done? or does the client have to wait for the entire php script to executed server side before getting a text response? </p> <p>Heres my code:</p> <pre><code> $dbc = mysql_connect("$db_host","$db_username","$db_pass"); if (!$dbc) { die('SERVER ERROR PLEASE CONTACT US FOR MORE INFORMATION!'); } mysql_select_db("$db_name", $dbc); $sql = "SELECT * FROM `ads` WHERE (`status` LIKE 'active%' OR `status` LIKE 'featured%') ORDER BY `clicks` DESC LIMIT 10;"; $result = mysql_query($sql,$dbc); $totalads=mysql_num_rows($result); $str=""; while ($row = mysql_fetch_assoc($result)) { $str .= $row["banner"] . "][". $row["link"] . "&lt;BR&gt;"; //the code below is used to update stats but can be run after output to client $views=$row["views"]; $targetviews=$row["targetviews"]; if (intval($views)+1 &gt;= intval($targetviews)) { $sql1 = "UPDATE `ads` SET `views` = `views` + 1 , `status` = 'expired' WHERE `ID`=".$row["id"].";"; } else { $sql1 = "UPDATE `ads` SET `views` = `views` + 1 WHERE `ID`=".$row["id"].";"; } $result2 = mysql_query($sql1,$dbc); mysql_free_result($result2); } $str=rtrim($str,"&lt;BR&gt;"); mysql_free_result($result); mysql_close($dbc); die ($str); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload