Problem after converting my HTML site to PHP ( echo ''; echo ''; everywhere) - php

I tried to convert my static html site pages with an online HTML to PHP converter. I changed all my extensions to .php and also the links. You can see the result of the conversion below. I run it with wamp but some stuff (images, css, text) of the page is shown in the browser, but most of the stuff is not, and instead I see
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '';
echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo
''; echo '
everywhere.
What am I doing wrong?
<? php
echo '<!DOCTYPE html>';
echo '<html lang="en">';
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->';
echo '<title>Title</title>';
echo '<!-- Bootstrap -->';
echo '<link href="css/bootstrap.min.css" rel="stylesheet">';
echo '<link rel="stylesheet" type="text/css" href="css/style.css">';
echo '<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->';
echo '<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->';
echo '<!--[if lt IE 9]>';
echo '<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>';
echo '<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>';
echo '<![endif]-->';
echo '</head>';
echo '<body>';
echo '<nav class="navbar navbar-default">';
echo '<div class="container">';
echo '<!-- Brand and toggle get grouped for better mobile display -->';
echo '<div class="navbar-header">';
echo '<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">';
echo '<span class="sr-only">Toggle navigation</span>';
echo '<span class="icon-bar"></span>';
echo '<span class="icon-bar"></span>';
echo '<span class="icon-bar"></span>';
echo '</button>';
echo '<a class="navbar-brand" href="index.php"><img src="images/logo.png" class="img-responsive" width="150px"></a>';
echo '</div>';
echo '<!-- Collect the nav links, forms, and other content for toggling -->';
echo '<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">';
echo '<ul class="nav navbar-nav navbar-right">';
echo '<li class="active">HOME <span class="sr-only">(current)</span></li>';
echo '<li class="dropdown">';
echo 'text <span class="caret"></span>';
echo '<ul class="dropdown-menu">';
echo '<li>some link</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li>something</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li>something else</li>';
echo '</ul>';
echo '</li>';
echo '<li class="dropdown">';
echo 'something<span class="caret"></span>';
echo '<ul class="dropdown-menu">';
echo '<li>something</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li>some link</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li></> something</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li></>something</li>';
echo '</ul>';
echo '</li>';
echo '<li class="dropdown">something<span class="caret"></span>';
echo '<ul class="dropdown-menu">';
echo '<li>something</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li>something</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li></>something</li>';
echo '<li role="separator" class="divider"></li>';
echo '<li></>something</li>';
echo '</ul>';
echo '</li>';
echo '</ul>';
echo '</div><!-- /.navbar-collapse -->';
echo '</div><!-- /.container-->';
echo '</nav>';
echo '<!-- Carousal -->';
echo '<section class="jk-slider">';
echo '<div id="carousel-example" class="carousel slide" data-ride="carousel">';
echo '<ol class="carousel-indicators">';
echo '<li data-target="#carousel-example" data-slide-to="0" class="active"></li>';
echo '<li data-target="#carousel-example" data-slide-to="1"></li>';
echo '<li data-target="#carousel-example" data-slide-to="2"></li>';
echo '</ol>';
echo '<div class="carousel-inner">';
echo '<div class="item active">';
echo '<div class="hero">';
echo '<hgroup>';
echo '<p>something</p>';
echo '</hgroup>';
echo '</div>';
echo '<div class="overlay"></div>';
echo '<img src="images/1.jpg" class="img-responsive" width="100%">';
echo '</div>';
echo '<div class="item">';
echo '<div class="hero">';
echo '<hgroup>';
echo '<p>something</p>';
echo '</hgroup>';
echo '</div>';
echo '<div class="overlay"></div>';
echo '<img src="images/2.jpg" class="img-responsive" width="100%">';
echo '</div>';
echo '<div class="item">';
echo '<div class="hero">';
echo '<hgroup>';
echo '<p>something</p>';
echo '</hgroup>';
echo '</div>';
echo '<div class="overlay"></div>';
echo '<img src="images/3.jpg" />';
echo '</div>';
echo '</div>';
echo '<a class="left carousel-control" href="#carousel-example" data-slide="prev">';
echo '<span class="glyphicon glyphicon-chevron-left"></span>';
echo '</a>';
echo '<a class="right carousel-control" href="#carousel-example" data-slide="next">';
echo '<span class="glyphicon glyphicon-chevron-right"></span>';
echo '</a>';
echo '</div>';
echo '</section>';
echo '<!-- End Of carousal -->';
echo '<section>';
echo '<div class="container">';
echo '<div class="row">';
echo '<div class="col-md-12">';
echo ' ';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</section>';
echo '<script src="../../ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>';
echo '<!-- Include all compiled plugins (below), or include individual files as needed -->';
echo '<script src="js/bootstrap.min.js"></script>';
echo '<script type="text/javascript">';
echo '<script type="text/javascript">';
echo '$('.count').each(function () {';
echo '$(this).prop('Counter',0).animate({';
echo 'Counter: $(this).text()';
echo '}, {';
echo 'duration: 5000,';
echo 'easing: 'swing',';
echo 'step: function (now) {';
echo '$(this).text(Math.ceil(now));';
echo '}';
echo '});';
echo '});';
echo '</script>';
echo '</script>';
echo '</body>';
echo '</html>';
?>

Do you really need to make everything in echo? You can just simply put in normal html tag. And put <?php ?> wherever you need PHP code.
Regarding your JS, you are calling <script type='text/javascript'></script> twice.

Related

How to insert HTML using foreach() without echo

I have this working code in my view:
<?php
$task_num = 0;
foreach ($curent_day->getTasksList() as $task){
echo '<div class="task">';
echo '<span class="task_id">'.($task_num+1).'.'.'</span>';
echo '<div class="task_time">';
echo '<span class="task_time_start">'.$task->getStartTime().'</span>';
echo '<span class="task_time_finish">'.$task->getFinishTime().'</span>';
echo '</div>';
echo ''.$task->name.'';
echo 'Start';
echo 'Finish';
echo '<div class="status_round '.$task->status.'"></div>';
echo '</div>';
$task_num++;
}
?>
Is there any way to get rid of 'echo'?
P.S. and is the way to insert HTML with HTML helper more correct even if it takes more space?
You can drop echo completely and use native HTML syntax:
<?php $task_num = 0 ?>
<?php foreach ($curent_day->getTasksList() as $task): ?>
<div class='task'>
<span class='task_id'><?= ++$task_num ?></span>
<div class='task_time'>
<span class='task_time_start'><?= $task->getStartTime() ?></span>
<span class='task_time_finish'><?= $task->getFinishTime() ?></span>
</div>
<a href='/' class='task_name'><?= $task->name ?></a>
<a href='/' class='btn task_start btn_disabled'>Start</a>
<a href='/' class='btn task_finish btn_disabled'>Finish</a>
<div class='status_round <?= $task->status ?>'></div>
</div>
<?php endforeach ?>
This will give you better syntax highlighting and autoformatting support in your IDE/editor.
There are several different ways that you can concatenate the string by using single quotes and double quotes, or by using a variable and the ".=" operator to append text onto the end of a string. Just google php strings & concatenation and it will have more than you need to figure this out.
But using you example here is a method:
$task_num = 0;
foreach ($curent_day->getTasksList() as $task){
echo
'<div class="task">' .
'<span class="task_id">' . ($task_num+1) . '.'.'</span>' .
'<div class="task_time">' .
'<span class="task_time_start">' . $task->getStartTime() . '</span>' .
'<span class="task_time_finish">' . $task->getFinishTime() . '</span>' .
'</div>' .
''.$task->name.'' .
'Start' .
'Finish' .
'<div class="status_round '.$task->status.'"></div>' .
'</div>';
$task_num++;
}
You have to echo to output you data to the browser.
You need not use string concatenation or multiple echo statements.
Alternative
$task_num = 0;
foreach ($curent_day->getTasksList() as $task){
$task_num++;
echo
"<div class='task'>
<span class='task_id'>{$task_num}</span>
<div class='task_time'>
<span class='task_time_start'>{$task->getStartTime()}</span>
<span class='task_time_finish'>{$task->getFinishTime()}</span>
</div>
<a href='/' class='task_name'>{$task->name}</a>
<a href='/' class='btn task_start btn_disabled'>Start</a>
<a href='/' class='btn task_finish btn_disabled'>Finish</a>
<div class='status_round {$task->status}'></div>
</div>";
}
You can concatenate your html in one variable and then you can use it with one time echo statement
<?php
$task_num = 0;
$html = '';
foreach ($curent_day->getTasksList() as $task){
$html .= '<div class="task">';
$html .= '<span class="task_id">'.($task_num+1).'.'.'</span>';
$html .= '<div class="task_time">';
$html .= '<span class="task_time_start">'.$task->getStartTime().'</span>';
$html .= '<span class="task_time_finish">'.$task->getFinishTime().'</span>';
$html .= '</div>';
$html .= ''.$task->name.'';
$html .= 'Start';
$html .= 'Finish';
$html .= '<div class="status_round '.$task->status.'"></div>';
$html .= '</div>';
$task_num++;
}?>

