For example:
I have a table name foo which has a column, abc. In abc column I have 3 same records and I want to show these 3 same records one by one every time page refreshed.
I can not use loop because loop will load all records at one time, and I don't want to show all of these records once. I want to show a single record at a time.
id user_id abc link
1 2 google http://foo.com
2 3 google http://bar.com
3 2 google http://baz.com
4 3 bing http://qar.com
5 1 yahoo http://quz.com
More Explanation: (Update 1)
I want to show only these links which are from google, now the problem is I have google three times in my table. If I use mysql_fetch_assoc() this will give me first record from google but not the other two and I want all googlelinks one by one by refresh.
You can use $_SESSION
variables. Here $_SESSION['refresh_record']
keeps track of the time the page is refreshed.
So, each time the page is refreshed, this AJAX is run, to increment the session variable.
$("#formid").submit(function(){
$.ajax({
type: "POST",
url: "UpdateTheSession.php",
data: $(this).serialize(),
success: function(){
// Do what you want to do when the session has been updated
}
});
return false;
});
UpdateTheSession.php
$_SESSION['refresh_record'] = $_SESSION['refresh_record'] + 1;
Now get the all the records into an array, then:
$result[$_SESSION['refresh_record']];
The above code should print a picture of what you should do in your mind. Cheers.