Hi Matt

I think I get what you're trying to do.

I'd do something like this...

Put all three tables in the same database. Add a column to bands called uid
(I _think_ you'll have to recreate the table first cos you need it to be
AUTO_INCREMENT, and add a PRIMARY KEY onit). Then add a column to shows
called band_id and a column to releases called band_id.

Your query for bands.php will be something like this...

SELECT * FROM bands, shows, releases WHERE bands.uid = '$band' AND
shows.band_id = bands,uid AND releases.bandid = bands.uid

This will get you one long row full of everything to do with that band.

Displaying the material is just a matter of doing a while ($row =
mysql_fetch_row)) etc


Make sense?

HTH!

Dave


-----Original Message-----
From: Matt Nigh [mailto:[EMAIL PROTECTED]]
Sent: 25 July 2001 18:15
To: Markus Wagner; [EMAIL PROTECTED]
Cc: php-db
Subject: Re: [PHP-DB] Re: another php/mysql problem


ok, well it looks like no one really understood my problem, which is ok
because didn't explain it well. i can barely understand myself what i'm
trying to do, but what i'll try doing is just telling you all what exactly i
need to happen.

ok, i have 3 tables, two of them (bands, shows) being in a DB named
almavale_board and the other table (releases) being in a DB named
almavale_releases. essentially what i want to have is a bands page that
displays a bio, links etc. (from the bands table), their releases (releases
table) and their shows (shows table). i need to pull this data from the two
DBs and then display them so each band has their own page, but it runs off
the same page (ie. bands.php). so what i want to have is
http://site.com/bands.php?band=thebandsname and then since i've defined the
variable $band in the URL, only the info from the row in the
'nospaces_bands' column with the value 'thebandsname' will be displayed.
then from that, the shows table will take the value from one of the columns
in the 'bands' table named 'band_bands' and will find all the records in the
shows table that have that same value in the column 'artistname'. then from
there, the releases table in the 'almavale_releases' DB will take the value
from the column 'artistname' in the 'shows' table and  will find all the
records in the releases table that have that same value in the column
'bandname'. so basically, i wanna pass multiple variables across these
tables/databases and display all the records that match each one. it's
pretty confusing, so i hope i explained it well enough for all to
understand.

thanks,


Matt


----- Original Message -----
From: "Markus Wagner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 5:25 AM
Subject: [PHP-DB] Re: another php/mysql problem


>
>
> Matt Nigh schrieb:
>
> > Matt Nigh
> >
> > <?php
> > $link = mysql_connect("localhost","username","password");
> > if(!$link) die ("Could not connect to MySQL!");
> > mysql_select_db("almavale_board",$link);
> > if (!isset($band)) {
> > die("No artist specified.");
> > }
> > $sql = "select * from bands where (nospaces_bands = '$band')";
> > $result = mysql_query($sql);
> > if (mysql_num_rows($result) <= 0) {
> > die("Sorry, there was no artist found by that name.");
> > }
> > if (!$my_row = mysql_fetch_array($result)) {
> > die("Please specify an artist.");
> > }
> > $band = "nospaces_bands";
> > $band_spaces = "band_bands";
> > $id = "id";
> > $email = "email";
> > echo "<b>band name without spaces:</b> " . $my_row["$band"];
> > echo "<br><b>band name with spaces:</b> " . $my_row["$band_spaces"];
> > echo "<br><b>id:</b> " . $my_row["$id"];
> > echo "<br><b>email address:</b> " . $my_row[$email];
> >
> > $band_spaces = $artist;
> >
> > mysql_select_db("almavale_board",$link);
> > $sql_01 = "select * from shows where (artistname = '$artist')";
> > $result_01 = mysql_query($sql_01);
> > if (mysql_num_rows($result_01) <= 0) {
> > die("<br><br>No shows found.");
> > }
> > $my_row_01 = mysql_fetch_array($result_01);
> >
> > $artist = "artistname";
> > $venue = "venue";
> > $time = "time";
> > echo "<br><br><hr><b>artist name with spaces:</b> " .
$my_row_01["$artist"];
> > echo "<br><b>venue:</b> " . $my_row_01["$venue"];
> > echo "<br><b>time:</b> " . $my_row_01["$time"];
> >
> > $artist = $band_name;
> >
> > mysql_select_db("almavale_releases",$link);
> > $sql_02 = "select * from releases where (bandname = '$band_name')";
> > $result_02 = mysql_query($sql_02);
> > if (mysql_num_rows($result_02) <= 0) {
> > die("No releases found.");
> > }
> > $my_row_02 = mysql_fetch_array($result);
> > $band_name = "bandname";
> > $albumtitle = "albumtitle";
> > $email = "email";
> > echo "<br><br><hr><b>artist name with spaces from releases:</b> " .
$my_row_02["$artist"];
> > echo "<br><b>album name:</b> " . $my_row_02["$albumtitle"];
> > echo "<br><b>album code:</b> " . $my_row_02["$albumcode"];
> >
> > mysql_close($link);
> > ?>
>
> What do you exactly want to do?
>
> And what is that?
>
> $band = "nospaces_bands";
> $band_spaces = "band_bands";
> $id = "id";
> $email = "email";
>
> Why don't you do this:
>
> echo "<b>band name without spaces:</b> " . $my_row["band"];
> echo "<br><b>band name with spaces:</b> " . $my_row["band_spaces"];
> echo "<br><b>id:</b> " . $my_row["id"];
> echo "<br><b>email address:</b> " . $my_row[email];
>
> Greetings
>
> Kobi


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to