Jump to content

jwwceo

Members
  • Posts

    212
  • Joined

  • Last visited

Posts posted by jwwceo

  1. I'm trying to make a page to update or delete a shirt from a database. I am passing the shirt_id in through a URL link and using GET. I used the exact same GET code on another page and it worked fine.  Can anyone see anything wrong with this... I am getting this error

    Undefined index: shirt_id in E:\ProgramFiles\Apache\htdocs\ShirtSite\edit.php on line 15

    Thanks in advance!!!!

    <?php

    include 'library/config.php';
    include 'library/opendb.php';

    $shirt_id = $_GET['shirt_id'];  [b]//LINE 15[/b]

    if(isset($_POST['delete'])) {

    $query = "DELETE FROM shirts WHERE shirt_id='$shirt_id'";
    $delete = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
        echo "Your shirt has been deleted!";

    }



    else if(isset($_POST['submit'])) {

      $name=$_POST['name'];
      $comment=$_POST['comment'];
      $link=$_POST['link'];
      $site=$_POST['site'];
      $image=$_POST['image'];
      $active=$_POST['active'];
      $commission=$_POST['commission'];

      $query="UPDATE shirts SET name='$name', comment='$comment', link='$link', site ='$site',
      image ='$image', active ='$active', commission ='$commission' WHERE shirt_id ='$shirt_id'";

      $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
        echo "Your shirt has been updated!";


    } else

    {


    $data = mysql_query("SELECT * FROM shirts WHERE shirt_id ='$shirt_id'") or die(mysql_error());
    $info = mysql_fetch_array( $data );

    echo "<a href='admin.php'><img src='images/logo.gif' border='0'></a><br>
    <form method='post' action='edit.php'>
    <TABLE>
    <TR>
      <TD>Name:</TD>
      <TD><INPUT TYPE='TEXT' NAME='name'  size=50 value='".$info['name']."'></TD>
    </TR>
    <TR>
      <TD>Comment</TD>
      <TD><textarea rows='5' cols='50' name='comment'>".$info['comment']."</textarea>
    </TD>
    </TR>
    <TR>
      <TD>Link</TD>
      <TD><INPUT TYPE='TEXT' NAME='link'  size=50 value='".$info['link']."'></TD>
    </TR>
    <TR>
      <TD>Site</TD>
      <TD><INPUT TYPE='TEXT' NAME='site'  size=50 value='".$info['site']."'></TD>
    </TR>
    <TR>
      <TD>Image</TD>
      <TD><INPUT TYPE='TEXT' NAME='image'  size=50 value='".$info['image']."'></TD>
    </TR>
    <TR>
      <TD>Active</TD>";

    if($info['image'] == 'true') {


    echo

      "<TD><input type='radio' name='active' value='true' CHECKED> Active
    <br>
    <input type='radio' name='active' value='false'> Inactive
      </TD>";

      }


      else {

      echo "<TD><input type='radio' name='active' value='true' > Active
    <br>
    <input type='radio' name='active' value='false' CHECKED> Inactive
      </TD>";

      }

    echo

    "</TR>
    <TR>
      <TD>Commission</TD>
      <TD><INPUT TYPE='TEXT' NAME='commission' size=50 value='".$info['commission']."'></TD>
    </TR>
    <TR>
      <TD></TD>

      <TD><INPUT TYPE='submit' name='submit' value='Edit this Tee'>
          <INPUT TYPE='submit' name='delete' value=' Delete this Tee'></TD>
    </TR>

    </TABLE>
    </form>";


    }
    ?>

    </body>
    </html>

  2. Hello,

    I am designing a database, my first one, for a t-shirt website. I have tables for the individual t-shirts, as well as a linked table for all the colors the shirts come in. They share a "color_id" field that is in both tables.

    My question is: what do I do if some of the shirts come in more than one color?  How can I design a databse that allows for shirts to have multiple options from the same table???

    Any help would be awesome...

    James
  3. I am looking for a tutorial on building a product gallery where products are diplayed in a grid format, like this [url=http://www.bustedtees.com]www.bustedtees.com[/url]. I mostly need to know how to get the search results to display 4 across. Right now, I can just get them to make a big list, where each entry is a row in a table....

    Are there any tutorials on this online anywhere..or anyone have any tips on how to do this....
  4. I have a very basic question. Below is a simple snippet to retrieve info from a database. I tweaked it to work with my fields and it works fine. My question is...why is $info not declared at the start of the script. Don't I have to declare all my variables??

    Also is there any command that doesn't require echo to go on every line that's outputted...but rather just outputs everything between a start and end "print" command??
    _________________________
    <?php
    // Connects to your Database

    include 'library/config.php';
    include 'library/opendb.php';

    $data = mysql_query("SELECT * FROM shirts") or die(mysql_error());

    echo "<table border cellpadding=3>";
    while($info = mysql_fetch_array( $data ))
    {
    echo "<tr>";
    echo "<th>Name</th> <td>".$info['name']."</td> ";
    echo "<th>Web Site</th> <td>".$info['site']." </td>";
    echo "<th>Comment</th> <td>".$info['comment'] . "</td> ";
    echo "<th>Link</th> <td>".$info['link']."</td>";
    echo "<th>Image</th> <td>".$info['image']."</td> ";
    echo "<th>Commission</th> <td>".$info['commission']." </td>";
    echo "<th>Active</th> <td>".$info['active']."</td></tr>";

    }
    echo "</table>";
    ?>
  5. That was probably it...

    The page would load but when you submitted the form..nothing happened...it simply cleared the data, like a reload....

    Is there any place to check error logs so I can see if there is a syntax error on line X??? I have error logs on Apache..and the browser will display the MySQL error if I have the tags set up right...but I can't find a place to find error logs for the PHP itself...

  6. Hey all..

    I am trying to write my first PHP file that will write to a database, MySQL. I just can't get this to work. I've been playing with this for hours...any obvious things wrong with this code...thanks in advance...

    <html>
    <head>
    <title>Add A Shirt</title>
    </head>
    <body bgcolor="#FFFFFF">

    <?
    if($_POST['submit'])
    {

      mysql_connect("localhost","root","9579");
      mysql_select_db("tees");

      $shirt_id=$_POST['shirt_id'];
      $name=$_POST['name'];
      $comment=$_POST['comment'];
      $link=$_POST['link'];
      $site=$_POST['site'];
      $image=$_POST['image'];
      $active=$_POST['active'];
      $commission=$_POST['commission'];

      $result="INSERT INTO shirts (shirt_id,name,comment,link,site,image,active,commission)  VALUES ('NULL', '$name', '$comment', '$link', '$site', '$image', '$active', '$commission' )";

      mysql_query($result);
      echo "Thanks for adding the tee";

      ?>


    <?
    else
    {

    ?>



    <form method="post" action="add.php">
    <TABLE>
    <TR>
      <TD>Name:</TD>
      <TD><INPUT TYPE='TEXT' NAME='name'  size=100></TD>
    </TR>
    <TR>
      <TD>Comment</TD>
      <TD><INPUT TYPE='TEXT' NAME='comment'  size=100></TD>
    </TR>
    <TR>
      <TD>Link</TD>
      <TD><INPUT TYPE='TEXT' NAME='link'  size=100></TD>
    </TR>
    <TR>
      <TD>Site</TD>
      <TD><INPUT TYPE='TEXT' NAME='site'  size=100></TD>
    </TR>
    <TR>
      <TD>Image</TD>
      <TD><INPUT TYPE='TEXT' NAME='image'  size=100></TD>
    </TR>
    <TR>
      <TD>Active</TD>
      <TD><INPUT TYPE='TEXT' NAME='active'  size=100></TD>
    </TR>
    <TR>
      <TD>Commission</TD>
      <TD><INPUT TYPE='TEXT' NAME='commission' size=100></TD>
    </TR>
    <TR>
      <TD></TD><br>
      <TD><INPUT TYPE="submit" name="submit" value="Add this Tee"></TD>
    </TR>
    </TABLE>
    </form>

    <?
    }
    ?>


    </body>
    </html>
×
×
  • 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.