Changing active class using echo in php comand

I have a problem with next code:
<?php
include("db.php");
$sql = mysql_query("SELECT COUNT(id_produs) FROM My_Products WHERE `id_produs_categorie`='$id_categorie' ");
$total_produse = mysql_result($sql, 0);
$total_pagini = ceil($total_produse / $produse_pe_pagina);
if(isset($_GET['ID'])!="")
$id_categorie=$_GET['ID'];
echo '<div class="row">';
echo '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">';
echo '<div class="bs-example margin-top20">';
echo '<ul class="pagination">';
echo '<li class="disabled"></li>';
echo '<li ( basename($_SERVER["REQUEST_URI"]) == "categorie.php?ID=$id_categorie&pagina=1" ? class="active" : "" )>1</li>';
for ($i=2; $i<=$total_pagini; $i++) {
echo '<li ( basename($_SERVER["REQUEST_URI"]) == "categorie.php?ID=$id_categorie&pagina=$i" ? class="active" : "" )>'.$i.'</li>';
};
echo '<li class="disabled"></li>';
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
?>
I'm trying to change the classes based on the page user is on.
The code is good if i echo the address its ok with variables but the problem is that even if i'm on page 1 it adds also the class active to page 2 or 3.
What i'm doing wrong here?
Thank you for your help!
Try:
<?php
include("db.php");
$sql = mysql_query("SELECT COUNT(id_produs) FROM My_Products WHERE `id_produs_categorie`='$id_categorie' ");
$total_produse = mysql_result($sql, 0);
$total_pagini = ceil($total_produse / $produse_pe_pagina);
if(isset($_GET['ID'])!="")
$id_categorie=$_GET['ID'];
if(isset($_GET['pagina'])!="")
$pagina = $_GET['pagina'];
echo '<div class="row">';
echo '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">';
echo '<div class="bs-example margin-top20">';
echo '<ul class="pagination">';
echo '<li class="disabled"></li>';
for ($i=1; $i<=$total_pagini; $i++) {
$class = $pagina == $i ? 'class="active"' : "";
echo '<li ' . $class .'>'.$i.'</li>';
};
echo '<li class="disabled"></li>';
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
?>

open link with target="_blank" can´t fix it

