Note that there are some explanatory texts on larger screens.

plurals
  1. POSelected meal must show me the right price but he show me a error Call to a member function fetch_assoc() on a non-object in
    primarykey
    data
    text
    <p>What I want is that when I select one meal that he show me the meal and the right price. Now he show me the meals but when i select one of these meals there are comes a error. </p> <p>Error: Call to a member function fetch_assoc() on a non-object in </p> <p>When I in mwvp.php this code removed. Then you see al prices that stored in database.</p> <p>You can see under this the removed code en the orginal.</p> <p>Change Meal.php</p> <pre><code>&lt;?php include ("connection.php"); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Kantine&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="test.css"&gt; &lt;meta charset="utf-8"&gt; &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function getMeals(str) { $('#meal_data').text(""); if (str == "select") return; $('#meal_data').load('mwvp.php?q='+str); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="container"&gt; &lt;div id="logo"&gt;&lt;/div&gt; &lt;div id="header"&gt; &lt;h1&gt;Change Meal&lt;/h1&gt;&lt;/div&gt; &lt;div id="menu"&gt; &lt;a href="Addmeal.php"&gt;&lt;img src="Addmeal.png"/&gt;&lt;/a&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;?php $result = mysqli_query($con,"SELECT meal, price FROM Meals "); echo '&lt;select name="Meals"onchange="getMeals(this.value)"&gt;&lt;option value="select"&gt;Choose Meal&lt;/option&gt;'; while ($row = $result-&gt;fetch_assoc()) { echo "&lt;option value=\""."\"&gt;" . $row['meal']."&lt;/option&gt;\n"; echo '&lt;br /&gt;'; } echo '&lt;/select&gt;'; echo '&lt;ul id="meal_data"&gt;'; echo '&lt;/ul&gt;'; mysqli_close($con); ?&gt;&lt;/div&gt; &lt;div id="footer"&gt;&lt;/div&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Original mwvp.php</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;meta charset="utf-8"&gt; &lt;?php $q = $_GET["q"]; include("connection.php"); $result = mysqli_query($con, "SELECT meal, price FROM meals WHERE meal = " .$q); while ($row = $result-&gt;fetch_assoc()) { echo '&lt;input name="price" type="text" value="'.$row['price'].'" /&gt;'; } ?&gt; &lt;/html&gt; </code></pre> <p>Removed code in mwvp.php</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;meta charset="utf-8"&gt; &lt;?php include("connection.php"); $result = mysqli_query($con, "SELECT meal, price FROM meals") while ($row = $result-&gt;fetch_assoc()) { echo '&lt;input name="price" type="text" value="'.$row['price'].'" /&gt;'; } ?&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload