Jump to content


Photo

[SOLVED] 2database


  • Please log in to reply
4 replies to this topic

#1 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 05 May 2006 - 05:57 PM

ok.. lets say i got 2 database..

one is for comments..

and another one for pictures..

what i'm trying to do is finding a way to assigne comment to a picture..

i was thinking about..

in the comment data base put a field with the name picname.. and in php assign the pic name to the comment..
like lets say..

$sql1= 'select name from pic';
$sql2='select name from comment';

insert into comment(picname,comment) values($picname,$comment)..

i just did somethin quick i'm just triyng to give a illustration..

my question is if everytime they view the picture will the be able to see the comment with such a simple comment books..

like when they viee the picture it will have..

select from commet where pic=$picname

.. will the be possible or there is some other way of joining 2 database that would make it easier..?

#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 05 May 2006 - 06:28 PM

why not just have one table for both?

#3 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 05 May 2006 - 06:32 PM

oh.. never thought about it that way.. i gues slet me give it a try..



#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 05 May 2006 - 06:35 PM

if you do use two tables you could do it this way:

SELECT * FROM `comment`,`pic` WHERE `pic`.`name` = `comment`.`name`

#5 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 05 May 2006 - 06:40 PM

that kind thing i was looking for.. but i'm trying the other way you told me first seens easier..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users