OrangeWire
IS-IT--Management
After reading php.net all day Im REALLY confused about how i should go about doing this...
i would like to merge 3 arrays into a single that
1) Does not have duplicate entries
2) Keeps the order of elements
Here is the code i have so far:
//Dont Mess With This Stuff, Jigga
mysql_connect($host, $user, $password) or die("Could not connect: " . mysql_error());
mysql_select_db($db);
$closest = 'SELECT `id_gal` '
. ' FROM `gals` '
. ' WHERE `gallery_text` '
. ' LIKE \'%pic%\' AND `main_page_link` '
. ' LIKE \'%pic%\' AND `main_page_description` '
. ' LIKE \'%pic%\'';
$closer = 'SELECT `id_gal` '
. ' FROM `gals` '
. ' WHERE `gallery_text` '
. ' LIKE \'%pic%\' AND `main_page_description` '
. ' LIKE \'%pic%\'';
$close = 'SELECT `id_gal` '
. ' FROM `gals` '
. ' WHERE `main_page_description` '
. ' LIKE \'%pic%\'';
$result1 = mysql_query($closest);
$result2 = mysql_query($closer);
$result3 = mysql_query($close);
print "<h1>CLOSEST:</h1><br>";
while ($row = mysql_fetch_array($result1)){
print $row[0] . "<br>\n";
}
print "<br><br><h1>CLOSER:</h1><br>";
while ($row = mysql_fetch_array($result2)){
print $row[0] . "\t" . $row[1] . "<br>\n";
}
print "<br><br><h1>CLOSE:</h1><br>";
while ($row = mysql_fetch_array($result3)){
print $row[0] . "\t" . $row[1] . "<br>\n";
}
The print statements are there to prove to me that i get the correct output:
CLOSEST:
14
62
74
82
90
93
96
100
101
149
211
314
319
374
388
390
391
407
421
570
577
CLOSER:
2
13
14
17
20
21
28
31
37
42
48
49
50
53
62
63
64
65
....(100 + more results)
CLOSE:
2
5
13
14
17
20
21
27
28
31
37
38
42
48
49
50
52
53
62
63
64
65
....(300 + more results)
Thanks very much for your time!!
i would like to merge 3 arrays into a single that
1) Does not have duplicate entries
2) Keeps the order of elements
Here is the code i have so far:
//Dont Mess With This Stuff, Jigga
mysql_connect($host, $user, $password) or die("Could not connect: " . mysql_error());
mysql_select_db($db);
$closest = 'SELECT `id_gal` '
. ' FROM `gals` '
. ' WHERE `gallery_text` '
. ' LIKE \'%pic%\' AND `main_page_link` '
. ' LIKE \'%pic%\' AND `main_page_description` '
. ' LIKE \'%pic%\'';
$closer = 'SELECT `id_gal` '
. ' FROM `gals` '
. ' WHERE `gallery_text` '
. ' LIKE \'%pic%\' AND `main_page_description` '
. ' LIKE \'%pic%\'';
$close = 'SELECT `id_gal` '
. ' FROM `gals` '
. ' WHERE `main_page_description` '
. ' LIKE \'%pic%\'';
$result1 = mysql_query($closest);
$result2 = mysql_query($closer);
$result3 = mysql_query($close);
print "<h1>CLOSEST:</h1><br>";
while ($row = mysql_fetch_array($result1)){
print $row[0] . "<br>\n";
}
print "<br><br><h1>CLOSER:</h1><br>";
while ($row = mysql_fetch_array($result2)){
print $row[0] . "\t" . $row[1] . "<br>\n";
}
print "<br><br><h1>CLOSE:</h1><br>";
while ($row = mysql_fetch_array($result3)){
print $row[0] . "\t" . $row[1] . "<br>\n";
}
The print statements are there to prove to me that i get the correct output:
CLOSEST:
14
62
74
82
90
93
96
100
101
149
211
314
319
374
388
390
391
407
421
570
577
CLOSER:
2
13
14
17
20
21
28
31
37
42
48
49
50
53
62
63
64
65
....(100 + more results)
CLOSE:
2
5
13
14
17
20
21
27
28
31
37
38
42
48
49
50
52
53
62
63
64
65
....(300 + more results)
Thanks very much for your time!!