i would like to change a link to target="_blank" (opening in a new window, or tab) but can#t fix it. i´m a fool in php and my try&error-method did´t work. can anybody help me?
Thank you so much!
original code from the parallax one theme (wordpress)
<?php
if(!empty($parallax_one_contact_info_item_decoded)){
foreach($parallax_one_contact_info_item_decoded as $parallax_one_contact_item){
if(!empty($parallax_one_contact_item->link)){
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
echo ''.$parallax_one_contact_item->text.' ';
}
echo '</div>';
} else {
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
if(function_exists('icl_translate')){
echo ''.icl_translate('Contact',$parallax_one_contact_item->id.'_contact',esc_attr($parallax_one_contact_item->text)).'';
} else {
echo ''.esc_attr($parallax_one_contact_item->text).'';
}
}
echo '</div>';
}
}
}
?>
Simply add target="_blank" in your anchor tag. For example :
echo '<a target="_blank" href="'.$parallax_one_contact_item->link.'" class="strong">'.$parallax_one_contact_item->text.' </a>';
Try this:
<?php
if(!empty($parallax_one_contact_info_item_decoded)){
foreach($parallax_one_contact_info_item_decoded as $parallax_one_contact_item){
if(!empty($parallax_one_contact_item->link)){
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
echo '<a target="_blank" href="'.$parallax_one_contact_item->link.'" class="strong">'.$parallax_one_contact_item->text.' </a>';
}
echo '</div>';
} else {
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
if(function_exists('icl_translate')){
echo '<a target="_blank" href="" class="strong">'.icl_translate('Contact',$parallax_one_contact_item->id.'_contact',esc_attr($parallax_one_contact_item->text)).'</a>';
} else {
echo '<a target="_blank" href="" class="strong">'.esc_attr($parallax_one_contact_item->text).'</a>';
}
}
echo '</div>';
}
}
}
?>
Note: Added target="_blank" in each hyperlink.

Embed HTML in PHP Code

