I am trying to add a new book to my database via the browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PatTheBeginner
    New Member
    • Oct 2010
    • 1

    I am trying to add a new book to my database via the browser

    Hi, the tables display ok but nothing happens when the "Add" button is clicked.
    The new album should appear at the bottom of the list?

    Code:
    <HTML>
    <BODY>
    Album Database     ADDING Albums BY Names ETC
    
    <TABLE BORDER="0">
    
    <FORM METHOD="GET">
    
    <TR><TD>name</TD><TD><input type="text"name="name"></TD></TR>
    
    <TR><TD>band</TD><TD><input type="text"name="band"></TD></TR>
    
    <TR><TD>sold</TD><TD><input type="text"name="sold"></TD></TR>
    
    <TR><TD>genre</TD><TD><input type="text"name="genre"></TD></TR>
    
    <TR><TD>country</TD><TD><input type="text"name="country"></TD></TR>
    
    <TR><TD>year</TD><TD><input type="text"name="year"></TD></TR>
    
    <TR><TD>order</TD><TD><input type="text"name="order"></TD></TR>
    
    <TR><TD><input type="submit"value="Add" name="Submit"></TD><TD><input type="Reset" value="Reset" name="Reset"></TD></TR>
    </Form>
    </Table>
    
    <?php
    $link=mysql_connect("localhost","root");
    
    $db=mysql_select_db("patsmusic",$link);
    
    if(isset($_GET["name"]))
    {
    $sql="INSERT INTO allthemusic(album_id,name,band,sold,genre,country,year,order)VALUES('','".$_GET["name"]."','".$_GET["band"]."','".$_GET["sold"]."','".$_GET["genre"]."','".$_GET["country"]."','".$_GET["year"]."','".$_GET["order"]."')";
    
    $result=mysql_query($sql,$link);
    }
    ?>
    
    <TABLE BORDER="1">
    <TR><TD>name</TD><TD>sold</TD><TD>country</TD><TD>year</TD></TR>
    <?php
    
    $sql="SELECT*FROM allthemusic";
    $result=mysql_query($sql,$link);
    
    while($row=mysql_fetch_object($result))
    {
    print("<TR><TD>$row->name</TD><TD>$row->sold</TD><TD>$row->country</TD><TD>$row->year</TD></TR>\n");
    }
    ?>
    </TABLE>
    </BODY>
    </HTML>
    Last edited by gits; Oct 7 '10, 05:58 AM. Reason: added code tags
  • semanticnotion
    New Member
    • Sep 2010
    • 66

    #2
    check your connection where is the password field

    Comment

    • oranoos3000
      New Member
      • Jan 2009
      • 107

      #3
      hi
      instead of check $_GET you can check is clicked submit buttion
      if(button is not clicked) then show the form to the user
      else you must add new record to the below list

      best regards

      Comment

      Working...