-2

Im newbie in programmin I want Check if the 2 parameter are correct and display the data

www.site.com/?param1=123&param2=444 <--- check if param1 and param2 are match and display the account.

On the database it has two same param2 and but different param1.

param1 | param2

123 444 First 122 444 Second

I want to display only the first

$param1 = $_GET['param1'];
$param2 = $_GET['param2'];

$result = mysqli_query($con,"SELECT * FROM tests");

if (mysqli_num_rows($result) > 0) {

while($row = mysqli_fetch_array($result)) {

}

}


if ( $param1 ==($param2)){

    echo "Display the data all the of first";

}

else{

    echo "incorrect parameter;";
}
codedge
  • 4,754
  • 2
  • 22
  • 38
maximos
  • 1
  • 1
  • you want to display only the first row from select query? – Slava May 03 '20 at 13:16
  • This is an example of how to deal with parameters: https://stackoverflow.com/questions/728229/parameters-in-mysqli – Luuk May 03 '20 at 13:20

1 Answers1

0

Try mysqli_fetch_all instead of mysqli_fetch_array in cycle: $rows = mysqli_fetch_all($result, MYSQLI_ASSOC);.

And then choose needed row to show (if it exists): if (isset($rows[0])) { // your code to show }.

Slava
  • 878
  • 5
  • 8