English 中文(简体)
用户清单
原标题:List Users with PHP / HTML / Mysql Database

试图用我的用户信息编制一个私人网站清单。

But im having problems doing that.. I need my website list members by ID from database with this informations

id database reference (Hided) - name - DiscordID - ShipID - Email

And i need this div : <div class="home-barra"> USER INFO </div> got copied and paste all time when retrieve new users.

仍然学习 php编码

<?php

session_start();

if (!isset($_SESSION[ loggedin ])) {
    header( Location: index.html );
    exit;
}
$DATABASE_HOST =  localhost ;
$DATABASE_USER =  webaccount ;
$DATABASE_PASS =  *********** ;
$DATABASE_NAME =  mydatabase ;
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if (mysqli_connect_errno()) {
    exit( Failed to connect to MySQL:   . mysqli_connect_error());
}

$stmt = $con->prepare( SELECT password, email, steamid, discordid FROM accounts WHERE id = ? );

$stmt->bind_param( i , $_SESSION[ id ]);
$stmt->execute();
$stmt->bind_result($password, $email, $steamid, $discordid);
$stmt->fetch();
$stmt->close();


?>
       <div class="home-container07">

<-- This need to be copied

            <div class="home-barra">
              <div class="home-container08">
                <span class="home-text07">Nome: <?=$username?></span>
              </div>
              <div class="home-container09">
                <span class="home-text08">Discord: <?=$discordid?></span>
              </div>
              <div class="home-container10">
                <span class="home-text09">SteamID64: <?=$steamid?></span>
              </div>
              <div class="home-container11">
                <span class="home-text10">Email: <?=$email?></span>
              </div>
            </div>
---->

          </div>
问题回答

Problem Solved, thanks Barman! Can be closed!

我在我的《加拿大刑法》中增加了一个问题。

$query = "SELECT id, username, discordid, steamid, email FROM accounts";
$result = mysqli_query($con, $query);

$users = array();

if ($result) {
    while ($row = mysqli_fetch_assoc($result)) {
        $users[] = $row;
    }
    mysqli_free_result($result);
}

mysqli_close($con);

此前,我曾编辑过我的《html法典》,如:

<?php foreach ($users as $user): ?>
        <div class="home-barra">
            <div class="home-container08">
                <span class="home-text07">Nome: <?php echo $user[ username ]; ?></span>
            </div>
            <div class="home-container09">
                <span class="home-text08">DiscordID: <?php echo $user[ discordid ]; ?></span>
            </div>
            <div class="home-container10">
                <span class="home-text09">SteamID64: <?php echo $user[ steamid ]; ?></span>
            </div>
            <div class="home-container11">
                <span class="home-text10">Email: <?php echo $user[ email ]; ?></span>
            </div>
        </div>
    <?php endforeach; ?>

Seems fetch有不同的工作方式。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签