Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 83
» Latest member: AL_YA
» Forum threads: 15
» Forum posts: 38

Full Statistics

Online Users
There are currently 7 online users.
» 0 Member(s) | 7 Guest(s)

Latest Threads
_SESSION for PHP
Forum: Questions and answers
Last Post: bmackenty
02-20-2021, 08:34 AM
» Replies: 2
» Views: 1,008
Quering Mysql Column if m...
Forum: Questions and answers
Last Post: LamaPijeon
02-14-2021, 07:44 PM
» Replies: 2
» Views: 1,073
Buttons on front page
Forum: Questions and answers
Last Post: bmackenty
02-07-2021, 09:58 AM
» Replies: 1
» Views: 1,038
Edit Item
Forum: Questions and answers
Last Post: bmackenty
01-26-2021, 09:57 AM
» Replies: 3
» Views: 1,265
Survey Button
Forum: Questions and answers
Last Post: bmackenty
01-15-2021, 10:21 AM
» Replies: 1
» Views: 1,112
Storing lists
Forum: Questions and answers
Last Post: bmackenty
01-15-2021, 09:44 AM
» Replies: 1
» Views: 5,583
Navbar
Forum: Questions and answers
Last Post: bmackenty
01-15-2021, 09:43 AM
» Replies: 1
» Views: 1,198
Submit button
Forum: Questions and answers
Last Post: bmackenty
01-12-2021, 09:30 AM
» Replies: 1
» Views: 1,108
Navbar dropdown arrow doe...
Forum: Questions and answers
Last Post: bmackenty
12-14-2020, 09:04 AM
» Replies: 1
» Views: 1,202
Intro TP
Forum: Questions and answers
Last Post: bmackenty
11-19-2020, 08:28 PM
» Replies: 1
» Views: 1,193

 
Shocked _SESSION for PHP
Posted by: LamaPijeon - 02-16-2021, 07:56 AM - Forum: Questions and answers - Replies (2)

Sooo...
The way that the session works is that if someone comes onto my page from most other ASW websites, the session from their page gets transferred over to my page. The problem with this is that since the sessions never stop, the user is logged into my website without ever even making an account. Would the correct way of fixing this by checking if that username exists in my database, and then if it doesn't I destroy the session? What if it just happens that the person is using a username that exists, but isn't that person?

Print this item

  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]
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]
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.

Print this item

  Buttons on front page
Posted by: DawarsoN - 02-05-2021, 01:40 PM - Forum: Questions and answers - Replies (1)

Dear Mr. Mackenty, I was wondering if there is a way to put 2 large buttons on the front page that will redirect the user to somewhere else. Maybe bootstrap? I'm talking like col 6 but very wide like in the screenshot provided: 

Thank you!



Attached Files Thumbnail(s)
   
Print this item

  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> 

Print this item

  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.  Big Grin

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

Print this item

  Storing lists
Posted by: YellowLab2 - 01-14-2021, 10:23 AM - Forum: Questions and answers - Replies (1)

I was wondering how you store lists, so that they are able to be reused

Print this item

  Navbar
Posted by: Cheesecake - 01-14-2021, 10:20 AM - Forum: Questions and answers - Replies (1)

when I go to my home page the navbar is an extra space above where it should be like this https://drive.google.com/file/d/10TbhM1M...sp=sharing but not on my other pages https://drive.google.com/file/d/1mB1eBh-...sp=sharing how do I change it so the extra space above the navbar is gone.

Print this item

  Submit button
Posted by: Cheesecake - 01-12-2021, 08:44 AM - Forum: Questions and answers - Replies (1)

Hi,
I made a submit button but don't know how to make it go to a page where the user can get the information from the form it says this when I click the submit button https://learningcomputerscience.com/2021...esults.php

Print this item

  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">
          <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">
            <class="dropdown-item" href="game_store_playstation.php">Playstation</a>
            <class="dropdown-item" href="game_store_xbox.php">Xbox</a>
            <class="dropdown-item" href="game_store_switch.php">Switch</a>
          </div>  
        
</li
can anyone please help me find the problem?

Print this item

  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?

Print this item