SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    populating a form

    please i am developing an order form, the plan was that after each insert , another div echo's the data from the database, but i am finding it hard to update the quantity or delete a particular entry

    PHP Code:
    <?php
    $submit 
    $_POST['Add'];

    //form data
    $Sname strip_tags(htmlentities($_POST['Sname']));
    $Pname strip_tags(htmlentities($_POST['Pname']));
    $Pidno strip_tags(htmlentities($_POST['Pidno']));
    $Psize strip_tags(htmlentities($_POST['Psize']));
    $Pcolour strip_tags(htmlentities($_POST['Pcolour']));
    $Pquantity $_POST['Pquantity'];
    $Weblink strip_tags(htmlentities($_POST['Weblink']));
    $Price strip_tags(htmlentities($_POST['Price']));

    //echo " ('','$Sname','$Pname','$Pidno','$Psize','$Pcolour','$Pquantity','$Weblink','$Price')";

    if('POST' === $_SERVER['REQUEST_METHOD']) 

    {
    //open database
    $connect mysql_connect('localhost','xxxxxxxxx','xxxxxxxx') or die('error connecting: ' mysql_error());
    mysql_select_db('reachea2_registeringmembers')or die('error selecting db: ' mysql_error());//select database
    //check for pplac
        //if ($Sname&&$Pname)
    //{
    $queryreg mysql_query("

    INSERT INTO repplac VALUES ('','
    $Sname','$Pname','$Pidno','$Psize','$Pcolour','$Pquantity','$Weblink','$Price')

    "
    );

    //}

    }
    ?>
    HTML Code:
    </div>
    <form action='youraccount.php' method='Post' class='slistbar'>
    	<!--<div>
    	<label for='shoppinglist' class='fixedwidth'></label>
    	<textarea type='text' name='shoppinglist' id='username' cols='100' rows='15'></textarea>
    	</div> -->
    	
    	<div>
    	<label for='Sname' class='fixedwidth'>Shop name</label>
    	<input type='text' name='Sname' id='Sname'/>
    	</div>
    	<div>
    	<label for='Pname' class='fixedwidth'>Product name</label>
    	<input type='text' name='Pname' id='Pname'/>
    	</div>
    	<div>
    	<label for='Pidno' class='fixedwidth'>Product id no</label>
    	<input type='text' name='Pidno' id='Pidno'/>
    	</div>
    	<div>
    	<label for='Psize' class='fixedwidth'>Product size</label>
    	<input type='text' name='Psize' id='Psize'/>
    	</div>
    	<div>
    	<label for='Pcolour' class='fixedwidth'>Product colour</label>
    	<input type='text' name='Pcolour' id='Pcolour'/>
    	</div>
    	<div>
    	<label for='Pquantity' class='fixedwidth'>Product quantity</label>
    	<select name="Pquantity" id="Pquantity">
    	  <option value="1">1</option>
      	  <option value="2">2</option>
      	  <option value="3">3</option>
      	  <option value="4">4</option>
      	  <option value="5">5</option>
      	  <option value="6">6</option>
      	  <option value="7">7</option>
      	  <option value="8">8</option>
      	  <option value="9">9</option>
      	  <option value="10">10</option> 
    </select>
    	</div>
    	<div>
    	<label for='Weblink' class='fixedwidth'>Web link</label>
    	<input type='text' name='Weblink' id='Weblink'/>
    	</div>
    	<div>
    	<label for='Price' class='fixedwidth'>Price GBP</label>
    	<input type='text' name='Price' id='Price'/>
    	</div>
    	<div class='buttonarea'>
    			<p>
    			<input type='submit' name='submit' value='Add'>
    			</p>
    			</div>
    			</p>
    	</form>
    </div>
    </div>
    <div class="action-box rounded">
    <div class="titlebar">
    <h2>bookmarks</h2>
    </div>
    <div class="listbar">
    PHP Code:
    <?


    $connect 
    mysql_connect('localhost','xxxxxxx','xxxxxxxxx') or die('error connecting: ' mysql_error());
    mysql_select_db('reachea2_registeringmembers')or die('error selecting db: ' mysql_error());

    $pplresult mysql_query("SELECT * FROM repplac");
    //table starting tag and header cells sitehttp://www.codingmix.com/2010/10/display-data-from-mysql-table-using-php.html
    echo "<table border='1'><tr><th> SHOP NAME</th><th> PRODUCT NAME</th><th> PRODUCT SIZE</th><th> PRODUCT COLOUR</th><th> PRODUCT QUANTITY</th><th> PRICE</th><th> </th></tr>";
    while(
    $row mysql_fetch_assoc($pplresult)){
    echo 
    "<tr><td>" .$row['Sname'] ."</td><td>" .$row['Pname'] ."</td><td>" .$row['Psize'] ."</td><td>" .$row['Pcolour'] ."</td><td>" .$row['Pquantity'] ."</td><td>" .$row['Price'] ."</td><td>" ?>
    <h3><a href="deleteproduct.php">delete</a></h3></td></tr><?php }
    // table closing tag
    echo"</table>"
    ?>
    so , i am thinking instead of echoing the result, i should pre populate a form, where some field will be editable like quantity update, and delete, while other fields will not be editable.please can you put me through this.thanks

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I don't see any logic (code) where you query the database, make sure Pquantity is not larger than the stock (current inventory), and subtract Pquantity from the stock.
    Ryan B | My Blog | Twitter

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This order form is not for the store .but is to. buy goods on customers request.so no stock


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •