Note that there are some explanatory texts on larger screens.

plurals
  1. POFor each ajax request,PHP return different results based on the time row was created
    primarykey
    data
    text
    <p>I have an ajax loop that returns recently created profiles from PHP encoded for JSON. What i want to do is first return the most recently created profile and go to the second recently created profile and so on every time ajax sends a request to PHP.</p> <p>How do i do this. So far the ajax loop just returns the same result since i can only get one recently created profile. </p> <p>Here's my PHP:</p> <pre><code>&lt;?php require_once 'db_conx.php'; $Result = mysql_query("SELECT * FROM profiles ORDER BY lastupdated desc limit 1") or die (mysql_error()); while($row = mysql_fetch_array($Result)){ $result = array(); $result['logo'] = $row['logo']; $result['name'] = $row['name']; echo json_encode($result); } ?&gt; </code></pre> <p>In the above php Block, if i remove 'limit 1' to something else, the ajax just stops working altogether.</p> <p>Here's my ajax code:</p> <pre><code>get_fb(); var get_fb = (function(){ var counter = 0; var $buzfeed = $('#BuzFeed'); return function(){ $.ajax({ dataType : 'json', type: "GET", url: "../php/TopBusinesses_Algorythm.php" }).done(function(feedback) { counter += 1; var $buzfeedresults = $("&lt;div style='margin-bottom:2px'&gt;&lt;input name='1' type='submit' id='LogLogo' value=' '&gt;&lt;span id='name' style='float:right; height:21px;font-weight:bold; color:#000; width:71%' class='goog-flat-menu-button'&gt;&lt;span class='LogName'&gt;&lt;/span&gt;&lt;/span&gt;&lt;span id='slogan'&gt;&lt;span class='LogSlogan'&gt;&lt;/span&gt;&lt;/span&gt;&lt;span id='services'&gt;&lt;span class='LogServices'&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span id='LogPid' style='height:170px; background-image:url(images/bg/iWhiteBg.fw.png)'&gt;&lt;/span&gt;&lt;/div&gt;"); $('.LogName').html(feedback.name).attr('id' + counter); $( '.LogSlogan' ).html(feedback.slogan); $('.LogPId').html(feedback.pid); $('.LogLogo').css('background-image', 'url(' + feedback.logo + ')' ).css('background-size', 'cover') $buzfeedresults.append(feedback); $buzfeed.append($buzfeedresults); var $buzfeedDivs = $buzfeed.children('div'); if ($buzfeedDivs.length &gt; 7) { $buzfeedDivs.last().remove(); } setTimeout(get_fb, 2000); }) }); }; })(); get_fb(); </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.
    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