ÅÄÖ (swedish characters) problems on update - php

I have some problems with displaying ÅÄÖ in jcart, I'm not very good at explaining but if you look here you'll see what I mean.
At first it all seems to work, but if you update the page or go to the checkout it doesn't. If you press "Ta bort" or add another item after updating the characters will be displayed correctly again. I use UTF-8 as charset and I've tried ISO-8859-1 which use to fix these problems, but instead it shows another symbol. Don't know exactly where the problem is so please tell me, if you have a clue, what you need more information about.
Looking at the demo may give you some ideas? Thanks!
To show the cart I have this: <?php $jcart->display_cart();?>
And here's some code from jcart.php (included file):
/**
* Process and display cart
*/
public function display_cart() {
$config = $this->config;
$errorMessage = null;
// Simplify some config variables
$checkout = $config['checkoutPath'];
$priceFormat = $config['priceFormat'];
$id = $config['item']['id'];
$name = $config['item']['name'];
$price = $config['item']['price'];
$qty = $config['item']['qty'];
$url = $config['item']['url'];
$add = $config['item']['add'];
// Use config values as literal indices for incoming POST values
// Values are the HTML name attributes set in config.json
$id = $_POST[$id];
$name = $_POST[$name];
$price = $_POST[$price];
$qty = $_POST[$qty];
$url = $_POST[$url];
// Optional CSRF protection, see: http://conceptlogic.com/jcart/security.php
$jcartToken = $_POST['jcartToken'];
// Only generate unique token once per session
if(!$_SESSION['jcartToken']){
$_SESSION['jcartToken'] = md5(session_id() . time() . $_SERVER['HTTP_USER_AGENT']);
}
// If enabled, check submitted token against session token for POST requests
if ($config['csrfToken'] === 'true' && $_POST && $jcartToken != $_SESSION['jcartToken']) {
$errorMessage = 'Invalid token!' . $jcartToken . ' / ' . $_SESSION['jcartToken'];
}
// Sanitize values for output in the browser
$id = filter_var($id, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
$name = filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
$url = filter_var($url, FILTER_SANITIZE_URL);
// Round the quantity if necessary
if($config['decimalPlaces'] === true) {
$qty = round($qty, $config['decimalPlaces']);
}
// Add an item
if ($_POST[$add]) {
$itemAdded = $this->add_item($id, $name, $price, $qty, $url);
// If not true the add item function returns the error type
if ($itemAdded !== true) {
$errorType = $itemAdded;
switch($errorType) {
case 'qty':
$errorMessage = $config['text']['quantityError'];
break;
case 'price':
$errorMessage = $config['text']['priceError'];
break;
}
}
}
// Update a single item
if ($_POST['jcartUpdate']) {
$itemUpdated = $this->update_item($_POST['itemId'], $_POST['itemQty']);
if ($itemUpdated !== true) {
$errorMessage = $config['text']['quantityError'];
}
}
// Update all items in the cart
if($_POST['jcartUpdateCart'] || $_POST['jcartCheckout']) {
$cartUpdated = $this->update_cart();
if ($cartUpdated !== true) {
$errorMessage = $config['text']['quantityError'];
}
}
// Remove an item
/* After an item is removed, its id stays set in the query string,
preventing the same item from being added back to the cart in
subsequent POST requests. As result, it's not enough to check for
GET before deleting the item, must also check that this isn't a POST
request. */
if($_GET['jcartRemove'] && !$_POST) {
$this->remove_item($_GET['jcartRemove']);
}
// Empty the cart
if($_POST['jcartEmpty']) {
$this->empty_cart();
}
// Determine which text to use for the number of items in the cart
$itemsText = $config['text']['multipleItems'];
if ($this->itemCount == 1) {
$itemsText = $config['text']['singleItem'];
}
// Determine if this is the checkout page
/* First we check the request uri against the config checkout (set when
the visitor first clicks checkout), then check for the hidden input
sent with Ajax request (set when visitor has javascript enabled and
updates an item quantity). */
$isCheckout = strpos(request_uri(), $checkout);
if ($isCheckout !== false || $_REQUEST['jcartIsCheckout'] == 'true') {
$isCheckout = true;
}
else {
$isCheckout = false;
}
// Overwrite the form action to post to gateway.php instead of posting back to checkout page
if ($isCheckout === true) {
// Sanititze config path
$path = filter_var($config['jcartPath'], FILTER_SANITIZE_URL);
// Trim trailing slash if necessary
$path = rtrim($path, '/');
$checkout = $path . '/gateway.php';
}
// Default input type
// Overridden if using button images in config.php
$inputType = 'submit';
// If this error is true the visitor updated the cart from the checkout page using an invalid price format
// Passed as a session var since the checkout page uses a header redirect
// If passed via GET the query string stays set even after subsequent POST requests
if ($_SESSION['quantityError'] === true) {
$errorMessage = $config['text']['quantityError'];
unset($_SESSION['quantityError']);
}
////////////////////////////////////////////////////////////////////////
// Output the cart
// Return specified number of tabs to improve readability of HTML output
function tab($n) {
$tabs = null;
while ($n > 0) {
$tabs .= "\t";
--$n;
}
return $tabs;
}
// If there's an error message wrap it in some HTML
if ($errorMessage) {
$errorMessage = "<p id='jcart-error'>$errorMessage</p>";
}
// Display the cart header
echo tab(1) . "$errorMessage\n";
echo tab(1) . "<form method='post' action='$checkout'>\n";
echo tab(2) . "<fieldset>\n";
echo tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n";
echo tab(3) . "<table border='0'>\n";
echo tab(4) . "<thead>\n";
echo tab(5) . "<tr>\n";
echo tab(6) . "<th colspan='3'>\n";
echo tab(7) . "<div align='center'><span style='font-size:24px;' id='jcart-title'><br />VARUKORG</span> ($this->itemCount $itemsText) </div>\n";
echo tab(6) . "</th>\n";
echo tab(5) . "</tr>". "\n";
echo tab(4) . "</thead>\n";
// Display the cart footer
echo tab(4) . "<tfoot>\n";
echo tab(5) . "<tr>\n";
echo tab(6) . "<th colspan='3'>\n";
// If this is the checkout hide the cart checkout button
if ($isCheckout !== true) {
if ($config['button']['checkout']) {
$inputType = "image";
$src = " src='jcart/images/checkout.gif' alt='{$config['text']['checkout']}' title='' ";
}
echo tab(7) . "<input type='$inputType' $src id='jcart-checkout' name='jcartCheckout' class='jcart-button' value='{$config['text']['checkout']}' /> \n";
}
echo tab(7) . "<span id='jcart-subtotal'>{$config['text']['subtotal']}: <strong>" . number_format($this->subtotal, $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . " </strong></span>\n";
echo tab(6) . "</th>\n";
echo tab(5) . "</tr>\n";
echo tab(4) . "</tfoot>\n";
echo tab(4) . "<tbody>\n";
// If any items in the cart
if($this->itemCount > 0) {
// Display line items
foreach($this->get_contents() as $item) {
echo tab(5) . "<tr>\n";
echo tab(6) . "<td class='jcart-item-qty'>\n";
echo tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n";
echo tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='1' style='margin:0;padding:0;width:20px;' type='text' value='{$item['qty']}' />\n";
echo tab(6) . "</td>\n";
echo tab(6) . "<td class='jcart-item-name'>\n";
if ($item['url']) {
echo tab(7) . "<a href='{$item['url']}'>{$item['name']}</a>\n";
}
else {
echo tab(7) . $item['name'] . "\n";
}
echo tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n";
echo tab(6) . "</td>\n";
echo tab(6) . "<td class='jcart-item-price'>\n";
echo tab(7) . "<span>" . number_format($item['subtotal'], $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</span><input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n";
echo tab(7) . "<a class='jcart-remove' href='?jcartRemove={$item['id']}'>{$config['text']['removeLink']}</a>\n";
echo tab(6) . "</td>\n";
echo tab(5) . "</tr>\n";
}
}

Related

Dependency of HTML rendering on function's return value that executes later?

I have a function that prints "Our data" first and then inside a loop checks for all the data in the database and then prints the data.
However, if there is no data, it shouldn't print "Our data", how do I achieve this since "Our data" is already printed?
The layout is as follows :
<h1> Our Data </h1>
<p> <!-- DATA --> </p>
The function is as follows:
function cpt_info($cpt_slug, $field_name, $title) {
echo "<h1>Our" . $title . "</h1>"; //here I want to print our data
$args = array('limit' => -1);
$cpt = pods($cpt_slug, $args);
$page_slug = pods_v('last', 'url');
echo "<h1 class='projects-under-" . $cpt_slug . "'>" . $title . "</h1>";
if ($cpt->total() > 0) :
while ($cpt->fetch()) :
if (!strcasecmp($cpt->field('post_name'), $page_slug)) :
$data = $cpt->field($field_name);
foreach ((array) $data as $key => $value) {
if ($value != null) : //here I check whether data is empty
$url = wp_get_attachment_url(get_post_thumbnail_id($value['ID']));
echo "<div class='col-sm-3 col-xs-6'><div class='border-to-circle'>";
echo "<div class='circle-container' style='background: url(" . $url . ")center center, url(" . get_template_directory_uri() . '/images/rwp-banner.jpg' . ")center center;'><h4><a href='" . get_permalink($value['ID']) . "'>" . $value['post_title'] . "</a></h4></div>";
echo "</div></div>";
endif;
}
endif;
endwhile;
endif;
}
Something like below:
if(count($data)){
echo '<h1> Our Data </h1>';
}

passing one variable from one page to another for pdf generation

I have a page that I have used to retrieve some excel data written in php... by using phpexcel... this part provides me company information
echo '<form action="final.php" method="post">';
echo "<table border='1'>";
for ($rowcount = $rowCompanyInfoStart; $rowcount <= $rowCompanyInfoEnd; $rowcount++)
{
//$data = $objWorksheet->rangeToArray('A1:' . $maxCell['column'] . $maxCell['row']);
$rangeCoordinates = $colCompanyInfoStart . $rowcount . ':' . $colCompanyInfoEnd . $rowcount;
$rowData = $sheet->rangeToArray($rangeCoordinates, NULL, TRUE, FALSE);
echo "<tr>";
$companyname=$worksheet->getCell($column.$row)->getValue();
// echo $companyname;
foreach($rowData[0] as $result)
{
echo "<td>".$result." </td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo '<input type="submit" name="sub" value="Convert into PDF" />';
// echo '<input type="text" name="resName" value="$result">';
function getdatan()
{
global $result; // declare as global
return $result;
}
echo '</form>';
this part is where I get company information... it looks like the table area shown down part...
I retrieve info and able to show as "$result" variable and with submit button named "convert it into pdf" I send it into other php page where I use TCPDF ....
Normally, this part of second page
$pdf->SetFont('times', 'BI', 12);
// add a page
$pdf->AddPage('L', 'A4');
if(isset($_POST['submit']))
{
$result = $_GET['resName'];
$pdf->Write(20, $result, '', 0, 'C', true, 0, false, false, 0);
}
// set some text to print
$txt = <<<EOD
TCPDF Example 003
Custom page header and footer are defined by extending the TCPDF class and overriding the Header() and Footer() methods.
EOD;
// print a block of text using Write()
// $pdf->Write(20, $resultt, '', 0, 'C', true, 0, false, false, 0);
// ---------------------------------------------------------
ob_end_clean();
//Close and output PDF document
$pdf->Output('example.pdf', 'I');
However, I am unable to print "$result" in the second page... can you help me about how to print this table on pdf...
PS: please clarify your help...
Try this
Change :
echo '<input type="submit" name="sub" value="Convert into PDF" />';
To:
echo '<input type="submit" name="resName" value="Convert into PDF" />';
EDIT
Put this at the begining of your second page:
var_dump($_POST);
just to check what you are receiving from the first page.
Also change :
$result = $_GET['resName'];
to this:
$result = $_POST['resName'];
ok since I was on my own... I found solution by myself ....
on the first page of PHP...
session_start();
//rest of your code and then...
if($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<form action="final.php" method="POST">';
$tablo="<br />";
$tablo = $tablo."<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\" align='center'>";
for ($rowcount = $rowCompanyInfoStart; $rowcount <= $rowCompanyInfoEnd; $rowcount++)
{
//$data = $objWorksheet->rangeToArray('A1:' . $maxCell['column'] . $maxCell['row']);
$rangeCoordinates = $colCompanyInfoStart . $rowcount . ':' . $colCompanyInfoEnd . $rowcount;
$rowData = $sheet->rangeToArray($rangeCoordinates, NULL, TRUE, FALSE);
//fazla bosluk olursa bunları aç ya da hucre bos mu kontrol et (cellExists ile)
//rowData = array_map('array_filter', $rowData);
//$rowData = array_filter($rowData);
$tablo= $tablo."<tr >";
$companyname=$worksheet->getCell($column.$row)->getValue();
// echo $companyname;
foreach($rowData[0] as $result)
{
$tablo= $tablo. "<td>".$result. " </td>";
}
$tablo= $tablo. "</tr>";
}
$tablo= $tablo. "</table>";
echo $tablo;
echo "<br />";
if($_SERVER['REQUEST_METHOD'] != 'POST') {
echo "SESSION Not AVAIL. first run.";
}
else{
$_SESSION['varname'] = $tablo;
}
echo '<input type="submit" name="resName" value="Convert into PDF" />';
}
so here I used both "POST request" instead of just "POST". It sends "REQUEST" without any "POST DATA"... and then for sending the data I created a a variable called "$table" I put all my rows and cell info into that and created a session so that second PHP can retrieve it....
ON the second PHP page I answer "request" and open "session" just like that
session_start();
//rest of your code and then...
if($_SERVER['REQUEST_METHOD'] != 'POST') {
echo "SESSION Not AVAIL. first run.";
$tablo = $_SESSION['varname'];
echo "SESSION now set.";
}
else{
$tablo = $_SESSION['varname'];
//echo "SESSION SET, value: " .$_SESSION['varname']. " and ". $_SESSION['color'];
}
if (isset($_SESSION['varname'])){
$tablo = $_SESSION['varname'];
// print_r($_SESSION);
//echo "Session Set: <br/>" . $tablo;
}
else{
echo "Session not set. Tablo is empty";
// echo "Session Set: <br/>" . $tablo;
}
so that's it!

Magento review for logged in customer on one product

I have a loop that shows all products that a customer has ordered, within that loop I want to pull out if the customer has rated that one product what rating they have given it. I think the problem is I need to use review/summary to display the rating?
$productsreviews = Mage::getModel('review/review')->getProductCollection()->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId())->setDateOrder();
foreach ($productsreviews as $productsreview)
{
$product = Mage::getModel('catalog/product')->load($productsreview->getData('entity_pk_value'));
}
echo $product->getRating();
EDIT:Full Code
<?php
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
/* Get the customer data */
$customer = Mage::getSingleton('customer/session')->getCustomer();
/* Get the customer's email address */
$customer_email = $customer->getEmail();
$customer_id = $customer->getId();
}
$collection = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('customer_email', array(
'like' => $customer_email
));
$uniuqProductSkus = array();
foreach ($collection as $order) {
$order_id = $order->getId();
$order = Mage::getModel("sales/order")->load($order_id);
$ordered_items = $order->getAllItems();
foreach ($ordered_items as $item)
{
if (in_array($item->getProduct()->getSku(), $uniuqProductSkus)) {
continue;
} else {
array_push($uniuqProductSkus, $item->getProduct()->getSku());
$_product = Mage::getModel('catalog/product')->load($item->getProductId());
$product_small_image_path = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(200);
$product_thumbnail_path = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(150);
$summaryData = Mage::getModel('review/review_summary')->load($item->getProductId());
echo "<li>";
echo "<div class='previous-name'><p><a style='color:black; font-weight:bold; font-size:14px;' href='" . $_product->getProductUrl() . "'>";
echo $item->getName() . "</a></p></div>";
echo "<div class='previous-image'><a href='" . $_product->getProductUrl() . "'>";
echo "<img src='" . $product_small_image_path . "' />";
echo "</a></div>";
echo "<div class='previous-rating'>";
echo "<p><a style='color:black; font-weight:bold; font-size:14px;' href='" . $_product->getProductUrl() . "#product_tabs_review_tabbed'>Review this beer now</a></p>";
echo $summaryData->getRatingSummary() . '% Would buy again <br/>';
echo "<div class='rating-box' style='float:left;'>";
echo "<div class='rating' style='width:" . $summaryData->getRatingSummary() . "%'></div></div>";
echo "<div class='previous-clear'></div></div>";
?>
review/summary will display the aggregated data. IIRC there's no method to pull out single review along with rating using the review model. This should give you the review object with associated rating:
$cReviews = Mage::getModel('review/review')->getResourceCollection()
->addStoreFilter($oProduct->getStoreId())
->addRateVotes()
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addEntityFilter('product', $oProduct->getId())
->setDateOrder()
->addFieldToFilter('customer_id', $yourCustomerId);
$cReviews->getSelect()->limit(1);
$oReview = $cReviews->getFirstItem();
Then you will have to calculate rating average for the single review:
if ( ($cRatings = $oReview->getRatingVotes()) && count($cRatings) ) {
$rAverage = array_sum($cRatings->getColumnValues('value')) / count($cRatings);
}

Delete index session in PHP

I have question referring to the session in PHP.
I've coded in PHP for setting the session and I want to delete it , but I got some errors and confusing with using the UNSET(variable $_SESSION). Perhaps anyone could help me to show what should I do with this matter. Thanks in advance
$_SESSION['chart'] = array();
$_SESSION['chart'][0]['index'] = 0
$_SESSION['chart'][0]['type'] = $type;
$_SESSION['chart'][0]['idanimal'] = $iddog;
$_SESSION['chart'][0]['price'] = $price;
printdata(); // <== this is the function to print out the data
All I want to do is just delete based on the index in this session
Here's the function :
function printdata()
{
$totalharga = 0;
if(is_array($_SESSION['chart']))
{
echo "<h3>"."Berikut adalah keranjang belanja anda" . "</h3>". "<br>";
$max = count($_SESSION['chart']);
$th1 = "<th>" . "No" . "</th>";
$th2 = "<th>" . "Animal Type" . "</th>";
$th3 = "<th>" . "ID Binatang" . "</th>";
$th4 = "<th>" . "Harga" . "</th>";
$th5 = "<th>" . "Hapus Data" . "</th>";
echo "<table border=1>";
echo "<tr>";
echo $th1 ;
echo $th2;
echo $th3;
echo $th4;
echo $th5;
echo "</tr>";
for ($indexo = 0; $indexo < $max; $indexo++)
{
echo "<tr>";
echo "<td>" . $indexo."</td>";
echo "<td>" . $_SESSION['chart'][$indexo]['type']."</td>";
echo "<td>" . $_SESSION['chart'][$indexo]['idanimal']."</td>";
echo "<td>" . "Rp. " . $_SESSION['chart'][$indexo]['harga']. ",-" ."</td>";
echo "<td>" . "<a href='deletesession.php?session=$indexo'>" ."Proses ". "</a>"."</td>";
$totalharga += $_SESSION['chart'][$indexo]['harga'];
echo "</tr>";
}
echo "</table>" . "<br/>";
echo "<blockquote>" . "Total Pembelian Item Yang Anda Pesan =". "<h2>". "Rp." . $totalharga . ",-" ."</h2>" . "</blockquote>";
}else
{
echo "Chart is still Empty";
}
}
I've already tried this :
Suppose that there is a chart already filled by the contents then I tried to delete within this code, I've received error with the unset variable
unset($_SESSION['chart'][1])
Thank you
I spot several things that could be improved in your code:
Don't echo in your functions, return instead (then echo what the function returns). This gives you more flexibility regarding what you do with your result.
PHP has a built-in loop for iterating arrays, the foreach loop. You should be using that instead of for.
So here's what I have:
function print_session_data($session) {
if (!is_array($session)) {
return "Array is empty";
}
$table_data = "";
$total_harga = 0;
foreach ($session as $index => $data) {
$table_data .= <<<TABLE_DATA
<tr>
<td>$index</td>
<td>{$data["type"]}</td>
<td>{$data["idanimal"]}</td>
<td>Rp. {$data["harga"]}</td>
<td>Proses</td>
</tr>
TABLE_DATA;
$total_harga += $data["harga"];
}
$result = <<<RESULT
<h3>Berikut abalah keranjang belanja anda</h3>
<table border="1">
<thead>
<tr>
<th>No</th>
<th>Animal Type</th>
<th>ID Binatang</th>
<th>Harga</th>
<th>Hapus Data</th>
</tr>
</thead>
<tbody>
$table_data
</tbody>
</table>
<blockquote>Total Pembelian Item Yang Anda Pesan = <strong>Rp. $total_harga</strong></blockquote>
RESULT;
return $result;
}
$_SESSION['chart'] = array();
$_SESSION['chart'][0]['type'] = "Type";
$_SESSION['chart'][0]['idanimal'] = 6;
$_SESSION['chart'][0]['price'] = '$25';
$_SESSION['chart'][0]['harga'] = 25;
echo print_session_data($_SESSION["chart"]); // <== this is the function to print out the data
Suppose that there is a chart already filled by the contents then I
tried to delete within this code, I've received error with the unset
variable unset($_SESSION['chart'][1])
From what I can see from your code the best way to unset the data correctly is as follow:
DEMO.
You have to check if the $_SESSION['chart'][0] was set before using the session variable index again. If it $_SESSION['chart'] array still contains other indexes then you can call printdata(); else indicate that the session was empty.

CodeIgniter appending to the beginning of the view when it shouldn't be

When I call regularDashboard(), it appends to the beginning of my view. In my view I'm calling $reg from inside a formatted style. So it shouldn't be echoing out at the beginning of the view... Any ideas as to why this is happening?
public function dcr() {
// pass all dashboard accesses through this function
$username = $this->session->userdata("username");
$query = $this->db->get_where('users', array('username' => $username));
$userType = $this->session->userdata('userType');
if ($userType == 'regular') {
foreach ($query->result() as $row) {
$data = array('reg' => $this->regularDashboard(), 'firstname' => $row->firstname);
$this->load->view('dashboard', $data);
} public function regularDashboard () {
$userid = $this->session->userdata('userid');
$results = $this->db->query("SELECT * FROM users");
foreach ($results->result() as $row) {
if($userid != $row->userid) {
echo $row->firstname . " " . $row->lastname;
echo "<form method='GET' action='processing/lib/process-send-friend-request.php?'>";
echo '<input name="accepted" type="submit" value="Send User Request" /><br />';
echo '<input name="AddedMessage" placeholder="Add a message?" type="textbox" />';
echo '<br>Select Friend Type: ' . '<br />Full: ';
echo '<input name="full_friend" type="checkbox"';
echo '<input type="hidden" name="id" value="' . $row->idusers . '" />';
echo '</form>';
echo "<br /><hr />";
} elseif ($userid == $row->userid) {
echo $row->firstname . " " . $row->lastname;
echo "<br />";
echo "You all are currently friends";
}
}
}
Views are buffered. When you echo something directly in a controller, it is sent before the buffer is flushed (therefore before the output containing the view is sent to the browser), that's why it appears before anything.
You shouldn't to this (sending a direct output/echoing something outside of views), you risk getting into troubles as soon as you use anything related to headers (redirect, cookies, CI's sessions...)
UPDATE:
To fix it, just assign all those string to a variable (as jeff showed), and send that to the view:
$data['form'] = $row->firstname . " " . $row->lastname;
$data['form'] .= "<form method='GET' action='processing/lib/process-send-friend-request.php?'>";
$this->load->view('formview',$data);
There, you just echo $form and you'll have all your strings output correctly.
EDIT :
all above if you're inside a Controller. If you're in a Model, just assign everything to a variable and return it to the Controller:
function regularDashboard()
{
$form = $row->firstname . " " . $row->lastname;
$form .= "<form method='GET' action='processing/lib/process-send-friend-request.php?'>";
return $form;
}
In the controller:
$data['form'] = $this->model->regularDashboard();
$this->load->view('formview',$data);
If you allow me, I'd suggest writing the form directly into the view, without the hassle (and the structural error) of creating something that's supposed to be "presentation" outdside of views.
It seems that your issue is the use of echo from within regularDashboard(). Try setting a variable that contains the form markup and return it instead of using echo.
Here is an example:
function regularDashboard()
{
$html = "";
$html .= "<form>";
//Append the rest of the form markup here
return $html;
}

Categories