Re: Re: another php/mysql problem

From: Date: Wed, 25 Jul 2001 17:14:49 +0000
Subject: Re: Re: another php/mysql problem
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-10759@lists.php.net to get a copy of this message
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" <m_wagner@informatik.uni-kl.de> To: <php-db@lists.php.net> 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

« previous php.db (#10759) next »