Right this is tough one for me and I can't figure it out. I have 2 .php files (one with iframe other with comment. so lets call them iframe.php and comment.php respectively).
In iframe.php file I get random url from database and put it as src of <iframe>
:
$sql = mysql_query("SELECT url FROM address_book ORDER BY RAND() LIMIT 1")
In comments.php file I get random url from same database table:
$sql = mysql_query("SELECT comment FROM address_book ORDER BY RAND() LIMIT 1")
Then on index.php page I have button:
<button id="nextfLuky" onClick="viewNext();return false;">Randomize</button>
This button calls following javascript function that inserts from iframe.php file into <div id="iframe"></div>
(located in index.php page). And comment from comment.php file is also inserted in <div id="comment"></div>
(Also located in index.php file)
And this is javascript called by <button>
function viewNext()
{
$("#iframe").load("iframe.php");
$("#coment").load("coment.php");
}
The problem is that I need to get url and comment that are related to each other from database (I can do it if I use one .php file, but I need to use two). And as I get them randomly in two different files they are not related to each other, when displayed in index.php file.
So how can I get url and comment that are related to each other if I get each one randomly in two different files?
Addition: Database Table Structure
______________________________________
id |int(11) |Auto Increment
______________________________________
url |varchar(255)
______________________________________
comment |text(1000)
______________________________________