I have a fully working piece of PHP, HTML code but when I place it into my website that is styled using jQuery Mobile the submit button will not display the query. Does anybody know how to fix this or even why it is happening
SCRIPT
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>The School of Computing and Mathematics</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="themes/project1.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile.structure-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
</head>
PHP
<body>
<div data-role="page">
<?php
// Create connection
$con=mysqli_connect('localhost', '', '', 'timetabledb');
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$course_dropdown ="";
$query_course = "SELECT * FROM course";
$result_course = mysqli_query($con,$query_course) or die(mysqli_error());
while($row = mysqli_fetch_assoc($result_course))
{
$course_dropdown .= "<option value='{$row['CourseName']}'>{$row['CourseName']}</option>";
}
$module_dropdown ="";
$query_module = "SELECT * FROM module";
$result_module = mysqli_query($con,$query_module) or die(mysqli_error());
while($row = mysqli_fetch_assoc($result_module))
{
$module_dropdown .= "<option value='{$row['ModuleName']}'>{$row['ModuleName']}</option>";
}
$day_dropdown ="";
$query_day = "SELECT * FROM days ";
$result_day = mysqli_query($con,$query_day) or die(mysqli_error());
while($row = mysqli_fetch_assoc($result_day))
{
$day_dropdown .= "<option value='{$row['Day']}'>{$row['Day']}</option>";
}
echo "<table border='1'>
<tr>
<th>Course Name</th>
<th>Module Name</th>
<th>Type of Class</th>
<th>Lecturer</th>
<th>Time</th>
<th>Day</th>
<th>Room</th>
</tr>";
if (isset($_POST['button']) && $_POST['button'] == 'Submit') {
$course = mysqli_real_escape_string($con, $_POST['Course']);
$module = mysqli_real_escape_string($con, $_POST['Module']);
$day = mysqli_real_escape_string($con, $_POST['Day']);
$query = "SELECT * FROM course_module WHERE CourseName = '$course' AND ModuleName = '$module' AND Day = '$day'";
$result = mysqli_query($con,$query);
while($row1 = mysqli_fetch_assoc($result)){
echo "<tr>";
echo "<td>" . $row1['CourseName'] . "</td>";
echo "<td>" . $row1['ModuleName'] . "</td>";
echo "<td>" . $row1['ClassType'] . "</td>";
echo "<td>" . $row1['Lecturer'] . "</td>";
echo "<td>" . $row1['Time'] . "</td>";
echo "<td>" . $row1['Day'] . "</td>";
echo "<td>" . $row1['Room'] . "</td>";
echo "</tr>";
}
}
?>
HTML
<h1>School of Computing and Mathematics</h1>
<h2>Mobile website<h2>
<h2>Current students</h2>
<div data-role="collapsible-set" data-theme="c" data-content-theme="d">
<div data-role="collapsible">
<h3>Section 1</h3>
<p>I'm the collapsible content for section 1</p>
</div>
<div data-role="collapsible">
<h3>Section 2</h3>
<p>I'm the collapsible content for section 2</p>
</div>
<div data-role="collapsible">
<h3>Timetabling</h3>
<p>Select your Course</p>
<form action="current.php" method="post" data-ajax="false">
<select name="Course">
<option>Select Course</option>
<?php echo $course_dropdown; ?>
</select>
<select name="Module">
<option>Select Module</option>
<?php echo $module_dropdown; ?>
</select>
<select name="Day">
<option>Select Day</option>
<?php echo $day_dropdown; ?>
</select>
<input id ="button_timetable" name="button" value="Submit" type="submit">
</form>
</div>
<div data-role="footer" data-id="foo1" data-position="fixed">
<div data-role="navbar">
<ul>
<li>Home</li>
<li>News</li>
<li class="ui-btn-active ui-state-persist">Current students</li>
<li>Prospective students</li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
</div>
</body>
</html>
Please keep in mind that this script is fully implemented on a plain HTML site. I am only having issues with the jQuery mobile library.
Thank You in advance
Let me give you an answer, I found everything going through your code.
Inside a index.php:
data-ajax="false" should be added as a form attribute, it prevents jQuery Mobile from using ajax to submit data.
Incorrect jQuery Mobile css was initialized in a HEAD
table tag was not closed
But, through and trough this is well built page.
Related
<?php
include_once("Globals.php");
global $model;
I want to capture the $order_id value from the $_GET['claim_order'] for future re-use.
if(isset($_GET['claim_order'])){
$order_id = $_GET['claim_order'];
}
for example the value saved in the $order_id variable is not available for repeat use on the current page.
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Caregiver Claims Order</title>
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Font Awesome -->
<link rel="stylesheet" href="../../plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="../../dist/css/adminlte.min.css">
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
<!-- Sidebar -->
<div class="sidebar">
<!-- Sidebar user (optional) -->
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
<div class="info">
SESSION: Caregiver
</div>
</div>
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
</ul>
</nav>
<!-- /.sidebar-menu -->
</div>
<!-- /.sidebar -->
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header" style="padding: 0px 0px 0px 0px" >
<div class="container-fluid " style="padding: 0px 0px 0px 0px" >
<div class ="row">
<div class="col">
<h1>Order#<?php
global $order_id;
echo (int)$order_id;
?></h1>
</div>
<div class ="col-auto">
<a href ="CaregiverCODetailView.php?button_claim=$care_giver_id">
<input type="submit" name="button_claim" class="btn btn-primary"></input>
</a>
<?php
if(isset($_GET["button_claim"])){
for example in the next 3 lines I try to use it but it returns the wrong value of 0 instead the correct value corresponding to the "button_claim".
I want to be able to refer to the value even if I refresh the .php page.
All I want to do is use that $order_id value in a SQL query. It basically indicates the ID# of the order in question.
$care_giver_id = $model->getCurrentUserId();
global $order_id;
$sql = "UPDATE `order` SET `care_giver_id` = '$care_giver_id' WHERE `order_id` = '$order_id'";
if(!mysqli_query($conn, $sql)){
header("Location: fail.php");
}else{
header("Location: CaregiverCODetailView.php");
}
}
?>
</div>
</div>
<div class="row" style="min-height:71vh" style="min-width:100vw">
<div class= "col" style="min-height:71vh" style="min-width:100vw">
<table id="example4" class="table table-borderless table-hover">
<?php
global $conn;
global $order_id;
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT";
$sql .= " `medication`.`name` as `name`,";
$sql .= " `medication`.`physical_form` as `form`,";
$sql .= " `medication`.`units` as `units`,";
$sql .= " `break_down`.`administer_time` as `time`,";
$sql .= " `break_down`.`quantity` as `quantity`";
$sql .= " FROM `break_down`";
$sql .= " JOIN `medication` on (`medication`.`medication_id` = `break_down`.`medication_id`)";
$sql .= " WHERE `break_down`.`order_id` = '$order_id'";
$result = $conn->query($sql);
echo "<id='example2'>";
echo "<tbody>";
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['quantity'] . $row['units']. "</td>";
echo "<td>" . $row['form'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
} else {
echo "</tbody>";
echo "</table>";
echo "<h4>ORDERS DATABASE EMPTY</h4>";
}
?>
</div>
</div>
<div class="row" style="min-height:15vh" style="min-width:100vw">
<div class= "col" style="background-color:orange" style="min-height:15vh" style="min-width:100vw" >
<?php
global $conn;
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = " select " ;
$sql .= " `patient`.`first` as `first`,";
$sql .= " `patient`.`last` as `last`,";
$sql .= " `order`.`order_id` as `order_id`,";
$sql .= " `order`.`date` as `datefield`";
$sql .= " from `patient`";
$sql .= " join `order` on (`order`.`patient_id` = `patient`.`patient_id`)";
$sql .= " where `order`.`order_id` = '$order_id'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<div class='row '>";
echo "<div class ='col '>";
echo "<h3>Patient</h3>";
echo "<h5>" . $row['first'] . " " . $row['last'] . "</h5>";
echo "</div>";
echo "<div class = 'col-auto '>";
echo "<h3>Date Created</h3>";
echo "<h5>" . $row['datefield'] . "</h5>";
echo "</div>";
echo "</div>";
}
}
?>
</div>
</div>
</div>
<!-- /.container-fluid -->
</section>
</div>
</div>
<!-- ./wrapper -->
If you want to store some short-term data, PHP sessions would be a sufficient solution. Keep in mind that this data will only last as long as your session lasts.
session_start();
$_SESSION['order_id'] = $_GET['claim_order'];
For a longer-term storage solution, consider storing the data in a database like MySQL or in a file (make sure to keep this file out of the web directory if it's holding private information).
You can use the setcookie('name_of_cookie', $value); and get this data using $_COOKIE('name_of_cookie');. after this you can use the unset($_COOKIE('name_of_cookie'));
On my website i have an admin page where i want to be able to update information in the database, using a form.
This is the code im using to enter information and update what is in my database:
adminform.php
<html>
<head>
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body>
<header id="header">
<h1>SafeTNet</h1>
<nav id="nav">
<ul>
<li>Admin Page Only</li>
<li></li>
<li>Logout </li>
</ul>
</nav>
</header>
<h1> Select a member </h1>
<br />
<select name="members" onchange="showUser(this.value)">
<option value="">Select a member email</option>
<?php
$query = "SELECT * FROM members";
$mysqli = new mysqli('localhost','root','root','SafeTNetD');
$result = $mysqli->query($query);
while($row = $result->fetch_assoc())
echo '<option value="'.$row["email"].'">'.$row["email"].'</option>';
?>
</select>
<div id="signup">
<h2>Update Your Member Information</h2>
<form method="post" action="admin1.php">
<table>
<tr>
<td>Email</td>
<td><input type="text" name="email" required="required"></td>
</tr>
<tr>
</tr>
<tr>
<td>City </td>
<td><input type="text" name="city"></td>
</tr>
<tr>
</tr>
<tr>
</table>
<br><br>
<div id="buttons">
<input type="submit">
</div>
</body>
</html>
admin1.php
<html>
<head>
<title>Admin</title>
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body>
<header id="header">
<h1>SafeTNet</h1>
<nav id="nav">
<ul>
<li>Admin Page Only</li>
<li></li>
<li>Logout</li>
</ul>
</nav>
</header>
<br />
<?php
$query = "SELECT * FROM members";
$mysqli = new mysqli('localhost','root','root','SafeTNetD');
$result = $mysqli->query($query);
while($row = $result->fetch_assoc())
echo '<option value="'.$row["email"].'">'.$row["email"].'</option>';
?>
</select>
<br />
<?php
$q=$row["email"];
$mysqli = new mysqli('localhost','root','root','members');
$sql = "SELECT * FROM members WHERE email='".$q."'";
if(array_key_exists('_submit_check', $_POST))
{
$email = $_POST['email'];
$city = $_POST['city'];
$sql = "UPDATE members SET city = '$city' WHERE email = '$q'";
if($mysqli->query($sql) === TRUE)
{
echo 'Record updated successfully<br />';
}
else
{
echo $sql.'<br />' . $mysqli->error;
}
$mysqli->close();
}
?>
<br><br><br>
<footer id="footer">
<img src="logo.jpg" height="50px">
<ul class="copyright">
<li>© SafeTNet. All rights reserved.</li><li> 2016</li>
</ul>
</footer>
</body>
</html>
I can get the form to run but cant get the information to change in the database or echo to the screen.
Thank you in advance.
if(array_key_exists('_submit_check', $_POST))
{
$email = $_POST['email'];
$city = $_POST['city'];
$sql = "UPDATE members SET city = '$city' WHERE email = '$q'";
if($mysqli->query($sql) === TRUE)
{
echo 'Record updated successfully<br />';
}
else
{
echo $sql.'<br />' . $mysqli->error;
}
$mysqli->close();
}
There is no element called '_submit_check' in your form. I guess you forgot the name attribute of your submit-button.
Your script is very vulnerable to SQL-Injection. You really should not simply throw the userinput into your query. You can use mysqli_real_escape_string() or Prepared Statements to protect your application.
To improve the readability of your code you could change the structure a little. In your admin1.php you should do the business logic before outputting any html. So you would first check if the form has been sent, then you do the database operation. The result of the check or the success/error-message of the database operation can be written into a variable until you output the content of your site.
This way everybody who starts reading the code immediately knows 'alright, this script is the target of some form and accesses the database for some write-operation'.
I wonder why the 2nd output $devNO gives me bool(false) which is empty. i have no idea about it. Am I wrong at the mysql_query() part?
$developer = $_POST['dev'];
$platform = $_POST['plat'];
$genre = $_POST['gen'];
var_dump($developer);
echo "<br>";
$devNO = mysql_query("SELECT No FROM developer WHERE Developer = $developer");
$platNO = mysql_query("SELECT No FROM platform WHERE Platform = $platform");
$genNO = mysql_query("SELECT No FROM genre WHERE Genre = $genre");
var_dump($devNO);
Here's my output:
Here I will show my full code for "games.php":
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<html>
<head lang="en">
<meta charset="utf-8" />
<title>Game List</title>
<link rel="stylesheet" href="css.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<style>
legend {font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif}
</style>
</head>
<body>
<div id="big_wrapper">
<header id="top_header">
<h1>Dandy's Game Library</h1>
</header>
<nav id="top_menu">
<ul>
<li><strong></stron>Home</strong></li>
<li><strong>Game List</strong></li>
</ul>
</nav>
<div id="game_wrapper">
<section id="filter">
<form action="games.php" method="post" name="search_form">
<fieldset>
<legend><h3><strong>Search</strong></h3></legend>
<strong>Developer</strong><br>
<select name="dev">
<option value="">--Select--</option>
<?php
include("dbConnection.php");
mysql_connect("localhost","root","");
mysql_select_db("games");
$sql = mysql_query("SELECT Publisher FROM publisher");
while($row = mysql_fetch_array($sql)){
echo "<option value='".$row['Publisher']."'>" .$row[Publisher]. "</option>";
}
?>
</select>
<br/><br/><strong>Game Platform</strong><br>
<select name="plat">
<option value="">--Select--</option>
<?php
$sql = mysql_query("SELECT Platform FROM platform");
while($row = mysql_fetch_array($sql)){
echo "<option value='".$row['Platform']."'>" .$row[Platform]. "</option>";
}
?>
</select>
<br/><br/><strong>Genre</strong><br>
<select name="gen">
<option value="">--Select--</option>
<?php
$sql = mysql_query("SELECT Genre FROM genre");
while($row = mysql_fetch_array($sql)){
echo "<option value='".$row['Genre']."'>" .$row[Genre]. "</option>";
}
$developer = $_POST['dev'];
$platform = $_POST['plat'];
$genre = $_POST['gen'];
?>
</select>
<br><br><input type="submit" name="search" value="Search"></input>
</fieldset>
</form>
</section>
<aside id="items">
<fieldset>
<legend><h3><strong>Game List</strong></h3></legend>
<?php
var_dump($developer);
$devNO = mysql_query("SELECT No FROM developer WHERE Developer = $developer");
$platNO = mysql_query("SELECT No FROM platform WHERE Platform = $platform");
$genNO = mysql_query("SELECT No FROM genre WHERE Genre = $genre");
var_dump($devNO);
$sql = sprintf("SELECT Title, Release_Year, Language, Price FROM games WHERE Developer_NO = $devNO");
$result = mysql_query($sql);
$game_title = 'Title';
$game_year = 'Release_Year';
$game_lan = 'Language';
$game_price = 'Price';
?>
<div id="gamelist">
<?php
if(!$result) {
die(mysql_error());
}
while($row = mysql_fetch_array($result)) {
?>
<div class="row">
<div class="cell"><?php echo $row[$game_title]?></div>
<div class="cell"><?php echo "Year : ".$row[$game_year]?></div>
<div class="cell"><?php echo "Language : ".$row[$game_lan]?></div>
<div class="cell"><?php echo "Price : RM".$row[$game_price]?></div>
</div>
<?php
}
?>
</div>
</fieldset>
</aside>
</div>
</div>
<div id="btm_wrapper">
<footer id="foot">
<strong></strong>
</footer>
</div>
</body>
</html>
The full output will be like this after i search from dropdown:
The method mysql_query() , if successful, returns a resultset, which has to be made an array even if only a single value is being returned from the query.
Ideally there should be a for-each iteration on this array to get result, however if you're sure you'll get at least one value, the first row with desired index('No' in your case).
$dataset= mysql_query("SELECT No FROM developer WHERE Developer = '$developer'");
$row = mysql_fetch_assoc($dataset);
$devNO = $row['No'];
Also note the quote I've used for varchar. It was correctly pointed in the other answer. Try Now.
If $developer is a string use quotes. You need to first fetch results from result set and than use it in code:
<?php
$devNOResult = mysql_query("SELECT No FROM developer WHERE Developer = '$developer'");
$platNOResult = mysql_query("SELECT No FROM platform WHERE Platform = '$platform'");
$genNOResult = mysql_query("SELECT No FROM genre WHERE Genre = '$genre'");
$devNO = mysql_fetch_row($devNOResult);
$sql = sprintf("SELECT Title, Release_Year, Language, Price FROM games WHERE Developer_NO = $devNO");
$result = mysql_query($sql);
$game_title = 'Title';
$game_year = 'Release_Year';
$game_lan = 'Language';
$game_price = 'Price';
?>
<div id="gamelist">
<?php
if(!$result) {
die(mysql_error());
}
while($row = mysql_fetch_array($result)) {
?>
I am working on a way to pull data from my mySQL database and display the text as an array however I have it so that only one string of data is available and each instance is separated by a comma example. 1,2,3,4 is there a way to have it break or start a new line after each comma instead of having a conglomerated mess that looks like this:
1 package KRAFT Deluxe Macaroni & Cheese Dinner Sharp Cheddar Cheese Sauce, 1 lb Ground Beef, 1 Jar Spaghetti Sauce, 1/2 Cup KRAFT Shredded Mozzarella Cheese
Code:
<?php
require_once '../scripts/app_config.php';
require_once '../../scripts/authorize.php';
require_once '../scripts/database_connection.php';
// Get the user ID of the user to show
$User_id = $_REQUEST['User_id'];
// Gets User Id
$select_query = "SELECT * FROM users WHERE User_id = " . $User_id;
// Run the query to get User Name
$result1 = mysql_query($select_query);
if ($result1) {
$row = mysql_fetch_array($result1);
$first_name = $row['First_name'];
$last_name = $row['Last_name'];
$email = $row['Email'];
$User_id = $row['User_id'];
} else {
handle_error("There was a problem finding your " .
"information in our system.",
"Error locating user with ID {$User_id}");
}
$Recipe_Id = $_REQUEST['Id'];
$result = mysql_query( "SELECT * FROM recipes WHERE Id = " . $Recipe_Id )
or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$Id = $row['Id'];
$Name = $row['Name'];
$Ingredients = $row['Ingredients'];
$Category1 = $row['Category1'];
$Category2 = $row['Category2'];
$Directions = $row['Directions'];
$Creator = $row['User_Name'];
?>
<html>
<head>
<title>Recipes</title>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Language" content="English">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../style/index.css" media="screen">
<script type="text/javascript" src="jquery-1.9.1.min.js">
</script>
</head>
<body>
<div id="header">
</div>
<center>
<span class="nav">Home</span> <span class="nav">New Recipe </span> <span class="nav">Sign Out </span>
</center>
<br>
<div id="content">
<div class="user_profile">
<h1><?php echo "{$first_name} {$last_name}";?></h1>
</div>
<div id="feature">
<?php
echo "<H1>". $row['Name'] ."</H1>";
echo "<p>" . $row['Category1'] . "</p>";
echo "<p>" . $row['Category2'] . "</p>";
echo "<p>" . $row['Creator'] . "</p>";
?> </div>
<div class="column1">
<h1>My Recipes</h1>
<?php
echo "<p>" . $row['Ingredients'] . "</p>";
?>
</div>
<div class="column2">
<h1>Directions</h1>
<?php
echo "<p>" . $row['Directions'] . "</p>";
}
?>
</div>
<div class="column3">
<h1>Recipes I Like</h1>
</div>
</div>
<div id="footer"></div>
</body>
</html>
If I got it correctly you just need something like this:
echo "<p>" . str_replace(', ',', <br />',$row['Ingredients']) . "</p>";
If i choose a meal than come the price not in the textbox.
What i want is that if i choose an option in the selectbox that the texbox automatic fills with the price.
<!DOCTYPE html>
<?php
include ("connection.php");
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="test.css">
<meta charset="utf-8">
<title>Kantine</title>
</head>
<body>
<div id="container">
<div id="logo"></div>
<div id="header">
<h1> Change or Delete meals</h1>
</div>
<div id="menu"></div>
<div id="content">
<?php
echo '<select name="Meals">';
$result = mysqli_query($con,"SELECT meal, price FROM meals") ;
while($row = $result->fetch_assoc())
{
echo "<option value=\""."\">" . $row['meal']."</option>\n";
echo "<br />";
}
echo '</select>';
echo '<input type="text" value="' . $row['price'] . '"/>';
mysqli_close($con);
?>
</div>
<div id="footer"></div>
</div>
</body>
</html>
PHP is not suitable for client side scripting. What you want depend on the user choice on the browser side, therefore you'll need Javascript for that. If that action requires a database connection then you may want to use AJAX to connect to a PHP script and get the query results.
Take a look at the jQuery framework and specifically to the ajax section of it.
Have you tried escaping the " in your first echo? Also some of your html can be moved out of the php section, and you dont need linebreaks between option elements. And mixing single and double quotes is a sure way to get into trouble. Be consistent.
<select name="Meals">
<?php
$result = mysqli_query($con,"SELECT meal, price FROM meals") ;
while($row = $result->fetch_assoc())
{
echo "<option value=\"". $row['meal'] . "\">" . $row['meal'] . "</option>";
}
echo "<input type=\"text\" value=\"" . $row['price'] . "\"/>";
mysqli_close($con);
?>
</select>