Member Avatar for nova37
$w3 = mysql_query( "SELECT * FROM w3" ) or die("SELECT Error: ".mysql_error());   
$worth = mysql_query( "SELECT * FROM worth" ) or die("SELECT Error: ".mysql_error());    
// fetching data 
while ($get_w3 = mysql_fetch_assoc($w3db) && $get_worth = mysql_fetch_assoc($worth))
{
		// Loading Urls for Comparing
	    echo $w3url=$get_w3['domain'];	   // cant echo	
	    echo $worthurl=$get_worth['domain'];  // ok printed

the code seems to be ok .. but i do not know why it cant print ( echo $w3url=$get_w3; )

please help
also is there any way to use separate while loops and compare data i use one while loop
for tow data fetches because i have to compare data of both tables

Recommended Answers

All 3 Replies

Member Avatar for diafol

This looks like an odd loop. I'd use a UNION for this, seeing as the data from each table is the same type/name.

(SELECT `domain`, 'w3' as source FROM w3)
UNION
(SELECT `domain`, 'worth' as source FROM worth);
ORDER BY `domain`


That'll give you a mix, with duplicates next to each other (below).

change this line

$w3 = mysql_query( "SELECT * FROM w3" ) or die("SELECT Error: ".mysql_error());

to

$w3db = mysql_query( "SELECT * FROM w3" ) or die("SELECT Error: ".mysql_error());

mysql_fetch_assoc($w3db), change $w3db to $w3 or use @ardav method. It is better way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.