GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Dec-2006, 21:06
rsfyo rsfyo is offline
New Member
 
Join Date: Dec 2006
Posts: 1
rsfyo is on a distinguished road

Combining 2 seperate select statements


Hi all,
could someone please tell me how I change this simple piece of code that displays ALL the members pictures to only showing the MALE members pictures.


PHP Code:

<?
$get_pictures = mysql_query("SELECT * FROM members_pictures WHERE picture_type='1' AND picture_status='1' ORDER BY RAND() LIMIT 1000");

$number = 0;

while ($got_pictures = mysql_fetch_array($get_pictures)) {

echo "&nbsp;<a href=\"".$got_pictures['picture_username']."\" class=\"title_text\"><img src=\"".$got_pictures['picture_path']."\" width=\"80\" height=\"80\" border=\"1\"></a>&nbsp;&nbsp;&nbsp; ";

$number++;

if ($number==7){

echo '</td></tr><tr><td>';

$number=0;

}

}

?>



I tried using the UNION statement in the middle as shown below but keep getting error messages.

PHP Code:

<?
$get_pictures = mysql_query("SELECT * FROM members_users WHERE basic_gender='MALE' ORDER BY RAND() LIMIT 1000 UNION SELECT * FROM members_pictures WHERE picture_type='1' AND picture_status='1' ORDER BY RAND() LIMIT 1000");
$number = 0;
while ($got_pictures = mysql_fetch_array($get_pictures)) {
echo "&nbsp;<a href=\"".$got_pictures['picture_username']."\" class=\"title_text\"><img src=\"".$got_pictures['picture_path']."\" width=\"80\" height=\"80\" border=\"1\"></a>&nbsp;&nbsp;&nbsp; ";
$number++;
if ($number==7){
echo '</td></tr><tr><td>';
$number=0;
}
}
?>


Thanks so much.
Last edited by LuciWiz : 20-Dec-2006 at 13:58. Reason: Please insert your Php code between [php] & [/php] tags
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
combining 2 fields in a single mysql select query mrjameer MySQL / PHP Forum 1 28-Sep-2006 19:38
Noob Programmer having trouble with if and switch statements in program Heresy C Programming Language 4 17-Feb-2006 17:55
Basic understanding on winsock select() Kjeksen CPP / C++ Forum 1 30-Aug-2005 07:42
select problem zuzupus MySQL / PHP Forum 0 15-Aug-2003 07:25
combo box select problem zuzupus MySQL / PHP Forum 2 23-Jul-2003 11:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:32.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.