Re: Re: another php/mysql problem

From: Date: Wed, 25 Jul 2001 20:49:55 +0000
Subject: Re: Re: another php/mysql problem
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-10771@lists.php.net to get a copy of this message
Couple of comments: 1. What's with the $artist = "artist"; echo $mytable[$artist]; bit? This really doesn't seem to gain you much. 2. Descriptive variable names are a Good Thing(tm). 3. Prettyprinting " 4. Why are the tables in different databases to begin with? 5. Don't pull any more than you need from the database. Try: <?php // expects $band as parameter mysql_connect("localhost","username","password") or die ("Could not connect to MySQL!"); $band_result = mysql_query( "SELECT nospaces_bands, band_bands, id, email " ."FROM almavale_board.bands" ."WHERE nospaces_bands = '$band' " ) or die("Error in band query"); while ($band_row = mysql_fetch_array($band_result)) { printBand($band_row); $shows_result = mysql_query( "SELECT artistname, venue, time " ."FROM almavale_board.shows " ."WHERE artistname = '".$band_row["band_bands"]."'" ) or die("Error in show query"); while($show_row = mysql_fetch_array($show_result)) printShow($show_row); $release_result = mysql_query( "SELECT bandname, albumtitle, email " ."FROM almavale_releases.releases " ."WHERE bandname = '".$band_row["band_bands"]."'" ) or die("Error in release query"); while($release_row = mysql_fetch_array($release_result)) printRelease($release_row); } ?> ... and you can implement printBand, printShow, and printRelease as you like.

« previous php.db (#10771) next »