Привет Марк, надеюсь, ты получаешь массу удовольствия от программирования. Позвольте мне помочь вам с этим. Если вы скопируете и вставите это в file.php
и вставите его в xampp
htdocs
с именем index.php
, вы будете настроены менее чем за 5 минут.
<?php
//
/*FIRST YOU NEED TO CONNECT TO YOUR DATABASE
YOU WILL NEED TO REPLACE SOME VALUES, [dbname], [user], [pass] if you are using xampp localhost will be fine if you are using another server manager then use the name that you use to access your data base.*/
$conn = new PDO("mysql:dbname=dbname;host=localhost;charset=utf8", 'user', 'pass');
/*
In the line below we do 2 things first we create a variable called $stm (is a short for statement) and then we use a PDO method (is just a function inside a class and a class is a collection of usefull functions).
and second we place a query inside the method between quotes '' or ""
*/
//Sorting is done with the ORDER BY followed by the rows you want to sort.
//ASC is for ascending and DESC is for descending sorting
$stm = $conn->prepare('SELECT * FROM table ORDER BY rw1, rw2, rw3, rw4 ASC');
/*THEN WE WILL EXECUTE THE MYSQL QUERY TO GET THE RESULTS*/
$stm->execute();
//PACK THIS IN A NICE ARRAY
$results = (array)$stm->fetchAll();
?>
<!-- AFTER THE ?> THIS SECTION IS HTML -->
<!-- NOW WE TAKE THE ARRAY AND ONE BY ONE WE CAN PRINT IT IN A UL OR A DIV JUST CHANGE THE HTML TAGS AND YOU'LL BE SET, IF YOU JUST PAST THIS IN A PHP AND REPLACE THE INFO YOU SHOULD GET EVERYTHING UP AND RUNNING IN LES THAN 3 MINUTES-->
<ul>
<?php foreach($results as $result): //this is php embedded inline ?>
<li>
<!-- THEN HERE WE PRINT THEM ONE BY ONE -->
<?php echo "{$result['uid']}, {$result['rw1']}, {$result['rw1']}, {$result['rw2']}, {$result['rw3']}, {$result['rw4']}"; //this is php embedded inline?>
</li>
<?php endforeach; //this is php embedded inline ?>
</ul>