Jump to content

ggw

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ggw's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you! I had done this previously and tested but the server must not of been updating Thanks everyone for their help
  2. Sorry it didn't say anything because my server has not been refreshing, I have added this code in so the variable is set $count=mysql_num_rows($result) It now says (when selecting 2 check boxes to delete); Array ( [0] => [1] => ) SQL: DELETE FROM contact WHERE del_id IN(, ) Array ( [0] => [1] => ) SQL: DELETE FROM contact WHERE del_id IN(, ) Array ( [0] => [1] => ) SQL: DELETE FROM contact WHERE del_id IN(, ) Array ( [0] => [1] => ) SQL: DELETE FROM contact WHERE del_id IN(, ) I think it would of said before if my server had been refreshing sorry
  3. Nothing is being deleted and nothing is printing out, it is just refreshing the page
  4. I have made the changes to the code and put the delete statements before the select and display however nothing has changed :-\
  5. I think they have been implemented correctly <form> <?php $result = mysql_query("SELECT * FROM contact ORDER BY msg_id ASC"); echo "<table border='1'> <tr> <th>Delete</th> <th>Message ID</th> <th>Name</th> <th>Email</th> <th>Message</th> </tr>"; while($row = mysql_fetch_array($result)) { ?> <td align="center" bgcolor="#FFFFFF"><input name="delete_these[]" type="checkbox" id="checkbox[]" value="<?php echo $row['del_id']; ?>"></td> <?php echo "<td>" . $row['msg_id'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['msg'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active, start this if(isset($_GET['delete'])) { for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $ids = implode(', ', $_GET['delete_these']); $sql = "DELETE FROM contact WHERE msg_id IN($ids)"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ } } mysql_close(); ?> </form>
  6. I have put it in form tags it is now refreshing the page once the delete button is clicked, however it is still not deleting the items selected. I have put that code in and it is still not working
  7. Hi, I am having difficulty deleting rows in my table using check boxes. I have all the check boxes displaying for each row and a delete button below the table. However when i click on the delete button it isnt deleting the checked rows, i have displayed the code below that i am using; <?php $result = mysql_query("SELECT * FROM contact ORDER BY msg_id ASC"); echo "<table border='1'> <tr> <th>Delete</th> <th>Message ID</th> <th>Name</th> <th>Email</th> <th>Message</th> </tr>"; while($row = mysql_fetch_array($result)) { ?> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['del_id']; ?>"></td> <?php echo "<td>" . $row['msg_id'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['msg'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active, start this if(isset($_GET['delete'])) { for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM contact WHERE id=".$_GET['del_id']; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ } } mysql_close(); ?> Please help Thank you
  8. ggw

    mysql error

    I have a new problem!! I have it editing all my items however on the form there is a drop down menu to select which category the item belongs to, I've just realised the category isn't changing when being edited. Can anyone help? The code I have for the category drop down box is : <label for="category_name">Category:</label> <?php $query=("SELECT category_id, category_name FROM category"); $result = mysql_query ($query); echo "<select id='category_name' name='category_name'>"; while($nt=mysql_fetch_array($result)){ echo "<option selected='selected' value=$nt[category_id]>$nt[category_name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> Any help would be much appreciated! Thanks!
  9. ggw

    mysql error

    I've done it guys!!!!!!! Thanks for all the help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  10. ggw

    mysql error

    Guys I have changed the code a bit and now this is the error I am getting: Click here to logout Array ( [name] => TEST EDITED [category_name] => 3 [description] => GGGGG [price] => 35 [item_id] => 90 [save] => Save ) edit value is true The file has been uploaded! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1: UPDATE item SET item_name = 'TEST EDITED', item_description = 'GGGGG', item_image = 'Koala.jpg', item_price = '35' WHERE item_id = In the array it has picked up the item_id that is being edited is 90. However in the UPDATE statement it is not finding the item_id. Can anyone help? Thanks!!
  11. ggw

    mysql error

    In ourworkadmin.php we have: <?php if(isset($_GET['remove'])) { header('Location: ../includes/item-delete.php?item_id='.$_GET['item_id']); } if(isset($_GET['edit'])) { header('Location: ../includes/item-edit.php?item_id='.$_GET['item_id']); } ?> item-edit.php the code is: <?php if (isset($_POST['edit'])){ print_r ($_POST); echo "<br /> edit value is true"; $name = $_POST['name']; $description = $_POST['description']; $price = $_POST['price']; $image = $_FILES['images']['name']; $category_id = $_POST['category_name']; $item_id = $_GET['item_id']; include('../includes/image-upload.php'); $query = ("UPDATE item SET item_name = '$name', item_description = '$description', item_image = '$image', item_price = '$price' WHERE item_id = ".$_GET['item_id']); mysql_query($query) or die(mysql_error().': '.$query); $item_id = mysql_insert_id(); echo "item edited: " .$_GET['item_id']; $query.= "UPDATE links SET item_id = $item_id, category_id = $category_id,"; header('Location: item-edit.php'); if(isset($_GET['item_id'])) { $result = mysql_query(" SELECT * FROM item WHERE item.item_id = " .$_GET['item_id']); $row = mysql_fetch_array($result); }} ?> And this is the form: <div id="mid-col"> <h2 id="homecol3"> <form action="item-edit.php" method="POST" enctype="multipart/form-data"> <div> <label for="name">Name:</label> <input id="name" name="name" type="text" value="<?php echo $itemname ?>" /> </div> <div> <label for="images">Image:</label> <input id="images" name="images" type="file" /> </div> <div> <label for="category_name">Category:</label> <?php $query=("SELECT category_id, category_name FROM category"); $result = mysql_query ($query); echo "<select id='category_name' name='category_name'>"; while($nt=mysql_fetch_array($result)){ echo "<option selected='selected' value=$nt[category_id]>$nt[category_name]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </div> <div> <label for="item_description">Description</label> <textarea id="description" name="description"><?php echo $row['item_description']; ?></textarea> </div> <div> <label for="item_price">Price:</label> <input id="price" name="price" type="text" value="<?php echo $row['item_price']; ?>" /> </div> <div> <input name="item_id" type="hidden" value="<?php echo $item_id; ?>" /> <input name="edit" value="Edit" type="submit" /> </div> </form> </h2> </div> Thanks!!
  12. ggw

    mysql error

    How do we get it so it knows the item_id? I am completely clueless as to why its not working. Thanks
  13. ggw

    mysql error

    I have added if (isset($_POST['save'])){ print_r ($_POST); This is what happens: Array ( [name] => test edited [category_name] => 3 [description] => test edited [price] => 28 [item_id] => [save] => Save ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1: UPDATE item SET item_name = 'test edited', item_description = 'test edited', item_image = 'Jellyfish.jpg', item_price = '28' WHERE item_id = Thanks
  14. ggw

    mysql error

    No the code isn't from a tutorial. I just thought that $item_id = $_POST['item_id']; this line of code would post the item_id.
  15. ggw

    mysql error

    I'm not too sure what you mean. I am just starting out in php :-\
×
×
  • 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.