I have to fetch data using a REST Api, and my response is in json. After decoding the response is in an array I have to display it in a webpage such that each of the responses in the array get displayed in a specific display format (Just Like tweets in twitter are displayed in a specific box type format).How to loop through the array in php and display it ? The only solution I find is embedding the HTML in php using echo which I did but it is not working .And the debugger isn't helping much.
What am I missing ?
Please advise what to do.
Here is my code:
echo "<div class="tweet original-tweet js-stream-tweet js-actionable-tweet js-profile- popup-actionable js-original-tweet my-tweet" data-tweet-id="515380319977893890"data-item-id="515380319977893890" data-name="" data-user-id="2665607941" data-expanded-footer="<div class="js-tweet-details-fixer tweet-details-fixer">
<div class="entities-media-container js-media-container" style="min-height:0px">
</div>
<div class="js-machine-translated-tweet-container"></div>
<div class="js-tweet-stats-container tweet-stats-container ">
</div>
<div class="client-and-actions">
<span class="metadata">
<span>11:00 PM - 25 Sep 2014</span>
&middot; <a class="permalink-link js-permalink js-nav" href="/status/515380319977893890" tabindex="-1">Details</a>
</span>
</div>
</div>
" data-you-follow="false"data-you-block="false">" ;
echo "<div class="content">" ;
echo "<div class="stream-item-header">" ;
echo "<a class="account-group js-account-group js-action-profile js-user-profile-link js-nav" data-user-id="2665607941">
<img class="avatar js-action-profile-avatar" src="https://pbs.twimg.com/profile_images/506790785572814848/vdj_UAuZ_bigger.jpeg" alt="">
<strong class="fullname js-action-profile-name show-popup-with-id" data-aria-label-part> </strong>
<span>‏</span><span class="username js-action-profile-name" data-aria-label-part><s></s><b> </b></span>
</a>" ;
echo "<small class="time">
<a class="tweet-timestamp js-permalink js-nav js-tooltip" title="11:00 PM - 25 Sep 2014" ><span class="_timestamp js-short-timestamp "
data-aria-label-part="last" data-time="1411711218" data-time-ms="1411711218000" data-long-form="true">Sep 25</span></a>
</small>" ;
echo"</div>";
echo "<p class="js-tweet-text tweet-text" lang="en" data-aria-label-part="0"> </p>" ;
echo "<div class="stream-item-footer">";
echo "<ul class="tweet-actions js-actions">";
echo "<li class="more-tweet-actions">";
echo "<div class="action-more-container">";
echo "<div class="dropdown">";
echo "<button type="button" class="btn-link with-icn dropdown-toggle js-dropdown-toggle js-tooltip">";
echo "<span class="Icon Icon--delete"></span>";
echo "<b>Delete</b>";
echo "</button>";
echo "<div class="dropdown-menu">";
echo "<div class="dropdown-caret">";
echo "<div class="caret-outer"></div>";
echo "<div class="caret-inner"></div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</div>";
After Scott's answer I changed my code , but still it is not working and I am not getting it.
echo "<div class=\"tweet original-tweet js-stream-tweet js-actionable-tweet js-profile-popup-actionable js-original-tweet
my-tweet\" data-tweet-id="515380319977893890\"data-item-id=\"515380319977893890\" data-name=\"\" data-user-id=\"2665607941\"
data-expanded-footer=\"<div class="js-tweet-details-fixer tweet-details-fixer">
<div class="entities-media-container js-media-container" style="min-height:0px">
</div>
<div class="js-machine-translated-tweet-container"></div>
<div class="js-tweet-stats-container tweet-stats-container ">
</div>
<div class="client-and-actions">
<span class="metadata">
<span>11:00 PM - 25 Sep 2014</span>
· <a class="permalink-link js-permalink js-nav" href="/status/515380319977893890" tabindex="-1">Details</a>
</span>
</div>
</div>
"
data-you-follow=\"false\"data-you-block=\"false\">" ;
echo "" ;
echo "<div class=\"stream-item-header\">" ;
echo "<a class=\"account-group js-account-group js-action-profile js-user-profile-link js-nav\" data-user-id=\"2665607941\
">
<img class=\"avatar js-action-profile-avatar\" src=\"https://pbs.twimg.com/profile_images/506790785572814848/vdj_UAuZ_bigger.jpeg\" alt=\"\">
<strong class=\"fullname js-action-profile-name show-popup-with-id\" data-aria-label-part> </strong>
<span>‏</span><span class=\"username js-action-profile-name\" data-aria-label-part><s></s><b> </b></span>
</a>" ;
echo "<small class=\"time\">
<a class=\"tweet-timestamp js-permalink js-nav js-tooltip\" title=\"11:00 PM - 25 Sep 2014\" ><span class=\"_timestamp js-short-timestamp \"
data-aria-label-part=\"last\" data-time=\"1411711218\" data-time-ms=\"1411711218000\" data-long-form=\"true\">Sep 25</span></a>
</small>" ;
echo"</div>";
echo "<p class=\"js-tweet-text tweet-text\" lang=\"en\" data-aria-label-part=\"0\"> </p>" ;
echo "<div class=\"stream-item-footer\">";
echo "<ul class=\"tweet-actions js-actions">";
echo "<li class=\"more-tweet-actions\">";
echo "<div class=\"action-more-container\">";
echo "<div class=\"dropdown\">";
echo "<button type=\"button" class=\"btn-link with-icn dropdown-toggle js-dropdown-toggle js-tooltip\">";
echo "<span class=\"Icon Icon--delete\"></span>";
echo "<b>Delete</b>";
echo "</button>";
echo "<div class=\"dropdown-menu\">";
echo "<div class=\"dropdown-caret\">";
echo "<div class=\"caret-outer\"></div>";
echo "<div class=\"caret-inner\"></div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</li>";
echo "</ul>";
echo "</div>";
echo "</div>";
echo "</div>";
Check your single and double quotes. The strings are being returned are being truncated. This is invalid:
echo "<div class="stream-item-header">" ;
Change it to:
echo "<div class=\"stream-item-header\">" ;
Or:
echo "<div class='stream-item-header'>" ;
And repeat this fix for each of your echo lines.
For example, this:
echo "<div class="tweet original-tweet js-stream-tweet js-actionable-tweet js-profile- popup-actionable js-original-tweet my-tweet" data-tweet-id="515380319977893890"data-item-id="515380319977893890" data-name="" data-user-id="2665607941" data-expanded-footer="<div class="js-tweet-details-fixer tweet-details-fixer">
<div class="entities-media-container js-media-container" style="min-height:0px">
</div>
<div class="js-machine-translated-tweet-container"></div>
<div class="js-tweet-stats-container tweet-stats-container ">
</div>
<div class="client-and-actions">
<span class="metadata">
<span>11:00 PM - 25 Sep 2014</span>
&middot; <a class="permalink-link js-permalink js-nav" href="/status/515380319977893890" tabindex="-1">Details</a>
</span>
</div>
</div>
" data-you-follow="false"data-you-block="false">" ;
Becomes this:
echo "<div class=\"tweet original-tweet js-stream-tweet js-actionable-tweet js-profile- popup-actionable js-original-tweet my-tweet\" data-tweet-id=\"515380319977893890\" data-item-id=\"515380319977893890\" data-name=\"\" data-user-id=\"2665607941\" data-expanded-footer=\"<div class="js-tweet-details-fixer tweet-details-fixer">
<div class="entities-media-container js-media-container" style="min-height:0px">
</div>
<div class="js-machine-translated-tweet-container"></div>
<div class="js-tweet-stats-container tweet-stats-container ">
</div>
<div class="client-and-actions">
<span class="metadata">
<span>11:00 PM - 25 Sep 2014</span>
&middot; <a class="permalink-link js-permalink js-nav" href="/status/515380319977893890" tabindex="-1">Details</a>
</span>
</div>
</div>
\" data-you-follow=\"false\" data-you-block=\"false\">" ;
For a more advanced trick, you can move your entire HTML to a separate file, an HTML template if you will. Then read in the file contents via PHP and find/replace the variables or dynamic parts as you need. This may be beyond the scope of your question however.
the quotes inside the echo need to be escaped:
echo "<div class=\"stream-item-footer\">";
Escape the quotes with \
echo "<div class=\"content\">" ;
Works for me:
echo '<div class="content">';
echo '<div class="stream-item-header">';
echo '<a class="account-group js-account-group js-action-profile js-user-profile-link js-nav" data-user-id="2665607941">
<img class="avatar js-action-profile-avatar" src="https://pbs.twimg.com/profile_images/506790785572814848/vdj_UAuZ_bigger.jpeg" alt="">
<strong class="fullname js-action-profile-name show-popup-with-id" data-aria-label-part> </strong>
<span>‏</span><span class="username js-action-profile-name" data-aria-label-part><s></s><b> </b></span>
</a>';
echo '<small class="time">
<a class="tweet-timestamp js-permalink js-nav js-tooltip" title="11:00 PM - 25 Sep 2014" ><span class="_timestamp js-short-timestamp "
data-aria-label-part="last" data-time="1411711218" data-time-ms="1411711218000" data-long-form="true">Sep 25</span></a>
</small>';
echo '</div>';
echo '<p class="js-tweet-text tweet-text" lang="en" data-aria-label-part="0"> </p>';
echo '<div class="stream-item-footer">';
echo '<ul class="tweet-actions js-actions">';
echo '<li class="more-tweet-actions">';
echo '<div class="action-more-container">';
echo '<div class="dropdown">';
echo '<button type="button" class="btn-link with-icn dropdown-toggle js-dropdown-toggle js-tooltip">';
echo '<span class="Icon Icon--delete"></span>';
echo '<b>Delete</b>';
echo '</button>';
echo '<div class="dropdown-menu">';
echo '<div class="dropdown-caret">';
echo '<div class="caret-outer"></div>';
echo '<div class="caret-inner"></div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
I'l write here my response dude, and hope i'm helping you. But there's nothing new, as Scott say, you missed a lot of double quote and IMHO you're a crazy boy doing it manually (in good sense).
Take you're JSON array and use the function i've linked in the comment in a way like this(hoping you have a similar situation, in other case is the same but you have to complex the code, maybe):
....
for($i=0; $i<sizeof($jsonarray); $i++){
echo addslashes($jsonarray[$i]);
}
....
In this way all of your code it's escaped, and if the error persist it means that's the problem is elsewhere

