- Posts: 115
- Thank you received: 0
database query of a booking with image upload field
- reilldesign
- Topic Author
- Offline
- Premium Member
-
Less
More
2 years 6 months ago #153270
by reilldesign
database query of a booking with image upload field was created by reilldesign
Hi Mr. Dam,
I am trying to implement a database query of a booking. I have already found two working $queries which work independently. Is there a way to connect them and replace the hardcoded number '17' in the second $query with the 'a.order_id'? At the end I want to output the values (see example).
I would be very grateful for any help.
Many thanks and greetings
Peter
I am trying to implement a database query of a booking. I have already found two working $queries which work independently. Is there a way to connect them and replace the hardcoded number '17' in the second $query with the 'a.order_id'? At the end I want to output the values (see example).
I would be very grateful for any help.
Many thanks and greetings
Peter
Code:
$db = JFactory::getDbo();
$query = "Select a.* from #__app_sch_order_items as a"
." inner join #__app_sch_orders as b on b.id = a.order_id"
." where b.order_status = 'A'";
$query = "Select c.*,d.fvalue from #__app_sch_fields as c inner join #__app_sch_field_data as d on d.fid = c.id where d.order_id = '17'";
$db->setQuery($query);
$rows = $db->loadObjectList();
if(count($rows) > 0){
for($i=0;$i<count($rows);$i++){
$row = $rows[$i];
echo $row->id . '<br />';
echo $row->order_name . '<br />';
echo $row->order_notes . '<br />';
echo $row->booking_date . '<br />';
echo $row->start_time . '<br />';
echo '<img src="' . Uri::root() . 'images/' . $folder . '/fields/' . $row->fvalue . '">' . '<br />';
}
}
Please Log in or Create an account to join the conversation.
- reilldesign
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 115
- Thank you received: 0
2 years 6 months ago #153325
by reilldesign
Replied by reilldesign on topic database query of a booking with image upload field
Hi Mr. Dam,
despite further attempts i have not found a solution to my problem. i would be very grateful if you could support me.
I need these values of a booking
id
order_name
order_notes
booking_date
start_time
fvalue
so that I can output it with the following code
despite further attempts i have not found a solution to my problem. i would be very grateful if you could support me.
I need these values of a booking
id
order_name
order_notes
booking_date
start_time
fvalue
so that I can output it with the following code
Code:
$db->setQuery($query);
$rows = $db->loadObjectList();
if(count($rows) > 0){
for($i=0;$i<count($rows);$i++){
$row = $rows[$i];
echo $row->id . '<br />';
echo $row->order_name . '<br />';
echo $row->order_notes . '<br />';
echo $row->booking_date . '<br />';
echo $row->start_time . '<br />';
echo '<img src="' . Uri::root() . 'images/' . $folder . '/fields/' . $row->fvalue . '">' . '<br />';
}
}
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 12960
- Thank you received: 1679
2 years 6 months ago #153326
by Mr. Dam
Replied by Mr. Dam on topic database query of a booking with image upload field
Hi,
Your query is messy, you want to retrieve data of order with ID #17 and value of Image custom field of that order, right?
Thanks
Dam
Your query is messy, you want to retrieve data of order with ID #17 and value of Image custom field of that order, right?
Thanks
Dam
Please Log in or Create an account to join the conversation.
- reilldesign
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 115
- Thank you received: 0
2 years 6 months ago #153331
by reilldesign
Replied by reilldesign on topic database query of a booking with image upload field
Hi,
yes. First I want to check if order status is 'A' and then i need to get those values:
order_name
order_notes
booking_date
start_time
fvalue
yes. First I want to check if order status is 'A' and then i need to get those values:
order_name
order_notes
booking_date
start_time
fvalue
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 12960
- Thank you received: 1679
2 years 6 months ago #153345
by Mr. Dam
Replied by Mr. Dam on topic database query of a booking with image upload field
Hi,
But for order ID #17 or field ID #17? If the order ID is 17, we will have just one reservation while field ID is 17, we will retrieve value of that field on all attended reservations
Thanks
Dam
But for order ID #17 or field ID #17? If the order ID is 17, we will have just one reservation while field ID is 17, we will retrieve value of that field on all attended reservations
Thanks
Dam
Please Log in or Create an account to join the conversation.
- reilldesign
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 115
- Thank you received: 0
2 years 6 months ago #153346
by reilldesign
Replied by reilldesign on topic database query of a booking with image upload field
Hi,
from the order_id (see first post).
from the order_id (see first post).
Code:
$query = "Select a.* from #__app_sch_order_items as a"
." inner join #__app_sch_orders as b on b.id = a.order_id"
." where b.order_status = 'A'";
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 12960
- Thank you received: 1679
2 years 6 months ago #153348
by Mr. Dam
Replied by Mr. Dam on topic database query of a booking with image upload field
Hi,
If you just need to retrieve customer's information, you don't need to "join" the DB table #__app_sch_order_items in your query.
For example:
And then, when you have a list of order through variable: $rows, you can use the "for" loop to retrieve value of picture custom field
Thanks
Dam
If you just need to retrieve customer's information, you don't need to "join" the DB table #__app_sch_order_items in your query.
For example:
Code:
$query = "Select * from #__app_sch_orders where order_status = 'A'";
And then, when you have a list of order through variable: $rows, you can use the "for" loop to retrieve value of picture custom field
Code:
foreach($rows as $row)
{
$db->setQuery("Select fvalue from #__app_sch_field_data where order_id = '$row->id' and fid = '17'");
$fieldValue = $db->loadResult();
if($fieldValue != "")
{
/** ..... **/
}
}
Thanks
Dam
Please Log in or Create an account to join the conversation.
- reilldesign
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 115
- Thank you received: 0
2 years 6 months ago #153424
by reilldesign
Replied by reilldesign on topic database query of a booking with image upload field
thanks a lot - it's working.
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 12960
- Thank you received: 1679
2 years 6 months ago #153427
by Mr. Dam
Replied by Mr. Dam on topic database query of a booking with image upload field
You're welcome
Dam
Dam
Please Log in or Create an account to join the conversation.
Moderators: Mr. Dam
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.