Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 13 online users. » 0 Member(s) | 12 Guest(s) Google
|
Latest Threads |
_SESSION for PHP
Forum: Questions and answers
Last Post: bmackenty
02-20-2021, 08:34 AM
» Replies: 2
» Views: 157
|
Quering Mysql Column if m...
Forum: Questions and answers
Last Post: LamaPijeon
02-14-2021, 07:44 PM
» Replies: 2
» Views: 178
|
Buttons on front page
Forum: Questions and answers
Last Post: bmackenty
02-07-2021, 09:58 AM
» Replies: 1
» Views: 248
|
Edit Item
Forum: Questions and answers
Last Post: bmackenty
01-26-2021, 09:57 AM
» Replies: 3
» Views: 370
|
Survey Button
Forum: Questions and answers
Last Post: bmackenty
01-15-2021, 10:21 AM
» Replies: 1
» Views: 292
|
Storing lists
Forum: Questions and answers
Last Post: bmackenty
01-15-2021, 09:44 AM
» Replies: 1
» Views: 888
|
Navbar
Forum: Questions and answers
Last Post: bmackenty
01-15-2021, 09:43 AM
» Replies: 1
» Views: 445
|
Submit button
Forum: Questions and answers
Last Post: bmackenty
01-12-2021, 09:30 AM
» Replies: 1
» Views: 302
|
Navbar dropdown arrow doe...
Forum: Questions and answers
Last Post: bmackenty
12-14-2020, 09:04 AM
» Replies: 1
» Views: 419
|
Intro TP
Forum: Questions and answers
Last Post: bmackenty
11-19-2020, 08:28 PM
» Replies: 1
» Views: 436
|
|
|
Quering Mysql Column if matching Word |
Posted by: LamaPijeon - 02-14-2021, 10:14 AM - Forum: Questions and answers
- Replies (2)
|
 |
