I want to add pagination in my site when user search for some item. I have tried the following code:
//Array Declaration//
$pages = array();
$userlist = array();
//paging variable//
$userlist_pg = $_GET['list_pg'];
if(empty($userlist_pg))
$userlist_pg = 1;
else
$userlist_pg=$_GET['list_pg'];
$userlist_limit = 10;//ADMIN_ITEMLIST_PER_PAGE;
$userlist_start = (($userlist_pg - 1) * $userlist_limit );
$userlist_currentpage = $userlist_pg;
$userlist_back = $userlist_pg-1;
$userlist_next = $userlist_pg + 1;
$query_string = "select cms_id,cms_variable,cms_page_name,cms_last_edited from tbl_cms";
//Paging variables start from here-------------------------
$orderlist = array();
$paging = new PagedResults();
$paging->TotalResults = table_query_count($query_string);
$InfoArray = $paging->InfoArray();
$query_string.=" LIMIT ".$InfoArray["MYSQL_LIMIT1"].", ".$InfoArray["MYSQL_LIMIT2"];
$PageVarName = 'client_page';
$smarty->assign("page_display", getpagelist($InfoArray["CURRENT_PAGE"],$InfoArray["PREV_PAGE"],$InfoArray["NEXT_PAGE"],$InfoArray["TOTAL_PAGES"],$InfoArray["Second_next"],$InfoArray["third_next"],$InfoArray["fourth_next"],$PageVarName));
$smarty->assign("currentpage",$InfoArray["CURRENT_PAGE"]);
$smarty->assign("total_pages",$InfoArray["TOTAL_PAGES"]);
//Paging variables end here-------------------------
it gives the following errors.
Call to undefined function table_query_count() in /home/www/jobplacement4u.com/hungry_uni/modules/search/action/search_action.php on line 110
Class 'PagedResults' not found in /home/www/jobplacement4u.com/hungry_uni/modules/search/action/search_action.php on line 30
Call to undefined method PagedResults::InfoArray() in /home/www/jobplacement4u.com/hungry_uni/modules/search/action/search_action.php on line 111
Looks like you forgot to include the file(s) with definition of function table_query_count and class PagedResults
Related
I am trying to store data by using id as primary key in Laravel 8, I used following code in controller :
public function store(Request $request)
{
$job = new Job();
$job->employeer_id = Auth()->user('employeer')->id;
$job->category = $request->category_name;
$job->job_context = $request->job_context;
$job->keywords = $request->keywords;
$job->title = $request->title;
$job->vacancy = $request->vacancy;
$job->deadline = $request->deadline;
$job->employment_type = $request->employment_type;
$job->location = $request->location;
$job->gender = $request->gender;
$job->age = $request->age;
$job->responsibilities = $request->responsibilities;
$job->education = $request->education;
$job->requirements = $request->requirements;
$job->additional_requirements = $request->additional_requirements;
$job->salary = $request->salary;
$job->benifits = $request->benifits;
$job->apply_instruction = $request->apply_instruction;
$job->save();
Category::where('category_name', '=' , $request->category_name)->increment('no_jobs', 1);
return redirect('/jobs');
}
The error says that :
Trying to get property 'id' of non-object
in this line :
$job->employeer_id = Auth()->user('employeer')->id;```
Instead of
Auth()->user('employeer')->id;
use
Auth::guard('employeer')->id();
or
auth('employeer')->user()->id;
Check if you get the user first
Auth::guard('employeer')->check();
Then put your code in condition if the user object exist.
So basically you should do this
if(Auth::guard('employeer')->check()){
$job = new Job();
$job->employeer_id = Auth::guard('employeer')->user()->id;
// rest of the code
}else{
// handle as you want
}
getting this error in my local server. but this code is running in online
where its not showing any error. now what can i do? error show empty(count($leadcount)) this condition
if(empty(count($leadcount))){
if(!empty($leadManagements)){
$LeadSend = $this->LeadSend->newEntity();
$inqData['requirement_id'] = $Requirements->id;
$inqData['lead_management_id'] = $leadManagements->id;
$inqData['send_date'] = Time::createFromFormat('Y-m-d', date('Y-m-d'));
$inqData['lead_type'] = 'booking';
$inqData['is_active'] = 1;
$inqData['is_delete'] = 1;
$LeadSend = $this->LeadSend->patchEntity($LeadSend, $inqData);
if($this->LeadSend->save($LeadSend)){
$expression = new QueryExpression('booking_lead_count = booking_lead_count + 1');
$expression2 = new QueryExpression('lead_sent_count = lead_sent_count + 1');
$this->LeadManagements->updateAll([$expression,$expression2], ['id' => $leadManagements->id]);
//lead_type send_date
$this->notificationBuyer($this->request->data);
$this->notificationSeller($this->request->data);
}
}
} else {
/// allready send inquery
}
Surely it should simply be either if(empty($leadcount)) or if(count($leadcount) == 0).
I have an afterSave function in my model, the function executes, but in an endless loop. what could be the reason?
The function inserts the data into my DB, but in multiple rows.
thanks.
my function:
public function afterSave($insert)
{
$modelProject = projects::find()
->where(['status' => 2])
->one();
$idProject = $modelProject->pId;
$candidateforproject = new candidateforproject();
// $candidateforproject->id = 3;
$candidateforproject->idProject = $idProject;
$candidateforproject->idCandidate = $this->prId;
$candidateforproject->idQuestionnaire = $this->id;
$candidateforproject->idStatus = 0;
$candidateforproject->insert();
$answerOne = questionsgrades::findOne($this->answer1);
$grade1 = $answerOne->grade;
$answerTow = questionsgrades::findOne($this->answer2);
$grade2 = $answerTow->grade;
$answerThree = questionsgrades::findOne($this->answer3);
$grade3 = $answerThree->grade;
$answerFour = questionsgrades::findOne($this->answer4);
$grade4 = $answerFour->grade;
$answerFive = questionsgrades::findOne($this->answer5);
$grade5 = $answerFive->grade;
$grade = $grade1 + $grade2 + $grade3 + $grade4 + $grade5;
$this->degree=$grade;
$this->save(['degree']);
}
return parent::afterSave($insert);
}
I can see that you are using $this->save(); in AfterSave action. This will cause calling AfterSave() again. So here is the place with loop.
Possible fix is to use $this->update(); instead of $this->save();
but, honestly, I think you should remaster you logic architecture.
I am trying to delete a certain item from a database depending on conditions. Here is what I have:
while ($row = mysql_fetch_array($result)) {
$now = strtotime("now");
$dateArray = date_parse_from_format("n-j-Y", $row["date"]);
$event_date = strtotime($dateArray['year'].'-'.$dateArray['month'].'-'.$dateArray['day']);
// temp user array
$event = array();
if($event_date > $now) {
//Event is in the future
$pid_check =$row["pid"];
$event["pid"] = $row["pid"];
$event["name"] = $row["name"];
$event["longitude"] = $row["longitude"];
$event["latitude"] = $row["latitude"];
$event["pavement"] = $row["pavement"];
$event["traffic"] = $row["traffic"];
$event["environment"] = $row["environment"];
$event["image_b64"] = $row["image_b64"];
$event["date"] = $row["date"];
$event["time"] = $row["time"];
$event["type"] = $row["type"];
// push single product into final response array
array_push($response["events"], $event);
} else {
$result2 = mysql_query("DELETE FROM events WHERE pid = $pid_check");
}
}
But when I try this it comes up blank, when I comment out result2 it works but doesn't delete(duh). How can I get it to delete? Sorry if this is a simple question, my knowledge of the language is not much.
I think $pid_check is getting set only if the condition in your if is TRUE.
It's not getting set for the else branch.
One option is to relocate the assignment of $pid_check before the if test.
I am using php-ews to send mails and I cannot find a way to set the importance (priority) of a mail.
Here is my code:
$from = $mail['from'];
$to = $mail['to'];
$subject = $mail['subject'];
$body = $mail['body'];
$msg = new EWSType_MessageType();
if($to && count($to) > 0){
$toAddresses = $this->getAddresses($to);
$msg->ToRecipients = $toAddresses;
}
$fromAddress = new EWSType_EmailAddressType();
$fromAddress->EmailAddress = $from['mail'];
$fromAddress->Name = $from['name'];
$msg->From = new EWSType_SingleRecipientType();
$msg->From->Mailbox = $fromAddress;
$msg->Subject = $subject;
$msg->Body = new EWSType_BodyType();
$msg->Body->BodyType = 'HTML';
$msg->Body->_ = $body;
$msgRequest = new EWSType_CreateItemType();
$msgRequest->Items = new EWSType_NonEmptyArrayOfAllItemsType();
$msgRequest->Items->Message = $msg;
$msgRequest->MessageDisposition = 'SendAndSaveCopy';
$msgRequest->MessageDispositionSpecified = true;
$response = $this->ews->CreateItem($msgRequest);
return $response;
Thank you in advance for your response!
You need to load the EWSType_ImportanceChoicesType class. Your code should look like this:
$from = $mail['from'];
$to = $mail['to'];
$subject = $mail['subject'];
$body = $mail['body'];
$msg = new EWSType_MessageType();
if($to && count($to) > 0){
$toAddresses = $this->getAddresses($to);
$msg->ToRecipients = $toAddresses;
}
$fromAddress = new EWSType_EmailAddressType();
$fromAddress->EmailAddress = $from['mail'];
$fromAddress->Name = $from['name'];
$msg->From = new EWSType_SingleRecipientType();
$msg->From->Mailbox = $fromAddress;
$msg->Subject = $subject;
$msg->Body = new EWSType_BodyType();
$msg->Body->BodyType = 'HTML';
$msg->Body->_ = $body;
$msgRequest = new EWSType_CreateItemType();
$msgRequest->Items = new EWSType_NonEmptyArrayOfAllItemsType();
$msgRequest->Items->Message = $msg;
// Start importance code
$msgRequest->Items->Message->Importance = new EWSType_ImportanceChoicesType();
$msgRequest->Items->Message->Importance->_ = EWSType_ImportanceChoicesType::HIGH;
// End importance code
$msgRequest->MessageDisposition = 'SendAndSaveCopy';
$msgRequest->MessageDispositionSpecified = true;
$response = $this->ews->CreateItem($msgRequest);
return $response;
To change the importance just change the ending of the following line to have HIGH, LOW or NORMAL:
$msgRequest->Items->Message->Importance->_ = EWSType_ImportanceChoicesType::HIGH;
I'm not realy familiar with php, but if I'm using C# the mailmessage-class has a "Importance" property which is an enum and can be set to: High, Low and Normal. Default is "Normal".
Hope this helps you...