How do I get this bit of PHP to output in this table?

This is the code
for($r=1; $r<=10; $r++){
if($shirt_info[$r][0]!='Select One')
{
echo '<div class='shirtinfo'>Order $r: </div>';
echo '<div class='shirtinfo'>Size: '.$shirt_info[$r][0].'</div>';
echo '<div class='shirtinfo'>Price: '.$shirt_info[$r][1].'</div>';
echo '<div class='shirtinfo'>Qty: '.$shirt_info[$r][2].'</div>';
echo '<div class='shirtinfo'>SPE: '.$shirt_info[$r][5].'</div>';
echo '<div class='shirtinfo'>LIA: '.$shirt_info[$r][6].'</div>';
echo '<div class='shirtinfo'>Vendor: '.$shirt_info[$r][7].'</div>';
echo '<div class='shirtinfo'>Style: '.$shirt_info[$r][8].'</div>';
echo '<div class='shirtinfo'>Color: '.$shirt_info[$r][9].'</div>';
echo '<div style='clear:both;'></div>';
}}
and this is the result http://www.redfivedesigns.com/screenshot2.jpg
From php manual:
For information on how strings behave, especially with regard to usage
of single quotes, double quotes, and escape sequences, see the Strings
entry in the Types section of the manual.
http://www.php.net/manual/en/language.types.string.php
// Outputs: Arnold once said: "I'll be back"
echo 'Arnold once said: "I\'ll be back"';
Escape your quotes or use double quotes:
Escaping:
echo '<div class=\'shirtinfo\'>Order $r: </div>';
echo '<div class=\'shirtinfo\'>Size: '.$shirt_info[$r][0].'</div>';
echo '<div class=\'shirtinfo\'>Price: '.$shirt_info[$r][1].'</div>';
echo '<div class=\'shirtinfo\'>Qty: '.$shirt_info[$r][2].'</div>';
echo '<div class=\'shirtinfo\'>SPE: '.$shirt_info[$r][5].'</div>';
echo '<div class=\'shirtinfo\'>LIA: '.$shirt_info[$r][6].'</div>';
echo '<div class=\'shirtinfo\'>Vendor: '.$shirt_info[$r][7].'</div>';
echo '<div class=\'shirtinfo\'>Style: '.$shirt_info[$r][8].'</div>';
echo '<div class=\'shirtinfo\'>Color: '.$shirt_info[$r][9].'</div>';
echo '<div style=\'clear:both;\'></div>';
Using double quotes:
echo '<div class="shirtinfo">Order $r: </div>';
echo '<div class="shirtinfo">Size: '.$shirt_info[$r][0].'</div>';
echo '<div class="shirtinfo">Price: '.$shirt_info[$r][1].'</div>';
echo '<div class="shirtinfo">Qty: '.$shirt_info[$r][2].'</div>';
echo '<div class="shirtinfo">SPE: '.$shirt_info[$r][5].'</div>';
echo '<div class="shirtinfo">LIA: '.$shirt_info[$r][6].'</div>';
echo '<div class="shirtinfo">Vendor: '.$shirt_info[$r][7].'</div>';
echo '<div class="shirtinfo">Style: '.$shirt_info[$r][8].'</div>';
echo '<div class="shirtinfo">Color: '.$shirt_info[$r][9].'</div>';
echo '<div style="clear:both;"></div>';
Also, I think you mean echo '<div class="shirtinfo">Order '.$r.': </div>'; instead of echo '<div class="shirtinfo">Order $r: </div>';

Categories