echo a div class - php

I have a problem, when I try to echo a div class. When I put the following code in my template, it detects only the closing tag and not the opening. So, my webpage is ruined:
<div id="container">
<div id="pagina_text">
{{ CONTENT }}
<br />
<div class="rw-ui-container"></div>
<br /><br />
<?php
var_dump($_GET['categorie']);
if(isset($_GET['categorie']) && $_GET['categorie'] === "navigatie_bar")
{
echo "<div class=\"fb-comments\" data-href=\"http://alledaagsetips.nl\" data-numposts=\"10\" data-colorscheme=\"light\"></div>";
}
?>
</div> <!-- end pagina_text -->
</div><!-- end container -->
Does someone know what am I doing wrong?

Replace single quote with double quote.
Change
<?php
if(strcmp($_GET['categorie'], "navigatie_bar") != 0)
{
echo '<div class="fb-comments" data-href="http://alledaagsetips.nl" data-numposts="10" data-colorscheme="light"></div>';
}
?>
to this
<?php
if(strcmp($_GET['categorie'], 'navigatie_bar') != 0)
{
echo "<div class='fb-comments' data-href='http://alledaagsetips.nl' data-numposts='10' data-colorscheme='light'></div>";
}
?>

Are you sure the "IF" condition is working?
Perhaps with a simple string comparison like so :
<?php
if(isset($_GET['categorie']) && $_GET['categorie'] === "navigatie_bar") {
echo '<div class="fb-comments" data-href="http://alledaagsetips.nl" data-numposts="10" data-colorscheme="light"></div>';
}
?>

replace single quotes with double and vice versa
echo "<div class='fb-comments' data-href='http://alledaagsetips.nl' data-numposts='10' data-colorscheme='light'></div>";
or use the same for all but with backslash, just to not get confused
echo "<div class=\"fb-comments\" data-href=\"http://alledaagsetips.nl\" data-numposts=\"10\" data-colorscheme=\"light\"></div>";

<div id="container">
<div id="pagina_text">
{{ CONTENT }}
<br>
<div class="rw-ui-container"></div>
<br><br>
<?php if ( ! empty($_REQUEST['categorie']) and $_REQUEST['categorie'] == 'navigatie_bar'): ?>
<div class="fb-comments" data-href="http://alledaagsetips.nl" data-numposts="10" data-colorscheme="light"></div>
<?php endif; ?>
</div> <!-- end pagina_text -->
</div><!-- end container -->

Related

PHP if else statement producing unwanted line breaks

I'm using a PHP if else statement to ignore a custom field 'thingstodo' if it's empty. I have got the following code to work but it's putting unwanted line-breaks after every paragraph tag in my content. Where am I going wrong?
<?php if (get_field('gettingthere')): ?>
<div class="inprofile3col">
<h2>Getting there</h2>
<span class="content">
<?php echo get_post_meta($post->ID, 'gettingthere', true); ?>
</span>
<?php endif; ?>
<!-- ends Getting there -->
<!-- Things to do begins -->
<?php if (get_field('thingstodo')): ?>
<h2>Things to do</h2>
<?php endif; ?>
<span class="content">
<?php
$value = get_field('thingstodo');
if ($value) {
echo $value;
} else {
echo '';
}
?>
</span>
</div>
Here
<span class="content">
<?php
$value = get_field('thingstodo');
if ($value ) {echo $value ;} else {echo '';}
?>
</span>
you still have an output if the field is empty: the empty span-tag:
<span class="content">
echo '';
</span>
You should remove line breaks from thingstodo and avoid empty html tags. Here is the updated mark up:
<?php if( get_field('gettingthere') ): ?>
<div class="inprofile3col">
<h2>Getting there</h2>
<span class="content">
<?php echo get_post_meta( $post->ID, 'gettingthere', true ) ; ?>
</span>
<?php endif; ?>
<!-- ends Getting there -->
<!-- Things to do begins -->
<?php if( get_field('thingstodo') && !empty(trim(get_field('thingstodo')))) { ?>
<h2>Things to do</h2>
<span class="content">
<?php
$value = preg_replace('/\s\s+/',' ',trim(get_field('thingstodo')));
if ($value) {echo $value ;} else {echo '';}
?>
</span>
<?php } ?>
</div>

I am editing php codes ( in index.php) to my website but I cant see any changes on the website

Here is the part of my index.php::
<?php include("header.php");
$containerClass="container"; $rowClass="row";
?>
<div id='wrapper'>
<div class='<?php print $containerClass; ?>' >
<?php
if(($ptype=="" && $fullScreenEnabled!="true") || $ptype=="home" || $ptype=="viewMemberListing" || $ptype=="viewFullListing" || ($ptype=="showOnMap" && $fullScreenEnabled!="true") || $ptype=="adminOptions" || $ptype=="UpdateAdminOptions" || $ptype=="allMembers" || $ptype=="contactus" || $ptype=="page" || $_GET["cpage"]==1){
if($ptype=="viewMemberListing") $reextraMessage=" ".$relanguage_tags["your listings"]." ";
else $reextraMessage=" ".$relanguage_tags["all listings"]." ";
?>
<div class='<?php print $rowClass; ?>'>
<div class='col-md-4 col-lg-4 sbar'>
<div id="sidebar">
<div id="sidebar1">
<div class='a_block'>
<h3><?php print $relanguage_tags["Search"].$reextraMessage; ?></h3>
<?php include("reSearchForm.php"); ?>
</div>
</div> <!-- end #sidebar1 -->
To this I add:
<div id="sidebar1">
<div class='a_block'>
<h3><?php print $relanguage_tags["Add Listing"].$reextraMessage; ?></h3>
<?php include("submitReListing.php"); ?>
</div>
</div> <!-- end #sidebar1 -->
// submitReListing.php is already there on my website and working but i just want this button to be on the home page so that users can search and submit listing from the homepage.
After I added the second part, I go to filezilla and it asks me if i want to upload file back to the server. I select yes. ( Do i need to check "Finish editing and delete local file"??) But i dont see any changes in my website.
Please suggest.
I am new to php so please bear with these questions. I can also provide the entire index file or other file if required. Thanks
Entire code:
<?php include("header.php");
$containerClass="container"; $rowClass="row";
?>
<div id='wrapper'>
<div class='<?php print $containerClass; ?>' >
<?php
if(($ptype=="" && $fullScreenEnabled!="true") || $ptype=="home" || $ptype=="viewMemberListing" || $ptype=="viewFullListing" || ($ptype=="showOnMap" && $fullScreenEnabled!="true") || $ptype=="adminOptions" || $ptype=="UpdateAdminOptions" || $ptype=="allMembers" || $ptype=="contactus" || $ptype=="page" || $_GET["cpage"]==1){
if($ptype=="viewMemberListing") $reextraMessage=" ".$relanguage_tags["your listings"]." ";
else $reextraMessage=" ".$relanguage_tags["all listings"]." ";
?>
<div class='<?php print $rowClass; ?>'>
<div class='col-md-4 col-lg-4 sbar'>
<div id="sidebar">
<div id="sidebar1">
<div class='a_block'>
<h3><?php print $relanguage_tags["Search"].$reextraMessage; ?></h3>
<?php include("reSearchForm.php"); ?>
</div>
</div> <!-- end #sidebar1 -->
<div id="sidebar2">
<div class='a_block'>
<h3><?php print $relanguage_tags["Add listing"].$reextraMessage; ?></h3>
<?php include("submitReListing.php"); ?>
</div>
</div> <!-- end #sidebar1 -->
<?php if(trim($sidebarad)!=""){ ?>
<div id='sidebarad1'><?php print $sidebarad; ?></div>
<?php } ?>
</div> <!-- end #sidebar -->
</div>
<div class='col-md-8 col-lg-8'>
<div id="mainContent">
<div id='reResults'>
<?php if($ptype=="viewFullListing") include("viewFullListing.php"); ?>
<?php if($ptype=="adminOptions" || $ptype=="UpdateAdminOptions") include("adminOptions.php"); ?>
<?php if($ptype=="allMembers") include("allMembers.php"); ?>
<?php if($ptype=="showOnMap" && $fullScreenEnabled!="true") print "<div id='mapResults'></div>" ?>
<?php if($ptype=="contactus") include("contactus.php"); ?>
<?php if($ptype=="page"){ include("page.php"); $fullScreenEnabled="false"; } ?>
<?php if($_GET["cpage"]==1) include("pluginPage.php"); ?>
<?php if($ptype=="categoriesEdit") loadPage("categoriesEdit.php"); ?>
</div>
</div><!-- end #mainContent -->
</div>
</div>
<?php
}
if($fullScreenEnabled=="true"){
?>
<div style="width:100%;">
<div style="width:248px;" id='mapSidebar' >
<div id='showbar' data-original-title="<?php print $relanguage_tags["Show the sidebar"]; ?>"></div>
<div id="sidebar" class='ui-widget-content'>
<div id="sidebarTabs"><div id='hidebar' data-original-title="<?php print $relanguage_tags["Hide the sidebar"]; ?>"></div>
<ul>
<li><?php print __("Search"); ?></li>
<li id='resultTab'><?php print __("Results"); ?> </li>
</ul>
<div id="sidebar1">
<div class='a_block'>
<!-- <div id="logo2"></div> -->
<h3><?php print $relanguage_tags["Search"].$reextraMessage; ?></h3>
<?php include("reSearchForm.php"); ?>
</div>
<?php if(trim($sidebarad)!=""){ ?>
<div id='sidebarad1'><?php print $sidebarad; ?></div>
<?php } ?>
</div> <!-- end #sidebar1 -->
<div id='sidebarResults'></div>
</div>
</div> <!-- end #sidebar -->
</div> <!-- end mapSidebar -->
<div style="width:80%;" id='mapContainer'>
<div id="mainContent"><div id='mapResults'></div><div id='theListing'></div> <div id='MapLoadingImage'><img src='images/maploading1.gif' alt='loading' /> </div>
<div id='modeButton'><a class='btn btn-primary btn-large' href='index.php? ptype=home&<?php print str_replace("ptype=", "",htmlspecialchars($_SERVER['QUERY_STRING'])); ?>'><i class='icon-align- justify'></i> <?php print $relanguage_tags["Switch to text mode"]; ?></a></div>
</div> <!-- end span8 -->
</div>
</div> <!-- end row -->
<div class="nolisting alert alert-info"><a class="close" onclick="$('.alert').hide()" data-dismiss="alert" href="#">x</a>
<h4 style="text-align:'center'"><?php print $relanguage_tags["No listings found for your search criteria"]; ?>.
<?php if($isThisDemo=="yes") print "The demo has limited listings." ?>
</h4></div>
<?php
}
if($ptype=="checklogin") loadPage("checklogin.php");
if($ptype=="submitReListing") loadPage("submitReListing.php");
if($ptype=="addReListing") loadPage("addReListing.php");
if($ptype=="editReListingForm") loadPage("editReListingForm.php");
if($ptype=="updateReListing") loadPage("updateReListing.php");
if($ptype=="myprofile") loadPage("myprofile.php");
if($ptype=="languagetags" || $ptype=="updateLanguageTags") loadPage("languagetags.php");
if($ptype=="categories" || $ptype=="updateCategories") loadPage("categories.php");
if($ptype=="pricerange" || $ptype=="updatePriceRange") loadPage("pricerange.php");
if($ptype=="countries" || $ptype=="updateCountries") loadPage("countries.php");
if($ptype=="towns" || $ptype=="updateTowns") loadPage("towns.php");
if($ptype=="addeditpage") loadPage("addeditpage.php");
if($ptype=="oodle" || $ptype=="updateOodle") loadPage("plugins/oodle/options.php");
?>
<!--
<div id="a_c" style="display:none;"><?php print $authorization_code; ?></div>
<div id="p_c" style="display:none;"><?php print md5($purchase_code); ?> </div>
-->
</div>
</div>
<?php
//if($fullScreenEnabled!="true")
include("footer.php"); ?>
Please Check whether it is going into the IF statement.
Ok, so you need to test this out methodically. First you need to check if ANY changes you type are getting uploaded into the server and getting reflected on the website.
So edit your file again, type die("Updated code"); as the first line of your index.php and save the file. In the dialogue box that comes up (the one of which you have the screen shot), Just click yes.
Now hard-refresh the page and see if the text "Updated code" shows up. If yes, then we can move to second step. If no, then you got either a permission or a cache issue. To resolve it might take more expertise than you have. You could check if correct file permissions are available (though I doubt that is the reason, since you will get warnings if thats the case). In any case, right click the file - select File Permissions and make sure the write checkbox is checked (If you are unsure of your user then just check it for all three - user, group and public. Not very safe, but I do not think you are building the worlds most secure site at the moment in any case)
Next is to check if there is a cache issue. You can try opening the same URL is a different browser or you can try deleting all your cache and trying again.I do not think this might be a problem either (unless you have a caching layer like varnish or memcache and it is set up in a really really bad way)
This next thing is very important:
The more apparent reason seems to be that your code could possibly be wrong. You are thinking that the software is problematic that is why you are not seeing changes that you should. It is a common mistake that people think that there can be no problems with their code, but with everything else in the world. So I would advice you to start line by line debugging until you hit one line where what is printed is not what was expected. And begin from there.

Can't add Bootstrap Tab into php code

If I add this Bootstrap Tab into html code, it works perfectly:
<ul class="nav nav-tabs">
<li class="active">Hello</li>
<li>Empty</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="hello">
<h3>Hello my Friend!</h3>
<p>hello</p>
</div><!-- #end #hello -->
<div class="tab-pane" id="empty">
<h3>Just gonna be empty...</h3>
<p>Yup. Nothin' here.</p>
</div><!-- #end #empty -->
</div>
But in those tap I need to connect to my database so show some information, my code is:
<ul class="nav nav-tabs">
<li class="active">Facilities</li>
<li>Course Fee</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="facilities">
<h3>Just gonna be empty...</h3>
<p>Yup. Nothin' here.</p>
<?php echo "<table>";
$userpic = '<img src="images/user.png"/>';
while ($roww = mysqli_fetch_array($usercomment)){
$cm_fac = $roww['facilities'];
$name = $roww['UserName'];
$time = $roww['CmtDate'];
echo '<tr>';
echo '<td>';
//i put some info here as table
echo '</td>';
echo '</tr>';
}
echo "</table>";
?>
</div><!-- end of facilities-->
<div class="tab-pane" id="fee">
<h3>Hello my Friend!</h3>
<p>hello</p>
<?php echo "<table>";
$userpic = '<img src="images/user.png"/>';
while ($roww = mysqli_fetch_array($usercomment)){
$cm_fee = $roww['fee'];
$name = $roww['UserName'];
$time = $roww['CmtDate'];
echo '<tr>';
echo '<td>';
//some info here too
echo '</td>';
echo '</tr>';
}
echo "</table>";
?>
</div><!-- end of fee-->
</div> <!--end of tab-content-->
but it doesn't work. Can anyone show me my problem?
Thank you for your time.
You maybe can try this:
<div class="tab-pane" id="fee">
<h3>Hello my Friend!</h3>
<p>hello</p>
<!-- open the 'while' -->
<?php
while ($roww = mysqli_fetch_array($usercomment)){
$cm_fac = $roww['facilities'];
$name = $roww['UserName'];
$time = $roww['CmtDate'];
?>
<!-- your table -->
<table>
<tr>
<td>
<?php echo "your data here"; ?>
</td>
</tr>
</table>
<?php } ?> <!-- close the 'while' here -->
</div>
Check results of your query.
You can use $roww = mysqli_fetch_array($usercomment, MYSQLI_ASSOC); to fetch data.

javascript executing php code

i have a php web application project ... and i want to implement a javascript onclick code ..
for example :
when user clicks follow this post ... the MySQL query inserts into database that the user followed this ... so the page is refreshed and after that it will appear as FOLLOWED ..
what's the javascript code needed to do this ... or is there any example may fit ??
here's a sample code
<div id="main_content">
<?php
if(isset($_GET['et']))
{
$et = $_GET['et'];
}
$result = mysql_query("select * from events where event_type =$et") ;
require_once('queries/category_extract.php') ;
?>
<div id="body_content">
<div id="event_tag">
<a><?php echo $cattitle["categ_title"]?>s</a>
</div>
<?php
while($row=mysql_fetch_array($result) )
{
require('queries/followers_extract.php')
?>
<div id="postpreview">
<div id="postpreview_up">
<div id="postpreview_up_left">
<div id="postpreview_up_left_left">
<a>Event Title :</a>
</div>
<div id="postpreview_up_left_right">
<a><?php echo $row["event_title"] ?></a>
</div>
</div>
<div id="postpreview_up_right">
<img src="images/read_more.gif" />
</div>
</div>
<div id="postpreview_bottom">
<div id="postpreview_bottom_left">
<div id="postpreview_bottom_left_left">
<a>Date :</a>
</div>
<div id="postpreview_bottom_left_right">
<a><?php echo $row["event_date"] ?></a>
</div>
</div>
<div id="postpreview_bottom_right">
<div id="postpreview_bottom_right_left">
<?php
if($follower['follower_id'] ==NULL){echo " <img src='images/follow_button.jpg' /> " ; }
else { echo " <img src='images/follow_closed.jpg' /> " ;}
?>
</div>
<div id="postpreview_bottom_right_right">
<?php
if($follower['follower_id'] !=NULL){ echo " <img src='images/following_button.jpg' /> " ; }
else { echo " <img src='images/following_Closed.jpg' /> " ;}
?>
</div>
<div id="postpreview_bottom_right_right">
<?php
if($follower['follower_id'] !=NULL){ echo " <img src='images/unfollow_button.jpg' /> " ; }
else { echo " <img src='images/unfollow_closed.jpg' /> " ;}
?>
</div>
</div>
</div>
</div>
<div id="splitter"></div>
<?php
}
?>
<!--End Of Post Preview-->
<!--End Of Post Preview-->
ok go for this: http://www.9lessons.info/2009/04/exactly-twitter-like-follow-and-remove.html
you have to learn the basics as i read.

html, css and php website container div not containing

I am stuck and I am desperate. Here is the problem:
I have a div "container" that includes all the other divs.
But somehow the div ends where the first php statement is! Magic I say.
I want the container div to hold the whole page, but it reaches the first php statement (that includes the code from another file into the page) and ends. I can't find the reason.
Code.
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{subTITLE}<?php echo TITLE; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta http-equiv="description" content="{subDESCRIPTION}<?php echo DESCRIPTION; ?>">
<meta http-equiv="keywords" content="<?php echo KEYWORDS; ?>">
<link type="text/css" rel="stylesheet" href="<?php echo ABSWEBTPLPATH; ?>main.css">
</head>
<body>
<div class="superbar">
<div class="menuSearch">
<span>
<?php ShowSearchForm(); ?>
</span>
</div>
</div>
<div class="container">
<?php include(TPLPATH.'header.php'); ?>
<br/><br/><br/>
<div class="content">
<div class="contentLeft">
<div class="cLhead">
<h4>
Categories
</h4>
</div>
<ul class="categories">
<?php ShowMenu(); ?>
</ul>
</div>
<span class="contentRight">
<?php ListGoods(); ?>
</span>
</div>
<?php include(TPLPATH.'footer.php'); ?>
</div>
</body>
</html>
PHP of header.php
<div class="header-container">
<div class="wrapper">
</div>
<div id="header_top_right">
<div class="btn1">
<span class="menuPokupki"><div class="description">Мои покупки</div><div class="descriptionSub"><nobr>история покупок</nobr></div></span>
</div>
<div class="btn2">
<span>
<h5 >Мой магазин</h5>
</span>
</div>
<form action="<?php echo ABSWEBPATH; ?>ch_rt.php" method="post">
<span class="cnt">
Валюта:
<select name="rt" class="sorting">
<?php
session_start();
if(isset($_SESSION["rt"]) && !empty($_SESSION["rt"])) {
if($_SESSION["rt"] == "wmr" or $_SESSION["rt"] != "wmz" or $_SESSION["rt"] != "wme" or $_SESSION["rt"] != "wmu") {
echo "<option value=\"wmr\" selected=\"selected\">руб. (RUR)</option>\r\n"; }
else {echo "<option value=\"wmr\">руб. (RUR)</option>\r\n";}
if($_SESSION["rt"] == "wmz") {
echo "<option value=\"wmz\" selected=\"selected\">$ (USD)</option>\r\n"; }
else {echo "<option value=\"wmz\">$ (USD)</option>\r\n";}
if($_SESSION["rt"] == "wme") {
echo "<option value=\"wme\" selected=\"selected\">€ (EUR)</option>\r\n"; }
else {echo "<option value=\"wme\">€ (EUR)</option>\r\n";}
if($_SESSION["rt"] == "wmu") {
echo "<option value=\"wmu\" selected=\"selected\">грн. (UAH)</option>\r\n"; }
else {echo "<option value=\"wmu\">грн. (UAH)</option>\r\n";} }
else {
if(isset($default_rt) && !empty($default_rt)) {
if($default_rt == "wmr" or $default_rt != "wmz" or $default_rt != "wme" or $default_rt != "wmu") {
echo "<option value=\"wmr\" selected=\"selected\">руб. (RUR)</option>\r\n"; }
else {echo "<option value=\"wmr\">руб. (RUR)</option>\r\n";}
if($default_rt == "wmz") {
echo "<option value=\"wmz\" selected=\"selected\">$ (USD)</option>\r\n"; }
else {echo "<option value=\"wmz\">$ (USD)</option>\r\n";}
if($default_rt == "wme") {
echo "<option value=\"wme\" selected=\"selected\">€ (EUR)</option>\r\n"; }
else {echo "<option value=\"wme\">€ (EUR)</option>\r\n";}
if($default_rt == "wmu") {
echo "<option value=\"wmu\" selected=\"selected\">грн. (UAH)</option>\r\n"; }
else {echo "<option value=\"wmu\">грн. (UAH)</option>\r\n";} }
else {
echo "<option value=\"wmr\" selected=\"selected\">руб. (RUR)</option>
<option value=\"wmz\">$ (USD)</option>
<option value=\"wme\">€ (EUR)</option>
<option value=\"wmu\">грн. (UAH)</option>\r\n"; } }
?>
</select>
<input type="submit" value="Установить" class="button" />
</form></span></div>
</div>
<div class="subheader">
<ul class="menu">
<li class="menu1" noWrap>О магазине</li>
<li class="menu1" noWrap>Способы оплаты</li>
<li class="menu1" noWrap>Контакты</li>
<span class="filter">
<span class="sortingTitle">Сортировка:</span>
<span class="sortingSelect">
<?php GoodsSort(); ?>
</span>
</span>
</ul>
</div>
</div>
</div>
CSS has 500 lines so I uploaded it to pastebin
sorry for terrible crap code. I have to urgently edit someone else's and I already hate him
http://pastebin.com/6b5UC9mj
Too many closing divs in header.php
Take the last one out
Your span is closed outside the form. Your current structure is :
<form action="<?php echo ABSWEBPATH; ?>ch_rt.php" method="post">
<span class="cnt">
....
</form>
</span>
Must be:
<form action="<?php echo ABSWEBPATH; ?>ch_rt.php" method="post">
<span class="cnt">
....
</span>
</form>

Categories