Bank query for another variable

Asked

Viewed 45 times

2

I have the following scenario, I perform a query to the bank and return all data:

<?php
include ("conectar.php");
$query = "SELECT * FROM pontos ORDER by pontos DESC LIMIT 0,10";

if ($result = mysqli_query($link, $query)) {

    $lista = 0;
    while ($row = mysqli_fetch_row($result)) {

        $lista++;
?>

Then I need to print a table with the academic number and points,

        <td align="center"><?php echo $row[0];?></td>
        <td align="center"><?php echo $row[1];?></td> 

Until then ok, the point is that I needed to get the values of

$row[0]

And move to another variable, which will be used to consult a webservice.

$user1->value = 'row[0]';

I can only pass a value from an input, and I needed the values to come directly from the first column of the bank, someone has an idea of how to do this?

$user2->value = $_POST["username"];
  • This variable you need to load, is in another php file?

  • @Luishenrique in the same file.

  • What’s in the var_dump() of $row[0]?

  • 1

    Why can’t you do it $user1->value = $row[0];?

  • @Luishenrique, forgive me for being layman in the language, I did the same thing but had put in quotes, now without working out, very grateful.

  • No problem. I put an answer with this, I thought there was some reason not to assign direct.

Show 1 more comment

1 answer

1


Simply assign the value directly to the desired variable during the loop.

<?php
include ("conectar.php");
$query = "SELECT * FROM pontos ORDER by pontos DESC LIMIT 0,10";

if ($result = mysqli_query($link, $query)) {

    $lista = 0;
    while ($row = mysqli_fetch_row($result)) {
        $user1->value = $row[0];
        $lista++;
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.