bitcycle Posted December 5, 2006 Share Posted December 5, 2006 I have a database of music artist. I want the main page to show all artist. Then artist by genre with mainpage.php?cat=Rock.My problem is not understanding what kind of statements I need to be researching to do this.This code below puts everything on one page. I think I need an if then statement but Im not sure how to state if this link is clicked echo this if that link is pressed echo that This is what I have so far. Thanks. O yea I'm very new to this. I have 2 years of linux admin background and I'm starting to learn html php mysql.bye[code]<?$db = mysql_connect("localhost", "root", "password");mysql_select_db("db1",$db);$result = mysql_query("SELECT * FROM db1",$db);$result2 = mysql_query("Select artist FROM db1 where cat='$cat'",$db) or die(myswhile ($myrow = mysql_fetch_array($result)){echo "<TR><TD>"; echo $myrow["artist"];echo "</br>";}echo "</TABLE>";While ($myrow2 = mysql_fetch_array($result2)){echo "<TR><TD>";echo $myrow2["artist"];echo "</br>";}echo "<TABLE>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/29506-php-mysql-structure/ Share on other sites More sharing options...
Darkness Soul Posted December 5, 2006 Share Posted December 5, 2006 I think you wanna something like:[code] // start where condition with void $where = '' ; // verify if cat is set if ( $_REQUEST['cat'] != '' ) { // set where condition $where = ' where cat = "'. $_REQUEST['cat'] .'" ' ; } // mount the sql string $sql = ' SELECT artist FROM db1 '. $where ; // execute the query $result = mysql_query ( $sql , $db )[/code]D.Soul Link to comment https://forums.phpfreaks.com/topic/29506-php-mysql-structure/#findComment-135416 Share on other sites More sharing options...
bitcycle Posted December 5, 2006 Author Share Posted December 5, 2006 Darkness Soul,You da man, Thanks for helping Link to comment https://forums.phpfreaks.com/topic/29506-php-mysql-structure/#findComment-135427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.