I am querying a MySQL table, and want it only to output items that match the word but can have other words as well. I am sort of looking for the equivalence of
PHP Code: strpos ( string $haystack , string $needle)
in MySql.
![[Image: Screenshot-2021-02-14-at-11-02-41.png]](https://i.ibb.co/xJPskXx/Screenshot-2021-02-14-at-11-02-41.png)
Here is an image of my phpMyAdmin table. I am trying to search the table if the rightmost column, the `archetype` column. I am trying to find all results that match one word like Voltron, but the problem is that for example item #11, also has the word 'Keyword' in that column so it won't show.
![[Image: Screenshot-2021-02-14-at-11-02-46.png]](https://i.ibb.co/n1Xv05s/Screenshot-2021-02-14-at-11-02-46.png)
This is an example of what I want to search by. The last column, the archetype column is the variable. I want to query MySql for all items that were Archetype like Tribal, or like Voltron, but can contain other 'Archetypes' as well.
When I query by this card, item number 3,9,10,11, and 15 should be outputed.
PHP Code: $aType = $_GET['archetype']; $aType = explode(" ", $aType); $arrayNum = $aType[0]; foreach ($aType as $value){ //This Decides the Cards. $query_all_items = mysqli_query($connect, "SELECT * FROM `edh__cardDatabase` WHERE `name` NOT LIKE '$name' AND `archetype` LIKE '$arrayNum' ORDER BY `name` ASC;"); $arrayNum = $aType[+1]; //This Decides the Cards. while ($row = mysqli_fetch_array($query_all_items)) {
And finally, this is what I have as the code, which right now doesn't work. $aType is an array with all of the Archetypes, and $arrayNum is a string with one of them. It all works, but I'm just curious if there is a way to find results that contain at least $arrayNum, but can contain more.
|
|
|
Edit Item |
Posted by: Koala123 - 01-14-2021, 04:47 PM - Forum: Questions and answers
- Replies (3)
|
 |
Mr. Mackenty when I try to edit an item it doesn't pop up as it does on the inventory. I think that it's coded to be able to connect to the database.inc but yet it does not work. I have tried multiple things, but nothing seems to make a difference. Could you please take a look at my code and see if there is anything wrong with it? Thank you so much.
PHP Code: <!doctype html> <!-- this file should be named recipe_edit_item.php --> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> </head> <body> <!-- =========================================== --> <!-- PLEASE DO NOT EDIT ANYTHING ABOVE THIS LINE --> <!-- =========================================== --> <?php include('recipe_navbar.php'); ?> <div class="container mt-5">
<table class="table table-hover table-bordered table-striped"> <thead> <tr> <th scope="col">Id</th> <th scope="col">Name</th> <th scope="col">Link_to_image</th> <th scope="col">Recipe</th> <th scope="col">Meal_type</th> <th scope="col">Gluten_free</th> <th scope="col">Vegeterian</th> <th scope="col">Vegan</th> <th scope="col">Lactose_free</th> </tr> </thead> <tbody> <?php
include('database_inc.php');
$result = mysqli_query($connect, "SELECT * FROM items;");
while ($row = mysqli_fetch_array($result)) { ?> <tr> <th scope="row"><?php echo $row['id']; ?></th> <td><?php echo $row['name']; ?></td> <td><?php echo $row['link_to_image']; ?></td> <td><?php echo $row['recipe']; ?></td> <td><?php echo $row['meal_type']; ?></td> <td><?php echo $row['gluten_free']; ?></td> <td><?php echo $row['vegeterian']; ?></td> <td><?php echo $row['vegan']; ?></td> <td><?php echo $row['lactose_free']; ?></td> <td><a href="recipe_edit_item_process.php?id=<?php echo $row['id']; ?>">Edit this item</a></td> </tr> <?php } ?> </tbody> </table> </div> <!-- close the container --> <!-- =========================================== --> <!-- PLEASE DO NOT EDIT ANYTHING BELOW THIS LINE --> <!-- =========================================== --> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> </body> </html>
This is the process page that could also be the source of the problem;
PHP Code: <!doctype html> <!-- this file should be named recipe_edit_item_process.php --> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> </head> <body> <!-- =========================================== --> <!-- PLEASE DO NOT EDIT ANYTHING ABOVE THIS LINE --> <!-- =========================================== --> <?php
// the line below gets the id from the url. There are all sorts of security issues here // can you think of some security problems?
$item_to_edit = $_GET['id'];
// the line below includes a file that allows connection to our database.
include('database_inc.php');
?> <?php include('recipe_navbar.php'); ?> <div class="container mt-5">
<?php
$result = mysqli_query($connect, "SELECT * from items WHERE id = '$item_to_edit';");
while ($row = mysqli_fetch_array($result)) { ?> <form action = "recipe_update_edited_item.php" method="POST">
<div class="form-group"> <label for="Id">Name</label> <input name="name" type="text" class="form-control" id="name" placeholder="Enter name" value = "<?php echo $row['name']; ?>" > </div>
<div class="form-group"> <label for="ink_to_image">Link_to_image</label> <input name="ink_to_image" type="text" class="form-control" id="ink_to_image" placeholder="Enter ink_to_image" value = "<?php echo $row['ink_to_image']; ?>"> </div>
<div class="form-group"> <label for="recipe"> Recipe</label> <input name="recipe" type="text" class="form-control" id="recipe" placeholder="Enter recipe" value = "<?php echo $row['recipe']; ?>"> </div>
<div class="form-group"> <label for="meal_type">Meal_type</label> <input name="meal_type" type="text" class="form-control" id="meal_type" placeholder="Enter meal_type" value = "<?php echo $row['meal_type']; ?>"> </div>
<div class="form-group"> <label for="gluten_free">Gluten_free</label> <input name="gluten_free" type="text" class="form-control" id="gluten_free" placeholder="Enter gluten_free" value = "<?php echo $row['gluten_free']; ?>"> </div>
<div class="form-group"> <label for="vegeterian">Vegeterian</label> <input name="vegeterian" type="text" class="form-control" id="vegeterian" placeholder="Enter vegeterian" value = "<?php echo $row['vegeterian']; ?>"> </div>
<div class="form-group"> <label for="vegan">Vegan</label> <input name="vegan" type="text" class="form-control" id="vegan" placeholder="Enter vegan" value = "<?php echo $row['vegan']; ?>"> </div>
<div class="form-group"> <label for="lactose_free">Lactose_free</label> <input name="lactose_free" type="text" class="form-control" id="lactose_free" placeholder="Enter lactose_free" value = "<?php echo $row['lactose_free']; ?>"> </div>
<input type="hidden" name="item_to_edit" value="<?php echo $item_to_edit; ?>">
<button type="submit" class="btn btn-primary">Edit this item</button> </form>
<?php } ?>
</div> <!-- close the container --> <!-- =========================================== --> <!-- PLEASE DO NOT EDIT ANYTHING BELOW THIS LINE --> <!-- =========================================== --> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> </body> </html>
|
|
|
Survey Button |
Posted by: Pan Adam - 01-14-2021, 02:43 PM - Forum: Questions and answers
- Replies (1)
|
 |
Hi Mr. MacKenty,
I was wondering how I could make a 'Click here to take a survey' button on the homepage which would bring me to another page. I tried using previous assignments to help but I couldn't figure it out. Could you help me?
Thank you.
PHP Code: <div class="text-center" style="float:center"> <button type="button" class="btn btn-primary">Click here to take a survey! <form action="Workout_survey.php" method="POST"> </form> </button> </div>
|
|
|
Navbar dropdown arrow does not work |
Posted by: Constantinople4life - 12-11-2020, 08:10 AM - Forum: Questions and answers
- Replies (1)
|
 |
Hello, the dropdown function on my website does not work and I need help debugging.
PHP Code: <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="game_store_console_section.php" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Consoles </a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="game_store_playstation.php">Playstation</a> <a class="dropdown-item" href="game_store_xbox.php">Xbox</a> <a class="dropdown-item" href="game_store_switch.php">Switch</a> </div> </li>
can anyone please help me find the problem?
|
|
|
Visual Studio Code |
Posted by: LamaPijeon - 11-19-2020, 02:16 PM - Forum: Questions and answers
- Replies (1)
|
 |
Write you VS Code problems
Hi guys. When I'm typing in Visual Studio Code when I write a bracket, the other bracket doesn't pop up. It's not terrible but a little annoying. So If I write <html>, </html> doesn't pop up. Why?
|
|
|
|