/    Sign up×
Community /Pin to ProfileBookmark

Help with a query & loop

I’m trying to extract the info from columns in a db table (paid_videos) to match up with the array, so the array data will display info in an html table.

here’s what I have:

“`
$data1 = $db->rawQuery(“SELECT id, id_user, id_video, earned_amount, time_date FROM paid_videos”);

if (!empty($data1)) {
foreach ($object as $key=> $data) {
$singledata = myfunction($data[0]);

$paid_list .= PT_LoadPage(‘transactions/list’,array(
‘ID’ => $video->id,
‘PAID_USER’ => $user->id,
‘VIDEO_NAME’ => $video->title,
‘AMOUNT’ => $tr->earned_amount,
“CURRENCY” => $currency,
‘TIME’ => date(“Y-m-d h:i A (T)”, strtotime($video->time_date))
));
}
}
“`

I believe I need help with a loop, and probably more.

I look forward to any assistance.

to post a comment

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 10.2019 — Where is $object defined? Should that be foreach($data1 as $key => $data) ?
Copy linkTweet thisAlerts:
@chrisjchrisjauthorAug 10.2019 — Thank you for your reply.

I tried this:
``<i>
</i>$data1 = $db-&gt;rawQuery("SELECT id, id_user, id_video, earned_amount, time_date FROM paid_videos");

if (!empty($data1)) {
foreach ($data1 as $key=&gt; $data) {
$singledata = myfunction($data[0]);


$paid_list .= PT_LoadPage('transactions/list',array(
'ID' =&gt; $video-&gt;id,
'PAID_USER' =&gt; $user-&gt;id,
'VIDEO_NAME' =&gt; $video-&gt;title,
'AMOUNT' =&gt; $tr-&gt;earned_amount,
"CURRENCY" =&gt; $currency,
'TIME' =&gt; date("Y-m-d h:i A (T)", strtotime($video-&gt;time_date))
));
}
}<i>
</i>
`</CODE>

and see this:<br/>
Fatal error: Uncaught Error: Call to undefined function myfunction() in /home/public_html/content.php:229 Stack trace: #0 /home/public_html/index.php(62): include() #1 {main} thrown in /home/public_html/content.php on line 229

and line 229 is:

<C>
$singledata = myfunction($data[0]);`

any additional guidance is appreciated
Copy linkTweet thisAlerts:
@NogDogAug 11.2019 — @chrisjchrisj#1607451

Well...the error message is pretty clear. Do you need to include some file that defines that function...or is that a place-holder name suggesting you need to define some function and reference it there? Or...does $singledata ever get used anywhere? If not, maybe you don't even need that line? 🤷‍♂️
Copy linkTweet thisAlerts:
@chrisjchrisjauthorAug 11.2019 — Much thanks again for your reply.

I've modified to this (and the error is gone):

$data_1 = $db-&gt;rawQuery("SELECT id, id_user, id_video, earned_amount, time_date FROM paid_videos");<br/>
if (!empty($data_1)) {<br/>
$ads_list1 .= PT_LoadPage('transactions/list',array(<br/>
'ID' =&gt; $video-&gt;id,<br/>
'PAID_USER' =&gt; $user-&gt;id,<br/>
'VIDEO_NAME' =&gt; $video-&gt;title,<br/>
'AMOUNT' =&gt; $tr-&gt;earned_amount,<br/>
"CURRENCY" =&gt; $currency,<br/>
'TIME' =&gt; date("Y-m-d h:i A (T)", strtotime($video-&gt;time_date))<br/>
));<br/>
}


Any additional help/suggestion/guidance to change what I have here so as to extract the info from columns in a db table (paid_videos) to match up with the array, so the array data will display info in an html table, will be greatly appreciated
×

Success!

Help @chrisjchrisj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...