MySQL数据库PHP特定行

My current code is this:

   <?php
$con=mysqli_connect("stevie.heliohost.org","rbxdataa_Art","mydata123art");
if (mysqli_connect_errno()) {
    printf("Connect failed: %s
", mysqli_connect_error());
    exit();
}


mysqli_select_db($con, "rbxdataa_Data");
$Amount=$_GET["Amount"];
$GetType=$_GET["Type"];
$sql = "SELECT * FROM EventRecord WHERE EventType='$GetType' ORDER BY EventId DESC";
$sql_run = mysqli_query($con, $sql);
while($sql_row = mysqli_fetch_assoc($sql_run)){
   echo $sql_row['EventId'].'<br>';
}
mysqli_close($con);
?>

As I am currently very new to PHP and MySQL, I have no idea why this code will not work. I am also confused as to how I would make it echo only the top ($Amount) as determined by how large the "EventId" value is. My intent is to gather the [$Amount] highest rows in the table with the EventType $GetType. I am aware of SQL Injection vulnerability, however for my purposes this does not affect me. Error: "Parse error: syntax error, unexpected T_STRING on line 4"

As I see, you have a normal code, may be you have no any rows in DataBase with requested EventType ?

At second: you have SQL Injection vulnerability. Use PDO and Prepared Statements instead your mysqli_query code.

If you want to get the row with the max eventid, you need do this:

$sql = "SELECT MAX(EventId)  FROM EventRecord WHERE EventType='$GetType';

is not necessary order by eventid when u can get the max using MAX(An AGGREGATION FUNCTION)

P.D: you can add more attributes in select statement.

Try this if you need highest amount with EventType.

$sql = "SELECT MAX(amount_field) FROM EventRecord WHERE EventType='$GetType';

If you want record sorted based on amount from highest to lowest then order by amount desc. (if you have amount column in table)

<?php
$con=mysqli_connect("Removed for Privacy");
mysqli_select_db($con, "Removed") or die(mysqli_error());

$Amount=$_GET["Amount"];
$GetType=$_GET["Type"];
$sql = "SELECT * FROM EventRecord WHERE EventType='$GetType' ORDER BY amount DESC";
$sql_run = mysqli_query($con, $sql);
while($sql_row = mysqli_fetch_assoc($sql_run)){
   echo $sql_row['EventId'].'<br>';
}
mysqli_close($con);
?>