0
Well, I’ve got a flea here behind my ear and I’m having trouble solving the following problem:
$select = $mysqli->query("SELECT * FROM payments WHERE client_email='$xemail'");
$row = $select->num_rows;
$linhas = 0;
while($linhas < $row) {
$get = $select->fetch_array();
$top_1 = $get[0];
$top_2 = $get[1];
$top_3 = $get[2];
$top_4 = $get[3];
$top_5 = $get[4];
$top_6 = $get[5];
$top_7 = $get[6];
$top_8 = $get[7];
$top_9 = $get[8];
$top_10 = $get[9];
$top_11= $get[10];
$top_12 = $get[11];
$linhas++;
}
echo '<div id="transaction_id">'.$top_2.'</div>';
echo '<div id="client_email">'.$top_3.'</div>';
echo '<div id="payment_method">'.$top_4.'</div>';
echo '<div id="payment_method_transaction">'.$top_5.'</div>';
echo '<div id="transaction_status">'.$top_6.'</div>';
echo '<div id="transaction_date">'.$top_7.'</div>';
echo '<div id="transaction_date_last">'.$top_8.'</div>';
echo '<div id="product">'.$top_9.'</div>';
echo '<div id="product_value">'.$top_10.'</div>';
echo '<div id="client_name">'.$top_11.'</div>';
echo '<div id="status">'.$top_12.'</div>';
Basically this will take all the purchases made for that customer’s email. But the problem is that the variables could not be called $top_1, they should receive an additional number each time the loop repeated, after top_12 and went back to top_1, instead of top_1 was top_13 and so on... and give an echo in the variable to be able to catch it in CSS... I don’t even know if this title would be ideal, but I searched for it in Google and I didn’t find anything, I honestly didn’t even know how to research this problem... :(
What I want to do is take all the shopping data and display it on a page to the customer. The system will read about 5 records and then it will display page 2, and so on... I don’t even know if this script is the best way to do it rs... but it was the one I tested and it worked. Can you create these variables with different names as the loop repeats? Is there a better way to do this?
Brother, I think you have confused, functions mysqli_ with mysql_ . As far as I know there are not yet, contrasts regarding the functions mysqli_.
– MagicHat
And, I was going to say the same, I think he got confused... mysql and mysqli are different, mysql has been deprecated and no more updates, mysqli remains normal... so much so that in his reference explains exactly this, mysql has been deprecated, and now the correct use would be mysqli
– Raizant
But I like this foreach, I don’t know much about programming... so I’ll take a look at it soon. While I wait to see if there are any more answers.
– Raizant
You can use the aproach you think best with mysql. My solution is this =]
– Guerra