mysql - How to Pass two values to another php page using anchor tag?

I'm trying to pass the value of seller_id and also order_datetime to report-summary.php. But how can i do that? I tried the codes below but all i got us the error ofarray to string conversion
error. Can anyone help me solve this? It would be better if you guys can show me examples of code on how to solve this. Thank you so much in advance any help will be appreciated!
<div class="col-3 my-auto">
<?php
$sql = "SELECT *, SUM(purchase_price) as purchase_price FROM ordered_items
INNER JOIN sellers ON ordered_items.seller_id = sellers.id
WHERE MONTH(order_datetime) = MONTH(NOW()) GROUP BY ordered_items.seller_id";
$query = $conn->query($sql);
$row = $query ->fetch_assoc();
$id=['seller_id'];
$month=['order_datetime'];
?>
<a href="report-summary.php?sellerid=<?php echo $id;?>&month=<?php echo $month;?>">
<button type="button" class="btn btn-info" style="height:34px; padding-left:10px;">
<i class="fa fa-file-excel-o"></i> Export Report Summary
</button>
</a>
</div>
</div>
</div>
Answer
Solution:
The error is caused by:
$id=['seller_id'];
$month=['order_datetime'];
$id and $month are actually 2 arrays containing the strings 'seller_id' and 'order_datetime', and you're trying to print them.
If you want to access to your data collection (extracted from the query), you have to iterate your results and then access the single field.
To do this, you have to iterate your $row. So, it will be something like:
while($row = $result->fetch_assoc()) {
echo 'id: ' . $row['seller_id'] . 'month: ' . $row['order_datetime'];
}
If $result has only one result, you can access to data without iterate through $row. So, it will be:
$id = $row['seller_id'];
$month = $row['order_datetime'];
Hope that this will help you!
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.