Jump to content

bambinou1980

Members
  • Posts

    130
  • Joined

  • Last visited

Everything posted by bambinou1980

  1. Sorry here is the updated code: <?php //Query all the prices $query_field2 = "SELECT * FROM products ORDER BY name desc"; $result_field2 = mysqli_query($connection, $query_field2) or die (mysqli_error()); $number1 = 0; $number2 = 0; $number3 = 0; $id_1 = 0; $id_2 = 1; $id_3 = 2; while($row_field2 = mysqli_fetch_array($result_field2)){ $name = htmlspecialchars($row_field2['name']); $price1 = htmlspecialchars($row_field2['price1']); $price2 = htmlspecialchars($row_field2['price2']); $price3 = htmlspecialchars($row_field2['price3']); ?> <div class="form-inline well"> <label for="product1_id">Choose Product <?php echo ++$number1; ?></label> <div class="form-group"> <input name="<?php echo "product".++$number2; ?>" type="text" class="form-control" value="<?php echo $name; ?>" disabled> <!--Price 1--> <label class="btn btn-default"> <input type="radio" name="<?php echo "action".++$number3; ?>" value="<?php echo $price1;?>" id="<?php ++$id_1; ?>" /> €<?php echo $price1;?> </label> <!--Price 1--> <!--Price 2--> <?php //Do not show second price if not set if(($price2) != null) { echo "<label class=\"btn btn-default\"> <input type=\"radio\" name=\"action{$number3}\" value=\"{$price2}\" id=\"{$id_2}\" /> € {$price2} </label>"; } ?> <!--Price 2--> <!--Price 3--> <?php //Do not show third price if not set if(($price3) != null) { echo "<label class=\"btn btn-default\"> <input type=\"radio\" name=\"action{$number3}\" value=\"{$price3}\" id=\"{$id_3}\"/> € {$price3} </label>"; } ?> <!--Price 3-->
  2. Yes for the radio buttons it is deliverate. Imagine form fields with 3 possible choices per line, as I did it above each inpout field will have 1 choice as the action will be identical to all 3 radio buttons. This is why I increase ++$number3; the first action then add it as $number3 in the next 2 radio buttons so the action name id increases of 1 each time but is also cpied to the next radio buttons. as: <?php //Query all the prices $query_field2 = "SELECT * FROM products ORDER BY name desc"; $result_field2 = mysqli_query($connection, $query_field2) or die (mysqli_error()); $number1 = 0; $number2 = 0; $number3 = 0; $id_1 = 0; $id_2 = 1; $id_3 = 2; while($row_field2 = mysqli_fetch_array($result_field2)){ $name = htmlspecialchars($row_field2['name']); $price1 = htmlspecialchars($row_field2['price1']); $price2 = htmlspecialchars($row_field2['price2']); $price3 = htmlspecialchars($row_field2['price3']); ?> <!--Price 1--> <label class="btn btn-default"> <input type="radio" name="<?php echo "action".++$number3; ?>" value="<?php echo $price1;?>" id="<?php ++$id_1; ?>" /> €<?php echo $price1;?> </label> <!--Price 1--> <!--Price 2--> <?php //Do not show second price if not set if(($price2) != null) { echo "<label class=\"btn btn-default\"> <input type=\"radio\" name=\"action{$number3}\" value=\"{$price2}\" id=\"{$id_2}\" /> € {$price2} </label>"; } ?> <!--Price 2--> <!--Price 3--> <?php //Do not show third price if not set if(($price3) != null) { echo "<label class=\"btn btn-default\"> <input type=\"radio\" name=\"action{$number3}\" value=\"{$price3}\" id=\"{$id_3}\"/> € {$price3} </label>";} ?> <!--Price 3--> Yes I know about your solutions but I did find Barand solutions a little bit too hard to implement for me, I am still a bit confused about relational database. So I thought about doing it this way: I created a form where I can add product name and 3 prices and add as manay product names as I want. In the form above, I loop through this and have 1 input field per product which shows the 3 prices for each product name. When this "add an order" form is filled up, the output is recorded is a new table called "orders". Now if I want to retrieve the orders per customer, I can simply use a mysql short mysql query. The only problem with this way of doing this is that I might now know how much of each product I have sold each month.....unless I send the output data of the form to a second table each time I pass a command, but if the command is deleted, the values in that new table will stay there. Where I did not understand Barand and yourself is to why use relational database in this case if I can still show all the orders into a table without it, if you could explain this a little further it would be great please. As All I want is 1 admin that can add an order or list all the orders for each customer(which can be done without relational database), then have the orders of the day shown to only 1 other user(semi admin). The customers themselves will not access the database as it is internal to a small factory. So instead I thought about doing it in an easier way by increase the first variables of ++ for price one and repeating it for price 2 and 3 for each line(which works) when I have this type of code: <input type="radio" name="<?php echo "action".++$number3; ?>" value="<?php echo $price1;?>" id="<?php ++$id_1; ?>" /> €<?php echo $price1;?> But all I wanted to try is why I cannot add my ++ in an echo(Remember this is just as a trial as I am trying to understand more of php): echo "<label class=\"btn btn-default\"> <input type=\"radio\" name=\"action{++$number}\" value=\"{$price2}\" id=\"{$id_2}\" /> € {$price2} </label>"; So quickly, in one case ++$variable works but in the other case {++$variable} does not work, I find it weird.....as the second solution should work also no?
  3. Yes sorry about the drodown menu, this should be a simple input field greyed out so the user cannot change it's value. The reason this was there is because I just copied and pasted the first line of code, I was going to change this later on.
  4. Hello, I am having a strange problem, I have one line of code that shows a variable this way: <input type="radio" name="<?php echo "action".++$number3; ?>" value="<?php echo $price1;?>" id="<?php ++$id_1; ?>" /> €<?php echo $price1;?> As you can see I have added increment of 1 to 2 variables. Below it I would like to echo another line as: <input type=\"radio\" name=\"action{++$number3}\" value=\"{++$price2}\" id=\"{$id_2}\" /> € {++$price2} I was expecting this to work in php but it is causing a page error "Blank page" each time I add the ++ on a variable inside the echo statement. Could someone explain to me why this is not allowed in PHP please? What are the other possibilities? Thank you, Ben
  5. Hello all, I have a form that required a time picker, with a bit of searching I found something called Moment.js and boostrap 3 timepicker from here: https://eonasdan.github.io/bootstrap-datetimepicker/Installing/ I have installed all the dependencies via bower and everything is in place, the time picker is also showing. Where I am confused: 1)How to keep the value of the timepicker and set it as "value" in this field: <div class="form-group"> <div class='input-group date' id='datetimepicker1'> <input type='text' class="form-control" value="" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> <script type="text/javascript"> $(function () { $('#datetimepicker1').datetimepicker(); }); </script> The time picker is showing: MM/DD/YYYY but I need it: DD/MM/YYYY Could you please give me a quick example on how to play with this time picker? I just need to record the data and send it to mysql. Thank you! Ben
  6. Thanks Barand I have unfortunately changed the way my script worked as I did not receive any email notifications of your reply :-( I have opened another thread regarding the new logic I will use. Thanks again for your hard work! Ben
  7. Hi All, I am still on the learning curbe with PHP, I have created a form that generated fields based on the number of products in the database. My problem now is to work out how to submit the $_POST data of each dynimically generated fields, I just cannot work out how I will manage to find the fields "name" in advance as the form data can grow from one product up to let's say 10. Could you please give me some hints on the type of logic I should use as I really do not know(due to my beginner level) where to start on dynimically generated fields. Thank you! Ben <form role="form" method="post" action="index.php"> <div class="form-group"> <label for="name_id"> Customer Name * </label> <input type="text" name="customer_name" placeholder="Customer Name" class="form-control" id="name_id"/> </div> <div class="form-group"> <label for="due_date_id"> Due Date * </label> <input type="text" name="due_date" placeholder="" class="form-control" id="duedate_id"/> </div> <!--Product 1--> <?php $query_field1 = "SELECT * FROM products ORDER BY name desc"; $result_field1 = mysqli_query($connection, $query_field1) or die (mysqli_error()); $number = 0; while($row_field1 = mysqli_fetch_array($result_field1)){ $name = $row_field1['name']; $price1 = $row_field1['price1']; $price2 = $row_field1['price2']; $price3 = $row_field1['price3']; ?> <div class="form-inline well"> <label for="product1_id">Choose Product <?php echo ++$number; ?></label> <div class="form-group"> <select name="product1" id="product1" class="form-control"> <option value="<?php echo $name; ?>" /><?php echo $name; ?></option>"; </select> <label class="btn btn-default"> <input type="radio" id="price1_id" name="action" value="<?php echo $price1;?>" /> €<?php echo $price1;?> </label> <?php if(($price2) != null) { echo "<label class='btn btn-default'> <input type='radio' id='price2_id' name='action' value='{$price2}'/> € {$price2} </label>"; } ?> <?php if(($price3) != null) { echo "<label class='btn btn-default'> <input type='radio' id='price3_id' name='action' value='{$price3}'/> € {$price3} </label>"; } ?> <label for="product1_id">Qty</label> <input name="quantity1" id="quantity1" type="text" class="form-control" maxlength="4" size="4"><!--disabled="disabled"--> </div> </div> <?php } ?> <div class="form-group"> <label for="address_id"> Address * </label> <textarea type="text" name="address" placeholder="Company's Address" rows="4" cols="50" class="form-control" id="address_id" value=""></textarea> </div> <div class="form-group"> <label for="phone_id"> Phone </label> <input type="text" name="phone" placeholder="Customer Phone" class="form-control" id="phone_id" value="" /> </div> <div class="form-group"> <label for="email_id"> Email </label> <input type="email" name="email" placeholder="Customer Email" class="form-control" id="email_id" value="" /> </div> <div class="form-group"> <label for="vat_id"> V.A.T Number(ie:MT20343324) </label> <input type="text" name="vat" placeholder="V.A.T Number" class="form-control" id="vat_id" value="" /> </div> <button type="submit" name="submit" class="btn btn-default"> Create Order </button> </div> </form>
  8. I have found this little pieve of code that seems to work pretty well with Jqeury to add new fields, my problem is, how to add my html and php code without breaking the js code? I tired to put them together but it failed: <script> $(document).ready(function() { var max_fields = 10; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); //Fields wrapper var add_button = $(".add_field_button"); //Add button ID var x = 1; //initlal text box count $(add_button).click(function(e){ //on add input button click e.preventDefault(); if(x < max_fields){ //max input box allowed x++; //text box increment $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box } }); $(wrapper).on("click",".remove_field", function(e){ //user click on remove text e.preventDefault(); $(this).parent('div').remove(); x--; }) }); </script> <div class="input_fields_wrap"> <button class="add_field_button">Add More Fields</button> <div><input type="text" name="mytext[]"></div> </div>
  9. Thanks iarp, wow, I will have to check this out, All I have at the moment is this: <form role="form" method="post" action="index.php"> <div class="form-group"> <label for="name_id"> Customer Name * </label> <input type="text" name="customer_name" placeholder="Customer Name" class="form-control" id="name_id" required/> </div> <div class="form-group"> <label for="due_date_id"> Due Date * </label> <input type="text" name="due_date" placeholder="" class="form-control" id="duedate_id" required/> </div> <!--Product 1--> <?php $query2 = "SELECT name, price1, price2, price3 FROM products ORDER BY name desc"; $result2 = mysqli_query($connection, $query2) or die (mysqli_error()); while($row = mysqli_fetch_array($result2)){ ?> <div class="form-inline well"> <label for="product1_id">Choose Product 1 *</label> <div class="form-group"> <select name="product1" id="product1" class="form-control"> <option value="<?php echo $row['name'];?>"><?php echo $row['name'];?></option> </select> <label class="btn btn-default"> <input type="radio" id="price1_id" name="action" value="<?php echo $row['price1'];?>" /> €<?php echo $row['price1'];?> </label> <?php if(($row['price2']) != null) { echo "<label class='btn btn-default'> <input type='radio' id='price2_id' name='action' value='{$row['price2']}'/> € {$row['price2']} </label>"; } ?> <?php if(($row['price3']) != null) { echo "<label class='btn btn-default'> <input type='radio' id='price3_id' name='action' value='{$row['price3']}'/> € {$row['price3']} </label>"; } ?> <label for="product1_id">Qty</label> <input name="quantity1" id="quantity1" type="text" class="form-control" maxlength="4" size="4"><!--disabled="disabled"--> </div> </div> <!--Product 1--> <?php } ?> <div class="form-group"> <label for="address_id"> Address * </label> <textarea type="text" name="address" placeholder="Company's Address" rows="4" cols="50" class="form-control" id="address_id" value="" required></textarea> </div> <div class="form-group"> <label for="phone_id"> Phone </label> <input type="text" name="phone" placeholder="Customer Phone" class="form-control" id="phone_id" value="" /> </div> <div class="form-group"> <label for="email_id"> Email </label> <input type="email" name="email" placeholder="Customer Email" class="form-control" id="email_id" value="" /> </div> <div class="form-group"> <label for="vat_id"> V.A.T Number(ie:MT20343324) </label> <input type="text" name="vat" placeholder="V.A.T Number" class="form-control" id="vat_id" value="" /> </div> <button type="submit" name="submit" class="btn btn-default"> Creat Order </button> </div> </form> o this be done in Jqeury? I have a mistake in my code by the way, at the moment the while loop is adding the same number of horizontal dropdown menu than ids for the product which is wrong, this is why having a "add" field button would have been much better.
  10. Hi Barand, Yes you are right,( I had to blurr the product names because those are my friends products). I have attached a pic here: As you can see, I have created a table with 5 fields, table called "products" with product_id, product_name, price1, price2, price3 and quantity. When the person in front of the pc passes an order from his desk, he will choose a due date,choose the customer name from the dropdown that should populate automatically the 3 prices radio buttons(from the products table), he will then input a quantity and click send. This data will then go to a new table called "Orders" this way I keep everything statically in one table where I will then be able to pull statistics in the future. What I wanted first was a (add) button to add a new line for the order each time but I checked it online and did find the logic quiet complicated for me so for now I was thinking about having 5 static dropdown fields. Regarding calender, what plugin would you suggest please? Something easy/simple to use. I am thinking about taking jquery courses online because I have not palyed much with it. Thank you so much as always:-)
  11. Hello, I am really struggling with this..... I have a Mysql table called "Products" with the fields: id name price1 price2 price3 Each product as you can see has 3 prices. What I am trying to achieve is this horizontally in the form Dropdown1[name], Radial button 1[price1], radial button 2[price2], radial button 3[price3], quantity_field I would like to have the radial buttons to populate the right prices of the product selected from the dropdown menu, I am completely mixed up here..... From what I understand I cannot achieve this with php alone but PHP and jqeury, would anyone knows how please? Here is my current code: <?php $query2 = "SELECT name, price1, price2, price3 FROM products ORDER BY name desc LIMIT 3"; $result2 = mysqli_query($connection, $query2); while($row = mysqli_fetch_assoc($result2)){ ?> <!--Product 1--> <div class="form-inline well"> <label for="product1_id">Choose Product 1 *</label> <div class="form-group"> <select name="product1" id="product1" class="form-control"> <option value="<?php echo $row['name'];?>"><?php echo $row['name'];?></option> </select> <label class="btn btn-default"> <input type="radio" id="price1_id" name="price1" value="4" value="<?php echo $row['price1'];?>" /> €<?php echo $row['price1'];?> </label> <label class="btn btn-default"> <input type="radio" id="price2_id" name="price2" value="4" value="<?php echo $row['price2'];?>"/> €<?php echo $row['price2'];?> </label> <label class="btn btn-default"> <input type="radio" id="price3_id" name="price3" value="4" value="<?php echo $row['price3'];?>"/> €<?php echo $row['price3'];?> </label> <input name="quantity1" id="quantity1" type="text" class="form-control" maxlength="4" size="4"><!--disabled="disabled"--> </div> </div> <!--Product 1--> <?php } ?> Also my other problem is that I am actually not just populating the dropdown menus but also multiplying the whole dropdown html components which is wrong. What is the best method to have let's say 3 horizontal dropdown lines(up to 5 product selection). Do I need to re-add an sql query each time for each of the lines? Thank you so much for your help in advance! Ben
  12. Hi Barand, Thank you so much, I am very impressed about your profile, wow, you have actually lived in coding/systems pretty much all your adult life, it must become totally natural for you to use those languages and logic...nice :-) Thanks again for the map:-) Ben
  13. Thanks Barand, I can see that you are very experienced in PHP, for how many years have you been coding please? Do you believe in frameworks like Yii2 or Laravel or is it a waste of time? Thank you, Ben
  14. Hello, I am still on the learning curve with PHP and mysql, I can create normal cruds but this time I need a CRUD where I can add fields and set a dropdown menu. Example: I have a products table with prices I want the admin to be able to pass an order and click on an "add product" button and have a dropdown menu with the data of the products showing each time, and perhaps have this done 10 times or more... Any idea how to do this please? Thank you. Ben
  15. Ok, the answer was to add this in the header: header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies.
  16. Wow thank you so much to both of you:-) great map Baran. From product to "order item" is a "1 to many relationship" From Product to Price is "1 to 1 relationship" but from Order to invoice, I do not know I do not recognize the link between in the order and invoice in your map, there is like a little circle, what does this one means please? I see so having a new "delete" column would let me create an update query that sets it to 1 or zero then in the list table I can show the non delete first, neat. One thing I am not sure about.....I had the problem years ago when I paid a dev to create an invoicing system for me, when customer detaisl changed(vat number, company name for example), this was also changing on the pre generated invoices(in the archives), so really when an order is done, you do not want too much relationships between the tables because the content that is being sent in the form has to be static and cannot eb modified dynamically, am I correct? One last thing I wanted to ask you, what is the best way to query 2 tables that have a relationship: ie: $query = "SELECT id, cust_name, address, FROM customers WHERE id = $customer"; Let's say I wanted to also have (based on your map)the cust_type showing in my tables. Thanks, Ben
  17. Yes I am actually clicking a link manually from http://sample.com/admin/crud/products/list-products.php Showing price 0.78 in the list table Now I click the "edit button" and go here: http://sample.com/admin/crud/products/update-products.php?product=1 I change price from 0.78 to 0.85 and click update. Echo message "Record updated". Now I click on the link again: http://sample.com/admin/crud/products/list-products.php It shows the right update price of 0.85 Now I click on "Edit record" It now shows the old record of 0.78, if I refresh the page, it now shows 0.85 for the same id. This is so weird and it is happening on the whole script. I am wondering if ob_start(); / ob_flush(); is causing problem. What else could cache the queries please? Would output buffering on causes this? Thank you, Ben
  18. Thank you so much I just realised that I was not getting emails notification of the posts....thanks again! Ben
  19. Hello, I am going to code my first php app but I have a design question. My app will have 4 tables: Customers Products Order Resellers Products will be first entered via a crud, then when the admin will pass an order he will need to populate the order form with the customer names via dropdown menu and also products names via dropdown menu. The admin of the app will want to see the list of all the current orders. My questions are: Shall i create a relation between the tables order, products and customers? For me I would design it as separated tables because if a product is removed, I still want my order to retain the old product names in the invoice. Am I correct to do it that way? Also I have another problem, products of the same name may have different prices according to the customer type. How shall I build this "product" table? I was thinking about making a "product" table and a "price" table, then have the product_id foreign key in the price table, would this be ok? I just a bit of help to start with as I am worried to start coding the whole database in the wrong way. Thanks again! Ben
  20. Hello, I am having a strange problem, I created a "customers delete" page and a "customer list" page, when I delete a record, it is removed from mysql but when I click on "list-customers" once, the record is still showing, I need to reload the page again to get the record to be gone, it is weird....Any idea what could cause this please? It looks like the records are cached some how but I have not added any cache addons to my script, it is a bare script with nothing else than pure php, mysql and bootstrap. Here is my deletion page: <?php ob_start(); session_start(); $admin_permission = $_SESSION['admin_permission']; if(($admin_permission) == 1){ //Session admin ID equal 1 }else{ header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php'); exit(); } ?> <?php include($_SERVER["DOCUMENT_ROOT"] . "/admin/includes/admin-header.php"); ?> <!--Content--> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="row"> <div class="col-md-3"> </div> <div class="col-md-6"> <?php $customer_id = $_GET['customer']; if(!$customer_id){ echo "<div class='alert alert-danger' role='alert'>Customer not found!</div>"; }else{ $query = "DELETE FROM customers WHERE id = $customer_id"; $result = mysqli_query($connection, $query); } if ($result && mysqli_affected_rows($connection) == 1) { // Success // redirect_to("somepage.php"); echo "<div class='alert alert-success' role='alert'>Record Deleted!</div>"; } else { // Failure // $message = "Subject update failed"; die("Database query failed. " . mysqli_error($connection)); } ?> </div> </div> </div> </div> </div> <!--Content--> <?php mysqli_close($connection); ob_flush(); ?> <?php include($_SERVER["DOCUMENT_ROOT"] . "/admin/includes/admin-footer.php"); ?> And here my customer listing page: <?php ob_start(); session_start(); $admin_permission = $_SESSION['admin_permission']; if(($admin_permission) == 1){ //Session admin ID equal 1 }else{ header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php'); exit(); } ?> <?php include($_SERVER["DOCUMENT_ROOT"] . "/admin/includes/admin-header.php"); ?> <!--Content--> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="row"> <div class="col-md-1"></div> <div class="col-md-10"> <h3> List of customers records </h3> <?php // This first query is just to get the total count of rows $sql = "SELECT COUNT(id) FROM customers"; $query = mysqli_query($connection, $sql); $row = mysqli_fetch_row($query); // Here we have the total row count $rows = $row[0]; // This is the number of results we want displayed per page $page_rows = 5; // This tells us the page number of our last page $last = ceil($rows/$page_rows); // This makes sure $last cannot be less than 1 if($last < 1){ $last = 1; } // Establish the $pagenum variable $pagenum = 1; // Get pagenum from URL vars if it is present, else it is = 1 if(isset($_GET['pn'])){ $pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']); } // This makes sure the page number isn't below 1, or more than our $last page if ($pagenum < 1) { $pagenum = 1; } if ($pagenum > $last) { $pagenum = $last; } // This sets the range of rows to query for the chosen $pagenum $limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows; // This is your query again, it is for grabbing just one page worth of rows by applying $limit $sql = "SELECT id, cust_company, cust_name, cust_surname, cust_address, cust_phone, cust_email, cust_vat FROM customers ORDER BY id DESC $limit"; $query = mysqli_query($connection, $sql); // This shows the user what page they are on, and the total number of pages $textline1 = "Testimonials (<b>$rows</b>)"; $textline2 = "Page <b>$pagenum</b> of <b>$last</b>"; // Establish the $paginationCtrls variable $paginationCtrls = ''; // If there is more than 1 page worth of results if($last != 1){ /* First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. */ if ($pagenum > 1) { $previous = $pagenum - 1; $paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Previous</a> '; // Render clickable number links that should appear on the left of the target page number for($i = $pagenum - 4; $i < $pagenum; $i++){ if($i > 0){ $paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> '; } } } // Render the target page number, but without it being a link $paginationCtrls .= ''.$pagenum.' '; // Render clickable number links that should appear on the right of the target page number for($i = $pagenum + 1; $i <= $last; $i++){ $paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> '; if($i >= $pagenum + 4){ break; } } // This does the same as above, only checking if we are on the last page, and then generating the "Next" if ($pagenum != $last) { $next = $pagenum + 1; $paginationCtrls .= ' <a href="'.$_SERVER['PHP_SELF'].'?pn='.$next.'">Next</a> '; } } $list = ''; ?> <ul class="pager"> <li class="previous"><?php echo $paginationCtrls; ?></li> </ul> <?php // Attempt select query execution if($result = mysqli_query($connection, $sql)){ if(mysqli_num_rows($result) > 0){ echo "<table class='table table-bordered'>"; echo "<tr>"; echo "<th class='col-md-1'>id</th>"; echo "<th class='col-md-2'>Company</th>"; echo "<th class='col-md-1'>Name</th>"; echo "<th class='col-md-1'>Surname</th>"; echo "<th class='col-md-2'>Address</th>"; echo "<th class='col-md-1'>Phone</th>"; echo "<th class='col-md-2'>Email</th>"; echo "<th class='col-md-2'>V.A.T</th>"; echo "<th class='col-md-1'></th>"; echo "</tr>"; while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){ $id = $row["id"]; $cust_company = $row["cust_company"]; $cust_name = $row["cust_name"]; $cust_surname = $row["cust_surname"]; $cust_address = $row["cust_address"]; $cust_phone = $row["cust_phone"]; $cust_email = $row["cust_email"]; $cust_vat = $row["cust_vat"]; echo "<tr>"; echo "<td>" . $id . "</td>"; echo "<td>" . $cust_company . "</td>"; echo "<td>" . $cust_name . "</td>"; echo "<td>" . $cust_surname . "</td>"; echo "<td>" . $cust_address . "</td>"; echo "<td>" . $cust_phone . "</td>"; echo "<td>" . $cust_email . "</td>"; echo "<td>" . $cust_vat . "</td>"; echo "<td><a class='btn btn-default' href='update-customers.php?customer=$id' role='button'>Edit</a><a class='btn btn-danger' href='delete-customers.php?customer=$id' role='button'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; // Close result set mysqli_free_result($result); }else{ echo "ERROR: Could not able to execute $query. " . mysqli_error($connection); }} ?> </div> <div class="col-md-1"></div> </div> </div> </div> </div> <!--Content--> <?php mysqli_close($connection); ob_flush(); ?> <?php include($_SERVER["DOCUMENT_ROOT"] . "/admin/includes/admin-footer.php"); ?> Thanks in advance! Ben
  21. Hello, I would like to know if someone could help me find a solution with this path problem please. I have a file here: C:\xampp\htdocs\food\admin\crud\customers\add-customers.php In that file I have this code: <?php session_start(); $admin_permission = $_SESSION['admin_permission']; if(($admin_permission) == 1){ //Session admin ID equal 1 }else{ header('Location: '. $_SERVER['HTTP_HOST'] . '/sign-in.php'); } include dirname(__FILE__) . '/admin/includes/admin-header.php'; include dirname(__FILE__) . '/admin/includes/admin-navbar.php'; include dirname(__FILE__) . '/admin/includes/admin-functions.php'; include dirname(__FILE__) . '/db/dbconnect.php'; ?> But this code outputs the errors: Warning: include(C:\xampp\htdocs\food\admin\crud\customers/admin/includes/admin-header.php): failed to open stream: No such file or directory in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 9 Warning: include(): Failed opening 'C:\xampp\htdocs\food\admin\crud\customers/admin/includes/admin-header.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 9 Warning: include(C:\xampp\htdocs\food\admin\crud\customers/admin/includes/admin-navbar.php): failed to open stream: No such file or directory in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 10 Warning: include(): Failed opening 'C:\xampp\htdocs\food\admin\crud\customers/admin/includes/admin-navbar.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 10 Warning: include(C:\xampp\htdocs\food\admin\crud\customers/admin/includes/admin-functions.php): failed to open stream: No such file or directory in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 11 Warning: include(): Failed opening 'C:\xampp\htdocs\food\admin\crud\customers/admin/includes/admin-functions.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 11 Warning: include(C:\xampp\htdocs\food\admin\crud\customers/db/dbconnect.php): failed to open stream: No such file or directory in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 12 Warning: include(): Failed opening 'C:\xampp\htdocs\food\admin\crud\customers/db/dbconnect.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\food\admin\crud\customers\add-customers.php on line 12 All I need is to have all my paths starting from the path: C:\xampp\htdocs\food\, I thought this would help include dirname(__FILE__) but it looks like not.... Would you have a different solution I could try please? Thank you, Ben
  22. Hello, I keephaving this annoying error and cannot work out why it is happening, any help would be more than appreciated please. I looked online for help but cannot work out why data cannot be sent before the header or why there is data anyway sent before the header code....I am confused. I checked for blank spaces and things like that but nothing... Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\plus\admin\includes\header.php:21) in C:\xampp\htdocs\plus\admin\sign-in.php on line 29 <?phpsession_start();include('includes/header.php');include('includes/public-navbar.php');include('../db/dbconnect.php');?> <?php $username = ""; if(isset($_POST['submit'])) { //process the form if(isset($_POST["username"]) && $_POST["password"]) { $query = "SELECT * FROM users WHERE username = 'admin' LIMIT 1"; $results = mysqli_query($connection, $query); $password = $_POST["password"]; $admin = $_POST["username"]; while ($row = mysqli_fetch_row($results)) { //If Admin name = md5 mysql recorded version if(md5($password) != $row[2]) { echo "wrong username/password!"; }else{ header("Location: logged-in.php"); die(); } } } } ?> <!--Content--> <div class="row"><div class="col-md-4"></div><div class="col-md-4"> <form role="form" method="post" action="sign-in.php"><div class="form-group"> <label for="InputUsername">Username</label><input type="text" class="form-control" name="username" placeholder="Your Email" value="<?php echo htmlentities($username); ?>" required /></div> <div class="form-group"> <label for="InputPassword">Password</label><input type="password" class="form-control" name="password" placeholder="Your Password" required /></div> <div class="form-group"> <button type="submit" class="btn btn-default" name="submit">Submit</button> </div></form></div><div class="col-md-4"></div></div> <!--Content--> <?php include('includes/footer.php'); ?> and here is my header.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Admin Login</title> <meta name="description" content=""> <meta name="author" content=""> <link href="../css/bootstrap.min.css" rel="stylesheet"> <link href="../css/style.css" rel="stylesheet"> </head> <body> <div class="container-fluid"> <div class="row"> <div class="col-md-12">
  23. Hello, I have this code here: while ($row = mysqli_fetch_row($results)) { //If Admin name = md5 mysql recorded version if (md5($password) == $row[2]) { echo "All good!"; }else{ echo "wrong username/password!"; } I would like to use $row['password']; in stead of $row[2] but it is not working, I am worried to one day have the array 2 changing position and would prefer use the actual column name instead, how do to this please? My column name is "password". Thank you, Ben
  24. Hello, I am using this collapse menu from bootstrap: http://getbootstrap.com/javascript/#collapse What I did is instead of putting text in the content section I added many links. The links only show up when one of the menu link is clicked. Now my problem is that in one of the menu sub, there are about 30 links, therefore the user has to go down the page to see the content. Is there a way to have the menu collapsing on itself when a link is clicked please? Like a reset to reset it like on page load Thanks all, Ben
×
×
  • 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.