Check in other table

Started on the old forum in February 2010 · view the original in the archive · old links redirect here

8 replies · 499 views · started 16 years ago · 1 min read

2 participants
kei_ki7 Senior · 431 posts #1
echo "<br/>New Picture<br/>";
	$nsql = "SELECT pid, aid, name FROM ibwf_albumpic WHERE aid='"$prch[0]"' ORDER BY time DESC LIMIT 1";
    $news = mysql_query($nsql);
    echo mysql_error();  
    if(mysql_num_rows($news)>0)
    {
    while ($new = mysql_fetch_array($news))
    {
				echo "<a href=\"album.php?action=pix&pid=$new[0]\"><img src=\"../image.php?pid=$new[0]&s=50\"/></a><br/>";
				echo "<a href=\"album.php?action=pix&pid=$new[0]\">$new[2]</a><br/>";
	}
    }

i just want to take all pid in ibwf_albumpic but if aid of ibwf_albumpic is private=1 in aid of ibwf_album then that is not taken, but i dont have private in ibwf_albumpic

ibwf_album (aid, uid, album, private) ibwf_albumpic (pid, uid, aid, name, file, caption, time)

they only have same in uid and aid

is this possible?

Did I help you? You can help me too Your donations will help me finance my studies.

thanatos Senior · 261 posts #2

aid is the pid from the ibwf_album ryt? try..

SELECT private FROM ibwf_album WHERE pid='aid'
kei_ki7 Senior · 431 posts #3

thanatos wrote: aid is the pid from the ibwf_album ryt? try..

SELECT private FROM ibwf_album WHERE pid='aid'

thanks, but im sorry, i didnt get where to put that

Did I help you? You can help me too Your donations will help me finance my studies.

kei_ki7 Senior · 431 posts #4

ibwf_album (aid, uid, album, private) ibwf_albumpic (pid, uid, aid, name, file, caption, time)

aid of ibwf_album = aid of ibwf_albumpic

i want to take all pid in ibwf_albumpic but if aid of ibwf_albumpic is private=1 in aid of ibwf_album then that is not taken

is that possible?

its like select pid from ibwf_albumpic where aid and private=0 but my problem is the private checker is in ibwf_album

i thought i saw somewhere using something like this

select pid from ibwf_albumpic where (select pid from ibwf_album where aid and private=0)

i just cnt remember

im sorry, i will edit the 1st post

Did I help you? You can help me too Your donations will help me finance my studies.

thanatos Senior · 261 posts #5
$nsql =mysql_query(mysql_fetch_array("SELECT pid, name FROM ibwf_albumpic WHERE aid='".$prch[0]."' ORDER BY time DESC LIMIT 1"); $priv8 = mysql_query(mysql_fetch_array("SELECT private FROM ibwf_album WHERE pid='".$prch[0]."'"); if($priv8[0]=='1'){ $show = "<img src=\"images/offlimits.jpg\"/>"; }else{ $show = "<img src=\"img.php?pid=$new[0]\"/>"; } echo $show; 
thanatos Senior · 261 posts #6

select pid from ibwf_albumpic where (select pid from album where aid and private=0) i dnt knw hw 2 put it dat way.. bt u cn search gugel if u wnt ur query dat way..

kei_ki7 Senior · 431 posts #7

thanks again thana 😀 i will try this asap

btw im planning to change my query if i cannot make this work

Did I help you? You can help me too Your donations will help me finance my studies.

kei_ki7 Senior · 431 posts #8

thanks thana for your time and replies

$nsql = "SELECT pid, aid, name FROM ibwf_albumpic WHERE aid = ANY (SELECT aid FROM ibwf_album WHERE private=0) ORDER BY time DESC LIMIT 1";

i use this and its works

Did I help you? You can help me too Your donations will help me finance my studies.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close