Jump to content

Thunder_Wolf

Members
  • Posts

    28
  • Joined

  • Last visited

Thunder_Wolf's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you very much that looks like its working like l need it to, would you suggest any other tutorials and web pages that will increase my knowledge? I still plan on reading through a few more php web pages. so any suggestions are always welcome and thank you again. that answer was very simple. I will be checking out tiig as well
  2. Hello, I have started a DB for simple web based inventory system, I have only dabbled in PHP before 6 weeks ago, within the last 6 weeks with some help and going through countless tutorials and asking questions when I need. At this time setup an insert, delete and update function for this db and are working perfectly, now what I need to know is there a way to display something like 'in stock' and 'out of stock' using php, based on the value of the quantity in my db next to the item in a table? Example : when the table is generated it will display: | Part number | Description | Stock | (normally Stock would show the quantity of each part, I just wish to |10-1111 | Some info | In Stock | display In or out os stock) |10-1112 | Some Info | Out of Stock | I the only code I have is the tables and just not sure what to do next to get the results I have described above. So I will include the table code I have and see where we can go from there. Or if you have some webs site that I can read through that will be great as well as long as it can give me basic instruction on how to do this. Reminder, I am self taught and still learning. <?php $con = mysqli_connect("localhost","user","pass","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20"); echo "<table border='1'> <tr> <th>ID</th> <th>Part number</th> <th>description</th> <th>location</th> <th>Quantity</th> </tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['amp20ptid'] . "</td>"; echo "<td>" . $row['partnum'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $row['location'] . "</td>"; echo "<td>" . $row['quantity'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); } ?>
  3. Nope it was a typo, but thanks for catch it. Same times I rush and i need to tell my self to slow down. I have change to using the echo thank you again
  4. Yeah, my grammar is not the best, I live with someone that can correct it for me if I make a mistake, she calls her self a "spelling and grammar nazi". what would you suggest to replace the printf? and i did correct the grammar issue, thanks for pointed that out.
  5. I did look at it again and completed WHERE claues, which didnt make a difference and also took out the query completely, which also didnt make a difference. And either way it didnt post any errors. As for the semi-colon, it was an extra and it did fixs the end result of the code, I totally missed it. I do appreciate your help. here is the end code and as i have stated its working as it should. <?php $con = mysqli_connect("localhost","scottk","ct@1446SA","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); //delete Entry from db $sql = ("DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $sql)) { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?>
  6. I just seen where I was to do the code foramting apologize, ok here is the working codes all is deleting and as you can see the ';' was removed and all is working as it should. Also i did find the code format button, again I do apologize and i did try to edit the post before you replyed states I didnt use code formate but I was to late. <?php $con = mysqli_connect("localhost","scottk","ct@1446SA","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT FROM amp20 WHERE amp20ptid"); // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); //delete Entry from db $sql = ("DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $sql)) { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?>
  7. Here is the working code. <?php $con = mysqli_connect("localhost","user","password","part_inventory"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT FROM amp20 WHERE amp20ptid"); // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); //delete Entry from db $sql = ("DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $sql)); //{ // die('Could not delete data: ' . mysqli_error($con)); //} echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?>
  8. To answer youe list, 1 yes it does work or i would be getting an error unable to connect 2 i have changed the code to $result = mysqli_query($con, "SELECT FROM amp20 WHERE amp20ptid"); instead of $result = mysqli_query($con, "SELECT * FROM amp20 "); made no difference. 3- that is correct 4 - i see what your saying i have changes mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); to $sql = ("DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); which still deletes entry in DB either way but the error has gone, it now states that the entry was not removed, but it is gone from the DB 5- if you are talking about $amp20ptid = $_POST['amp20ptid']; i have removed it completely and still still removed the entry What this is for is deleteing a row from the db, not with all this changes, it states that the entry was not deleted but the row is gone from the db has intended. Also if i remove the: { die('Could not delete data: ' . mysqli_error($con)); } it continues to the : echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } and the row is gone as well so i dont know
  9. Ok this is puzzleing. I am geting "Could not delete data: 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 '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being. <?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?>
  10. I have 2 issues happening, first one I need to get resolved is, line 60 is giving me a 'Notice: Undefined variable: delete'. This codes had multi issues but was able to resolve all but this one and my table not filling in with the data from my database. If you need any other info please let me know, Again I am new at this. <tr> <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 *line 60* -----> if ($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysqli_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysqli_close($con); ?>
  11. Sorry for admitting a mistake is practicing deceit, its fixed now can we please move on
  12. Ok yeah i know what I did, I coped and paste from an old file, this is what should have been pasted: "die('Could not enter data: ' . mysqli_error($con));" is what should have been pasted and because it looks like i had the mix of mysql and mysqli. but i am just glad its fixed none the less, and yes that is very possible when i was coding i could have missed the "i"
  13. I just got it fixed: Old code - die('Could not enter data: ' . mysql_error()); new code - die('Could not enter data: ' . mysql_error($con)); then change : old code - $sql = "INSERT INTO 'part_inventory' . 'amp_20' ('amp20ptid', 'partnum', 'description', 'location', 'quantity') to new code - $sql = "INSERT INTO amp20 (amp20ptid, partnum, description, location, quantity) i was able to put 2 new entries in to my data base.
×
×
  • 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.