php - update form not populating from existing data in mysql database -
hi im trying populate update form existing info mysql database can modify info , save mysql database. working , no errors not populating @ all. in advance
index.php
<?php require('includes/mysqli_connect.php'); $query = "select * item"; $result = mysqli_query($dbc, $query); while($items = mysqli_fetch_array($result)) { echo "<h3>" . $items['item_id'] . "</h3>"; echo "<p>" . $items['title'] . "</p>"; echo "<a href=\"modify.php?id=" . $items['item_id'] . "\">modify item</a>"; echo "<span> </span>"; echo "<span> </span>"; echo "<a href=\"delete.php?id=" . $items['item_id'] . "\">delete item</a>"; } ?>
modify.php
<?php require('includes/mysqli_connect.php'); if(!isset($_post['submit'])) { include('includes/mysqli_connect.php'); $q = "select * item item_id = '$_get[item_id]'"; $result = mysqli_query($dbc, $q); $items = mysqli_fetch_array($result) /* or die("error: ".mysqli_error($dbc)) */; } ?> <h1>modify item</h1> <form action="<?php echo $_server['php_self']; ?>" method="post"> <h4>selling format:</h4> <h4>auction: <input type="checkbox" value="<?php echo $items['auction']; ?>" name="inputauction"></h4> <h4>buy now: <input type="checkbox" value="<?php echo $items['buynow']; ?>" name="inputbuynow"></h4> <h4>select category:</h4> <select name="cat_id"> <?php include('includes/mysqli_connect.php'); $q = "select cat_id, cat_name category ". "order cat_id"; $r = mysqli_query($dbc,$q); while($row = mysqli_fetch_array($r)) { echo "<option value=\"".$row['cat_id']."\">".$row['cat_name']."</option>\n "; } ?> </select> <h4>title: <input type="text" size="30" maxlength="30" value="<?php echo $items['title']; ?>" name="inputtitle"></h4> <h4>description:</h4> <textarea rows="7" cols="27" value="<?php echo $items['description']; ?>" name="inputdescription" wrap="physical"></textarea> <p><a href="#" onclick="window.open('uploadwin.php', 'newwindow', 'width=200, height=150'); homecoming false;"> <h4>click here upload picture</h4></a></p> <h4>auction start price: <input type="text" size="15" maxlength="15" value="<?php echo $items['auct_price']; ?>" name="inputauct_price"></h4> <h4>buynow price: <input type="text" size="15" maxlength="15" value="<?php echo $items['buynow_price']; ?>" name="inputbuynow_price"></h4> <h4>duration: <select name="inputduration"> <option value="<?php echo $items['1 day']; ?>">1 day</option> <option value="<?php echo $items['3 days']; ?>">3 days</option> <option value="<?php echo $items['5 days']; ?>">5 days</option> </select></h4> <h4>quantity: <input type="text" size="15" maxlength="15" value="<?php echo $items['qty']; ?>" name="inputqty"></h4> <h4>item location: <input type="text" size="15" maxlength="15" value="<?php echo $items['item_location']; ?>" name="inputitem_location"></h4> <h4>accepted payment:</h4> <h4>paypal: <input type="checkbox" value="<?php echo $items['paypal']; ?>" name="inputpaypal"></h4> <h4>eft: <input type="checkbox" value="<?php echo $items['eft']; ?>" name="inputeft"></h4> <h4>postage:</h4> <h4>pickup: <input type="checkbox" value="<?php echo $items['pickup']; ?>" name="inputpickup"></h4> <h4>post interstate: <input type="checkbox" value="<?php echo $items['post_nationally']; ?>" name="inputpost_nationally"></h4> <h4>post national: <input type="checkbox" value=" <?php echo $items['post_internation']; ?>" name="inputpost_internation"></h4> <h4>post internation: <input type="checkbox" value="<?php echo $items['buyerpay_post']; ?>" name="inputbuyerpay_post"></h4> <input type="hidden" name="item_id" value="<?php echo $_get['item_id']; ?>" /> <input type="submit" value="modify" name="submit"> </form><br><br> <?php if(isset($_post['submit'])) { $u = "update `icadbs504a`.`item` set `auct_price` = '$_post[inputauct_price]', `buynow_price` ='$_post[inputbuynow_price]', `title` = '$_post[inputtitle]', `description` = '$_post[inputdescription]', `qty` = '$_post[inputqty]', `img_path` = '$imgpath', `item_location` = '$_post[inputitem_location]', `auction` = '$_post[inputauction]', `buynow` = '$_post[inputbuynow]', `duration` = '$_post[inputduration]', `pickup` = '$_post[inputpickup]', `post_nationally` = '$_post[inputpost_nationally]', `post_internation` = '$_post[inputpost_internation]', `buyerpay_post` = '$_post[inputbuyerpay_post]', `cat_id` = '$cat', `paypal` = '$_post[inputpaypal]', `eft` = '$_post[inputeft]' `item_id` = $_post[item_id]"; mysqli_query($u) or die(mysqli_error()); echo "item has been modified!"; header("location: index.php"); } include('includes/footer.html'); ?>
php mysqli
No comments:
Post a Comment