Jump to content

bitcycle

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bitcycle's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I keep getting mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I have an id field of index type. Why would this not be working. Thanks mark <HTML> <?php include "connect.php"; $result = mysql_query("SELECT * FROM music WHERE id=$id"); $myrow=mysql_fetch_array($result); echo $myrow["artistname"]<br; ?> </HTML>
  2. 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 and artists all artists alphabatized by letter like mainpage.php?letter=R. The mainpage show every artist in the database, mainpage.php?=Rock shows artists in a category and mainpage.php?=letter show all artists starting with the same letter. I created a letter field in the database. I understand how to structure the first if statement (if mainpage.php?cat=rock print all all rock artists but im not sure how to combine two conditions. like if mainpage.php?letter=a print all artists that start with a and only those and not all everty artist with it. Do I need a if elsif statement?Thanks Here is what I have so far mark [code]$db = mysql_connect("localhost", "root", "miy5uxiv"); mysql_select_db("db1",$db); #$result = mysql_query("SELECT * FROM db1 ORDER BY letter",$db); #$result2 = mysql_query("Select artist FROM db1 where cat='$cat'",$db) or die(mysql_error()); #$myrow2 = mysql_fetch_array($result2); // start where condition with void     $where = '' ;     // verify if cat is set     if ( $_REQUEST['cat'] != '' )     {         // set where condition         $where = ' where cat = "'. $_REQUEST['cat'] .'" ORDER BY artist ' ;     }     // mount the sql string     $sql = ' SELECT * FROM db1 '. $where  ;     // execute the query     $result = mysql_query ( $sql , $db ); while ($myrow = mysql_fetch_array($result)) { echo "<TR><TD>";   echo "<TD><a href=\"forumcode.php?id=".$myrow[id]."\">$myrow[artist]</a></br>"; echo "</br>"; } echo "</TABLE>"; $wheretest = ''; if ($_REQUEST['letter'] != '') {         $wheretest = ' where letter = "'.$_REQUEST['letter'] .'" ';   } $sqltest = ' SELECT * FROM db1 '. $wheretest ; $resulttest = mysql_query ($sqltest , $db ); $myrow2 = mysql_fetch_array($resulttest); echo "<TR><TD>"; echo "<TD> $myrow2[artist]"; echo "</table>" [/code]
  3. Darkness Soul, You da man, Thanks for helping
  4. 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(mys while ($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]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.