I am following The book "Beginning PHP, Apache, MySQL web development" by Wrox. I have been following it verbatim and for some reason I am having a issue with the code. The editor says that there are no errors in my code. but when I run it gives me the following message:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3" here is the following code
<?php
//take in the id of a director and return his/her full name
function get_director() {
global $db;
$query = 'SELECT people_fullname
FROM people
WHERE people_id = ' . $director_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
//take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db;
$query = 'SELECT people_fullname
FROM people
WHERE people_id = ' . $leadactor_id;
$result = mysql_query($query, $db) or die (mysql_error($db));
$extract($row);
return $people_fullname;
}
// take in the id of a movie type
// and return the meaningful textual description
function get_movietype($type_id) {
global $db;
$query = 'SELECT movietype_label
FROM movietype
WHERE movietype_id = ' . $type_id;
$result = mysql_query($query, $db) or die (mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
// conect to MySQL
$db = mysql_connect('localhost', 'root', 'root') or
die ('unable to connect. Check your parameters');
// make sure you are yousing the right database
mysql_select_db('moviesite', $db) or die(mysql_error($db) );
// retrieve information
$query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type
FROM movie
ORDER BY movie_name ASC, movie_year DESC';
$result = mysql_query($query, $db) or die ($mysql_error($db) );
// determine number of rows in returned result
$num_movies = mysql_num_rows($result);
$table = <<<ENDHTML
<div style ="text-align: center;">
<h2>Movie Review Database</h2>
<table border="1" cellpadding="2" cellspacing="2" style="width: 70%; margin-left: auto; margin-right:auto;">
<tr>
<th>Movie Title</th>
<th>Year of the release</th>
<th>Movie Director</th>
<th>Movie Lead Actor</th>
<th>Movie Type</th>
</tr>
ENDHTML;
//loop throught the results
while ($row = mysql_fetch_assoc($result) ) {
extract($row);
$director = get_director($movie_director);
$leadactor = get_leadactor($movie_leadactor);
$movietype = get_movietype($movie_type);
$table .= <<<ENDHTML
<tr>
<td>$movie_name</td>
<td>$movie_year</td>
<td>$director</td>
<td>$leadactor</td>
<td>$movietype</td>
</tr>
ENDHTML;
}
$table .= <<<ENDHTML
</table>
<p>$num_movies Movies</p>
</div>
ENDHTML;
echo $table
?>
After that I tried copying and pasting the exact code thinking maybe I did something wrong
and here it is the following code:
<?php
// take in the id of a director and return his/her full name
function get_director($director_id) {
global $db;
$query = 'SELECT
people_fullname
FROM people
WHERE
people_id = ' . $director_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a lead actor and return his/her full name
function get_leadactor($leadactor_id) {
global $db;
$query = 'SELECT
FROM
people WHERE
people_id = ' . $leadactor_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $people_fullname;
}
// take in the id of a movie type and return the meaningful textual
// description
function get_movietype($type_id) {
global $db;
$query = 'SELECT
movietype_label
FROM
movietype
WHERE
movietype_id = ' . $type_id;
$result = mysql_query($query, $db) or die(mysql_error($db));
$row = mysql_fetch_assoc($result);
extract($row);
return $movietype_label;
}
//connect to MySQL
$db = mysql_connect('localhost', 'root', 'root') or
die ('Unable to connect. Check your connection parameters.');
// make sure you’re using the right database
mysql_select_db('moviesite', $db) or die(mysql_error($db));
// retrieve information
$query = 'SELECT
movie_name, movie_year, movie_director, movie_leadactor,
movie_type
FROM
movie
ORDER BY
movie_name ASC,
movie_year DESC';
$result = mysql_query($query, $db) or die(mysql_error($db));
// determine number of rows in returned result
$num_movies = mysql_num_rows($result);
$table = <<<ENDHTML
<div style="text-align: center;">
<h2>Movie Review Database</h2>
<table border="1" cellpadding="2" cellspacing="2"
style="width: 70%; margin-left: auto; margin-right: auto;">
<tr>
<th>Movie Title</th>
<th>Year of Release</th>
<th>Movie Director</th>
<th>Movie Lead Actor</th>
<th>Movie Type</th>
</tr>
ENDHTML;
// loop through the results
while ($row = mysql_fetch_assoc($result)) {
extract($row);
$director = get_director($movie_director);
$leadactor = get_leadactor($movie_leadactor);
$movietype = get_movietype($movie_type);
$table .= <<<ENDHTML
<tr>
<td>$movie_name</td>
<td>$movie_year</td>
<td>$director</td>
<td>$leadactor</td>
<td>$movietype</td>
</tr>
ENDHTML;
}
$table .= <<<ENDHTML
</table>
<p>$num_movies Movies</p>
</div>
ENDHTML;
echo $table;
?>
when I ran the code this time, the table header shows but part of the code is also displayed on the browser. It looks like this:
ENDHTML; // loop through the results while ( = mysql_fetch_assoc(Resource id #3)) { extract(); = get_director(); = get_leadactor(); = get_movietype(); .= << ENDHTML; } .= <<
any help will be appreciated I am new to programming thanks
When you end an heredoc you must not put any char at the begining of the line. In your code there are heredocs with spaces or tabs before them. Delete the spaces and put your heredoc at the begining of the line.
More info on heredoc.
Closing heredoc statement must be at the very first position in the string:
ENDHTML; // works
ENDHTML; // won’t work
Related
I created a table which is updated through a form and each row gets assigned a specific number.
When viewing this table, I want to click on that assigned number and get a page where all the details of that row are displayed.
If I do $sql = "SELECT * FROM clients WHERE nif_id='114522';"; - where the nif_id is the assigned number - I get the values for that number, but I need it to change with every number in the table.
Any ideas?
UPDATE
This is the table code:
<div class="card card-body">
<table class="table">
<thead>
<tr>
<th>NIF</th>
<th>Nome</th>
<th>Apelido</th>
<th>Telemóvel</th>
<th>E-mail</th>
</tr>
</thead>
<tbody>
<?php
include_once '../includes/db.inc.php';
$sql = "SELECT * FROM clients ORDER BY nif_id ASC;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$first = $row["prm_nome"];
$last = $row["apelido"];
$phone = $row['nmr_tlm'];
$email = $row['mail'];
$nif = $row['nif_id'];
echo '<tr>';
echo '<td>'.$nif.'</td>';
echo '<td>'.$first.'</td>';
echo '<td>'.$last.'</td>';
echo '<td>'.$phone.'</td>';
echo '<td>'.$email.'</td>';
echo '</tr>';
}
}
?>
</tbody>
</table>
</div>
You can use the get request parameters.
ex: www.myapp.com/table?id=3920393
add functionality in your PHP file as follows
if(isset($_GET["id"])){
$id = $_GET["id"];
$sql = "SELECT * FROM clients WHERE nif_id='".$id."';";
//make db call & display HTML
}
This is a very simple implementation and does not implement any security or SQL injection security. This was more of a conceptual answer as to how you can tackle your problem.
This is quite a common scenario for web-based systems.
<div class="card card-body">
<table class="table">
<thead>
<tr>
<th>NIF</th>
<th>Nome</th>
<th>Apelido</th>
<th>Telemóvel</th>
<th>E-mail</th>
</tr>
</thead>
<tbody>
<?php
include_once '../includes/db.inc.php';
$sql = "SELECT * FROM clients ORDER BY nif_id ASC;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$first = $row["prm_nome"];
$last = $row["apelido"];
$phone = $row['nmr_tlm'];
$email = $row['mail'];
$nif = $row['nif_id'];
echo '<tr>';
echo '<td>'.$nif.'</td>';
echo '<td>'.$first.'</td>';
echo '<td>'.$last.'</td>';
echo '<td>'.$phone.'</td>';
echo '<td>'.$email.'</td>';
echo '</tr>';
}
}
?>
</tbody>
</table>
</div>
where the detail.php is another page to query specific details regarding the query nifid.
As a reminder, if the data type of the column is INT, there is no need to use single quotes to surround the value in the SQL statement.
Sample detail.php:
<?php
if(!isset($_GET['nifid']) || (int)$_GET['nifid'] <= 0) {
// Invalid or missing NIFID
header('Location: table.php');
}
include_once '../includes/db.inc.php';
$id = (int)$_GET['nifid'];
$sql = "SELECT * FROM clients WHERE nif_id=$id";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
// TODO: display the result in whatever way you like
?>
Firstly, the headings are stored in h1 tags. This is taken from a separate table named "menu_type". Which is linked through a "menu" table.
I am trying to display data on the base like this:
HEADING
Table Data
2nd Heading
Second Data
--- In a loop until it is all completed ---
Here is a like page of what it is doing
I believe I have the methods correct and can see what it is doing, it is printing the first heading, then a blank table, then the second heading and then the data from the first table.
See my code:
<?php
$query = "SELECT * FROM menu_type";
$result = mysqli_query($connect, $query);
$result_array = array();
$numRows = mysqli_num_rows($result); // returns the num of rows from the query above, allowing for dynamic returns
while($row = mysqli_fetch_assoc($result)){
$menuType = $row['type'];
$result_array[] = $menuType; // This array holds each of the menu_types from DB
}
$countArray = count($result_array);
for($i = 0; $i < $numRows; $i++){
$query = "SELECT * FROM menu WHERE type_id='$result_array[$i]'";
$result = mysqli_query($connect, $query) or die(mysqli_error($connect));
echo "
<div id='hide'>
<h1 id='wines' class='head-font text-center head'>$result_array[$i]</h1>
<table class='table table-hover table-responsive'>
<thead>
<tr>
<th>
Item
</th>
<th class='text-right'>
Price
</th>
</tr>
</thead>
<tbody>
<tr>
";
$menuQuery = "SELECT * FROM menu, menu_type WHERE type_id='$i' AND menu.type_id = menu_type.id";
$menuResult = mysqli_query($connect, $menuQuery) or die(mysqli_error($connect));
while ($row = mysqli_fetch_assoc($menuResult)) {
$name = $row['name'];
$description = $row['description'];
$price = $row['price'];
echo "
<td>$name - <small>$description</small></td>
<td class='text-right'>£$price </td>
";
}
echo
"
</tr>
</tbody>
</table>
";
}
// print_r($result_array[2]);
?>
You don't need these anymore, it's like you're repeating the query. It looks incorrect also.
$menuQuery = "SELECT * FROM menu, menu_type WHERE type_id='$i' AND menu.type_id = menu_type.id";
$menuResult = mysqli_query($connect, $menuQuery) or die(mysqli_error($connect));
The menu items are already in this query, you just have to loop through it;
$query = "SELECT * FROM menu WHERE type_id='$result_array[$i]'";
$result = mysqli_query($connect, $query) or die(mysqli_error($connect));
UPDATE 1: this code is incorrect, it doesn't insert the value to the array. I updated the code (after "try this").
$result_array[] = $menuType;
UPDATE 2: the $result is repeatedly used in mysqli functions, the index is being moved. What I did is copied the initial $result to $resultCopy. Try code again, haha
Use array_push($array,$value_you_insert) function, for inserting elements to an array.
Try this;
<?php
$query = "SELECT * FROM menu_type";
$result = mysqli_query($connect, $query);
$resultCopy = $result;
$result_array = array();
$numRows = mysqli_num_rows($result); // returns the num of rows from the query above, allowing for dynamic returns
while($row = mysqli_fetch_assoc($resultCopy)){
$menuType = $row['type'];
array_push($result_array,$menuType);
}
for($i = 0; $i < $numRows; $i++){
echo "
<div id='hide'>
<h1 id='wines' class='head-font text-center head'>".$result_array[$i]."</h1>
<table class='table table-hover table-responsive'>
<thead>
<tr>
<th>Item</th>
<th class='text-right'>Price</th>
</tr>
</thead>
<tbody>
";
$query = "SELECT * FROM menu WHERE type_id='$result_array[$i]'";
$result = mysqli_query($connect, $query) or die(mysqli_error($connect));
while ($row = mysqli_fetch_assoc($result)) {
$name = $row['name'];
$description = $row['description'];
$price = $row['price'];
echo"
<tr>
<td>".$name." - <small>".$description."</small></td>
<td class='text-right'>£".$price."</td>
</tr>
";
}
echo
"
</tbody>
</table>
";
}
?>
enter image description herei am working on project CMS with php and one of my while loops doesn't work and i cant find why.
i am echo on (td) inside of loop and nothing showed on the page but when i echo outside of while loop it work very well.
i have commentet the loop to see you.
Can you give me some help where i have the problem?
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Id</th>
<th>Author</th>
<th>Comment</th>
<th>Email</th>
<th>Status</th>
<th>In Response to</th>
<th>Date</th>
<th>Approve</th>
<th>Unapprove</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT * FROM comments ";
$select_comments = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_comments)) {
$comment_id = $row['comment_id'];
$comment_post_id = $row['comment_post_id'];
$comment_author = $row['comment_author'];
$comment_content = $row['comment_content'];
$comment_email = $row['comment_email'];
$comment_status = $row['comment_status'];
$comment_date = $row['comment_date'];
echo "<tr>";
echo "<td>$comment_id</td>";
echo "<td>$comment_author</td>";
echo "<td>$comment_content</td>";
/
echo "<td>$comment_email</td>";
echo "<td>$comment_status</td>";
//THIS IS THE LOOP DOESN'T WORK
$query = "SELECT * FROM posts WHERE post_id = $comment_post_id";
$select_post_id_query = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_post_id_query)) {
$post_id = $row['post_id'];
$post_title = $row['post_title'];
echo "<td><a href='../post.php?p_id=$post_id'>$post_title</a></td>";
}
echo "<td>$comment_date</td>";
echo "<td><a href='comment.php?approve=$comment_id'>Approve</a></td>";
echo "<td><a href='comment.php?unapprove=$comment_id'>Unapprove</a></td>";
echo "<td><a href='comment.php?delete=$comment_id'>Delete</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
<?php
//approve posts
if(isset($_GET['approve'])){
$the_comment_id = $_GET['approve'];
$query = "UPDATE comments SET comment_status = 'approved' WHERE comment_id = $the_comment_id ";
$approve_comment_query = mysqli_query($connection, $query);
header("Location: comment.php");
}
//unapprove posts
if(isset($_GET['unapprove'])){
$the_comment_id = $_GET['unapprove'];
$query = "UPDATE comments SET comment_status = 'unapproved' WHERE comment_id = $the_comment_id ";
$unapprove_comment_query = mysqli_query($connection, $query);
header("Location: comment.php");
}
//delete posts
if(isset($_GET['delete'])){
$the_comment_id = $_GET['delete'];
$query = "DELETE FROM comments WHERE comment_id = {$the_comment_id} ";
$delete_query = mysqli_query($connection, $query);
header("Location: comment.php");
}
?>
You are overwriting variable $row in your second loop. You should change it eg. to $subRow to avoid such situation.
i have find the missing part on of my db with the connection.
THNX all you friends :D
Here's the PHP files in my project. I used a href for 'get movie details' as per that it goes to another page and shows the results.
<a href = "movie_details.php?movie_id=$movie_id" ...
I need to get those details with ajax request and render response in same page (better if it in a inside a div).
table1.php
<?php
$link = mysql_connect("localhost","root","") or die(mysql_error());
mysql_selectdb("MovieSite") or die(mysql_error());
$query = "SELECT movie_id, movie_name, movie_director, movie_leadactor FROM Movie ";
//"WHERE movie_year > 1990 ORDER BY movie_type";
$result = mysql_query($query, $link) or die(mysql_error());
$num_movies = mysql_num_rows($result);
$movie_header = <<<EOD
<h2><center>Movie Review Database</center></h2>
<table width = "70%" border = "1" cellpadding = "2" cellspacing = "2" align = "center">
<tr>
<th>Movie Title</th>
<th>Movie Director </th>
<th>Movie Lead Actor</th>
</tr>
EOD;
function get_director(){
global $movie_director;
global $director;
$query_d = "SELECT people_fullname FROM people WHERE people_id = '$movie_director'";
$results_d = mysql_query($query_d) or die(mysql_error());
$row_d = mysql_fetch_array($results_d);
extract($row_d);
$director = $people_fullname;
}
function get_leaderactor(){
global $movie_leadactor;
global $leadactor;
$query_l = "SELECT people_fullname FROM people WHERE people_id = '$movie_leadactor'";
$result_l = mysql_query($query_l);
$row_l = mysql_fetch_array($result_l);
extract($row_l);
$leadactor = $people_fullname;
}
$movie_details = '';
while ($row = mysql_fetch_array($result)){
$movie_id = $row['movie_id'];
$movie_name = $row['movie_name'];
$movie_director = $row['movie_director'];
$movie_leadactor = $row['movie_leadactor'];
get_director();
get_leaderactor();
$movie_details .= <<<EOD
<tr>
<td>$movie_name</td>
<td>$director</td>
<td>$leadactor</td>
</tr>
EOD;
}
$movie_details .= <<<EOD
<tr>
<td>Total : $num_movies Movies </td>
</tr>
EOD;
$movie_footer = "</table>";
$movie = <<< MOVIE
$movie_header;
$movie_details;
$movie_footer;
MOVIE;
echo $movie;
?>
movie_details.php
<?php
$link = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db('MovieSite') or die("DB Select" . mysql_error());
function calculate_differences($takings, $cost){
$difference = $takings - $cost;
if ($difference < 0){
$difference = substr($difference, 1);
$font_color = 'red';
$profit_or_loss = "Rs. " . $difference . "M";
}elseif ($difference > 0){
$font_color = 'green';
$profit_or_loss = "Rs. " . $difference . "M";
}else {
$font_color = 'blue';
$profit_or_loss = "Broke even";
}
return "<font color = \"$font_color\"> ". $profit_or_loss . "</font>";
}
function get_director(){
global $movie_director;
global $director;
$query_d = "SELECT people_fullname FROM people WHERE people_id = '$movie_director'";
$results_d = mysql_query($query_d) or die(mysql_error());
$row_d = mysql_fetch_array($results_d);
extract($row_d);
$director = $people_fullname;
}
function get_leaderactor(){
global $movie_leadactor;
global $leadactor;
$query_l = "SELECT people_fullname FROM people WHERE people_id = '$movie_leadactor'";
$result_l = mysql_query($query_l);
$row_l = mysql_fetch_array($result_l);
extract($row_l);
$leadactor = $people_fullname;
}
$movie_query = "SELECT * FROM Movie WHERE movie_id = '" . $_GET['movie_id'] . "'";
$result = mysql_query($movie_query, $link) or die(mysql_error());
$movie_header = <<<EOD
<h2><center>Movie Review Database</center></h2>
EOD;
while ($row = mysql_fetch_array($result)){
//$movie_id = $row['movie_id'];
$movie_name = $row['movie_name'];
$movie_director = $row['movie_director'];
$movie_leadactor = $row['movie_leadactor'];
$movie_year = $row['movie_year'];
$movie_running_time = $row['movie_running_time'] . "Mins";
$movie_takings = $row['movie_taking'];
$movie_cost = $row['movie_cost'];
get_director();
get_leaderactor();
}
$movie_health = calculate_differences($movie_takings, $movie_cost);
$page_start = <<<EOD
<html>
<head>
<title>Details and Review for: $movie_name </title>
</head>
<body>
EOD;
$movie_table_headings =<<<EOD
<tr>
<th>Movie Title</th>
<th>Year of Release</th>
<th>Movie Director </th>
<th>Movie Lead Actor</th>
<th>Movie running Time</th>
<th>Movie Health</th>
</tr>
EOD;
$movie_details = <<<EOD
<table width = "70%" border = "1" cellpadding = "2" cellspacing = "2" align = "center">
<tr>
<th colspan = "6"><u><h2>$movie_name: details</h2></u></th>
</tr>
$movie_table_headings
<tr>
<td width = "33%" align = "center">$movie_name</td>
<td align = "center">$movie_year</td>
<td align = "center">$director</td>
<td align = "center">$leadactor</td>
<td align = "center">$movie_running_time</td>
<td align = "center">$movie_health</td>
</tr>
</table>
<br /><br />
EOD;
$page_end = <<<EOD
Home
</body>
</html>
EOD;
$movie = <<< MOVIE
$page_start;
$movie_details;
$page_end;
MOVIE;
echo $movie;
mysql_close();
AJAX works by allowing you to retrieve the contents of a page using clientside code (e.g. , javascript/jQuery) without making the user leave the current page.
When you make an ajax request, you can specify parameters to send via GET or POST (or not send any parameters at all). Your code will then receive the content of the page as if you had visited it with your browser (what you would get if you went to the page, right-clicked and viewed source).
So what you would want to do with your PHP is to output the values that you need on your current page. It is common practice to encode this data using JSON or XML (which is the X in ajax), so that your clientside code can read it more easily. (I personally prefer JSON).
Learn jQuery: http://w3schools.com/jquery/default.asp
Learn about AJAX: http://w3schools.com/ajax/default.asp
Learn about Ajax with jQuery: http://api.jquery.com/jQuery.ajax/
or http://api.jquery.com/jQuery.get/
or http://api.jquery.com/jQuery.post/
Let me know if that answers your question..
<?php
if (isset($_GET['flyerID']))
$FlyerID = $_GET['flyerID'];
$DBConnect = #mysqli_connect("host", "UN", "pword")
Or die("<p>Unable to connect to the datbase server.</p>" . "<p>Error Code ".mysqli_connect_errno().": ".mysqli_connect_error()) . "</p>";
$DBName = "agentsleuthdb";
#mysqli_select_db($DBConnect, $DBName)
Or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) ."</p>";
$TableName = "FEEDBACK";
$SQLstring = "SELECT * FROM $TableName order by FIRSTNAME";
$QueryResult = #mysqli_query ($DBConnect, $SQLstring)
Or die("<p> Unable to exequte Select query.</p>"."<p>Error Code ".mysqli_errno($DBConnect) .": ".mysqli_error
($DBConnect))."</p>";
if (mysqli_num_rows($QueryResult) == 0){
exit("<p>There is no feedback</p>");
}
?>
<table border="1">
<tr>
<th width = "15%">First Name </th>
<th width = "15%">Last Name </th>
<th width = "15%">Email Addr </th>
<th width = "15%">Company </th>
<th width = "40%">Feedback </th>
</tr>
<?php
$Row = mysqli_fetch_row($QueryResult);
do {
echo "<tr><td>{$Row[0]}</td>";
echo "<td>{$Row[1]}</td>";
echo "<td>{$Row[2]}</td>";
echo "<td>{$Row[3]}</td>";
echo "<td>{$Row[4]}</td></tr>";
$Row = mysqli_fetch_assoc($QueryResult);
} while ($Row);
mysqli_free_result($QueryResult);
mysqli_close($DBConnect);
?>
It only returns one row.. how can I return all entries?
Have you tried
while ($Row = mysqli_fetch_row($QueryResult))
Description here
or
while ($Row = mysqli_fetch_array($QueryResult, MYSQL_ASSOC))
Description here
Hope this helps.
In your code, only the first time you call mysqli_fetch_row, which makes an $Row an indexed array.
This is why you see output when you access the content of $Row with an index ($Row[0], $Row[1], etc..).
Afterwards, you mysqli_fetch_assoc which turns $Row in an associative array, thus accessing $Row with an index for your output doesn't work anymore.
Replace your do ... while loop by the first while loop aforloney suggested.