Jump to content

Mai Multe Variabile In Mysqli_Fetch_Array


Andrei Manolache

Recommended Posts

<?php
    $con=mysqli_connect("xxxxx","xxxxx","xxxxxx","xxxxx");
            // Check connection
            if (mysqli_connect_errno()) {
             echo "Nu s-a putut realiza conectiunea cu baza de date MySQL: " . mysqli_connect_error();
            }

            $imobilizari_corporale = mysqli_query($con,"SELECT SUM(suma) AS `total_imob_corporale` FROM `2014` WHERE subcat='imobilizari_corporale'");            
            $credite_tl = mysqli_query($con,"SELECT SUM(suma) AS `total_credite_tl` FROM `2014` WHERE subcat='credite_tl'");            

$HTML = "<table>";

while($row = mysqli_fetch_array($imobilizari_corporale)) <-- !!As vrea sa adaug aici mai multe variabile (cu ar fi $credite_tl).Nu merge prin simpla adaugare cu virgula.
{
    $HTML .= <<<HTML
        <tr>
        <td>Imobilizari Corporale</td>
        <td>{$row['total_imob_corporale']}</td>
        <td>{$row['total_credite_tl']}</td>
        </tr>
HTML;
}

$HTML .= "</table>";

echo $HTML;

mysqli_close($con);
        ?>

Ma poate ajuta cineva?

Link to comment
Share on other sites

  • Moderators

Nu ar fi mai usor sa adaugi tot selectul in acelasi query?

$variabilaQuery = mysqli_query($con,"SELECT SUM(suma) AS `total_imob_corporale`, SUM(suma) AS `total_credite_tl` FROM `2014` WHERE subcat = 'imobilizari_corporale' AND subcat = 'credite_tl");

Daca nu ma insel ar trebui sa mearga, poate am gresit pe undeva la scris. Poate altcineva stie mai bine, in momentul actual nici eu nu stau foarte bine cu treaba ce tine de mysqli_fetch_array

 

Daca ai ceva cunostinte de engleza poti cauta pe stackoverflow sau chiar sa intrebi, is persoane acolo care se ocupa zilnic cu lucruri de genul si cu experienta mare.

PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.