<?php session_start();
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in'])
{
header('Location: /admin');
}
include 'includes/header.inc'; ?>
<div class="main_content_wrapper">
<div class="main_content limit_main_content_width margin_center p20">
<div class="question_wrapper main_content_content homepage_section" style='margin-top: 20px'>
<div>Ask any cooking related doubts or learn from already answered quesetions.</div>
</div>
<div class="question_wrapper main_content_content homepage_section">
<div class='big_heading'>Ask your doubt</div>
<div class="question_wrapper_content question_div_wrapper mb10">
<div class="question_wrapper_content question_div_wrapper placeholder_text js_main_question_placeholder">Write your question here</div>
<div class='question_wrapper_content question_div_wrapper ask_question_box p20 subtle_border radius3 mb10 js_main_question_value js_main_question_input' contenteditable='true'></div>
<input type="email" class="p20 subtle_border question_wrapper_content email_input js_main_email_value" placeholder='Enter your email here'>
<div class="g-recaptcha mt10" data-sitekey="6LcIo9oSAAAAAPTdolZGu6RoMDybW0Q66-TLTkbV"></div>
</div>
<div class="everyOtherGreenButton inline_middle question_wrapper_content submit_main_question js_submit_main_question center_align">ASK ME NOW</div>
<div class="everyOtherGreenButton inline_middle question_wrapper_content sending_main_question js_sending_main_question center_align noafter">SENDING...</div>
<div class='inline_middle bold question_wrapper_content response_message question_sent_success js_question_sent_success'>Success! You will receive an email when Kavita answers the question. :D</div>
<div class='inline_middle bold question_wrapper_content response_message question_sent_error js_question_sent_error'>There was an unknown error :( Please try again or refresh the page.</div>
</div>
<div class="question_wrapper main_content_content homepage_section">
<div class='big_heading'>Recently answered questions</div>
<div class="recently_answered_wrapper">
<?php
include 'includes/database_login.inc';
$sql_query = "SELECT * FROM posts WHERE published = 1 and deleted = 0 and answered = 1 ORDER BY answered_on DESC LIMIT 5";
$result = mysqli_query($conn, $sql_query);
echo $result->num_rows;
$rowCount = '2';
echo $rowCount;
$p_index = 0;
while($row = mysqli_fetch_assoc($result)) {
?><a href='/post.php?id=<?php echo $row["id"]; ?>' class="recently_answered_wrapper_content recently_answered_question inline_middle subtle_border recent<?php echo $p_index%4; ?>">
<div class="title p10 bold">Q. <?php echo $row['title']; ?></div>
<div class="answer p10" style='padding-top: 0'><?php echo $row['answer']; ?></div>
</a><?php //$p_index++;
}
$conn->close(); ?><a href='/posts.php' class="recently_answered_wrapper_content recently_answered_question noborder view_all_answered_questions inline_middle center_align">
<div class="p10 bold" style="margin-top: 55px;">VIEW ALL ANSWERS</div>
</a>
</div>
</div>
</div>
This is a snippet of my php code. I have somehow figured that the error Unexpected end of file is happening here. But I don't see why.
UPDATE
When I comment out echo $rowCount, it doesnt show any errors.
Related
So i want to place this code below
$keyword="";
if (isset($_POST['searchpakaian'])) {
$keyword = $_POST['searchpakaian'];
}
$query = mysqli_query($conn,"SELECT * FROM tbl_pakaian WHERE nama_pakaian LIKE '%".$keyword."%' ORDER BY id ASC limit 0,6");
$hitung_data = mysqli_num_rows($query);
if ($hitung_data > 0) {
while ($row = mysqli_fetch_array($query)) {
?>
<div class="col">
<div class="card h-100">
<div class="card-img-wrap ">
<img src="img/Galeri/pakaian/<?php echo $row['gambar_pakaian'] ?>" class="card-img-top" alt="...">
</div>
<div class="card-body">
<h5 class="card-title"><?php echo $row['nama_pakaian'] ?></h5>
<p class="card-text "><?php echo $row['keterangan_pakaian'] ?></p>
</div>
</div>
</div>
<?php } } else { ?>
<center><h4>Tidak Ada Data</h4></center>
<?php } ?>
On if conditional statement
if($req == 'something'){
}
Here is my full code
<?php
include '../koneksi.php';
$req = $_REQUEST['req'];
$keyword="";
if (isset($_POST['searchpakaian'])) {
$keyword = $_POST['searchpakaian'];
}
$query = mysqli_query($conn,"SELECT * FROM tbl_pakaian WHERE nama_pakaian LIKE '%".$keyword."%' ORDER BY id ASC limit 0,6");
$hitung_data = mysqli_num_rows($query);
if ($hitung_data > 0) {
while ($row = mysqli_fetch_array($query)) {
?>
<div class="col">
<div class="card h-100">
<div class="card-img-wrap ">
<img src="img/Galeri/pakaian/<?php echo $row['gambar_pakaian'] ?>" class="card-img-top" alt="...">
</div>
<div class="card-body">
<h5 class="card-title"><?php echo $row['nama_pakaian'] ?></h5>
<p class="card-text "><?php echo $row['keterangan_pakaian'] ?></p>
</div>
</div>
</div>
<?php } } else { ?>
<center><h4>Tidak Ada Data</h4></center>
<?php } ?>
If i just copy the code to the if conditional statement code, it just say 'unexpected end of file'
What should i do?
The syntax error are vey simple to find just confirm that when you copy inside the if, dont repeat php keys as and the echo finish it with ;
<?php echo('hello world'); ?>
OR the same echo but simple deleting the php tag by = simbol (only work with echo)
<?= 'hello world' ?>
thanks for taking a look at my question.
I'm trying to get PHP to output bootstrap rows that only contain 2 col-md-6 columns, instead of outputting 1 row with 1 col for each iteration.
Searching here on Stackoverflow I found a solution that makes sense but when I implement it, the HTML that I get makes no sense!
I should be getting this:
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
...But I'm getting this:
<div class="col-md-6">
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
</div>
CODE:
<?php
require_once('somedb.php');
$query = mysqli_query($conn, "SELECT * FROM notyourbusiness");
$rowCount = mysqli_num_rows($query);
$i = 0;
echo '<div class="row">';
if($rowCount > 0){
while($row = mysqli_fetch_assoc($query)){
?>
<?php echo '<div class="col-md-6">'; ?>
<img src="img/project/<?php echo $row['thumb'] ?>" class="work-thumbnail" width="100">
<h2><?php echo $row["name"]; ?></h2>
<?php echo '</div>'; ?>
<?php
$i++;
if ($i%2 == 0) echo '</div><div class="row">';
} ?>
<?php } ?>
</div>
Any help will be greatly appreciated, thanks!
Can you provide us more information? It seems that the first is comming from outside of this php code.
You can try this
<?php
$query = mysqli_query($conn, "SELECT * FROM notyourbusiness");
$rowCount = mysqli_num_rows($query);
$i = 0;
if($rowCount > 0){
while($row = mysqli_fetch_assoc($query)){
$row_draw = ($i % 2 == 0) ? true : false;
# Start row div
if ($row_draw)
{
print "<div class='row'>";
}
# Print Column
print "<div class='col-md-6'>";
?>
<img src="img/project/<?php echo $row['thumb'] ?>" class="work-thumbnail" width="100">
<a href="javascript:void(0);">
<h2><?php echo $row["name"]; ?></h2>
</a>
<?php
print "</div>";
# End row div
if ($row_draw)
{
print "</div>";
}
$i++;
}
}
?>
I am developing a simple project but encountered a problem which I can not find solution.
The follow php code:
<?php include "header.php"; ?>
<?php
$subtitle = "Os teus animes favoritos diariamente!";
$conn = mysqli_connect("$host","$dbuser","$dbpw","$db");
if (mysqli_connect_errno())
{
echo "Falha ao ligar à Base de Dados: " . mysqli_connect_error();
}
$result = mysqli_query($conn, "SELECT * FROM m_capitulos ORDER BY 'm_capitulos'.'id_cap' DESC LIMIT 30") or die(mysqli_error($conn));
mysqli_close($conn);
?>
<section class="mbr-section mbr-section--relative mbr-section--fixed-size mbr-after-navbar" id="features1-3" style="background-color: rgb(255, 255, 255);">
<div class="mbr-section__container container"><!-- "mbr-section__container--std-top-padding" para dar padding no top! -->
<div class="mbr-section__row row">
<?php while ($row = mysqli_fetch_array($result)){ ?>
<div class="mbr-section__col col-xs-12 col-sm-4">
<div class="mbr-section__container mbr-section__container--center mbr-section__container--middle">
<figure class="mbr-figure"><img class="mbr-figure__img" src="<?php echo $row['p_thumb']; ?>"></figure>
</div>
<div class="mbr-section__container mbr-section__container--middle">
<div class="mbr-header mbr-header--reduce mbr-header--center mbr-header--wysiwyg">
<h3 class="mbr-header__text"><?php echo $row['nombre_cap']; ?></h3>
</div>
</div>
<div class="mbr-section__container mbr-section__container--last">
<div class="mbr-buttons mbr-buttons--center">DOWNLOAD</div>
<br>
<div class="mbr-buttons mbr-buttons--center">DOWNLOAD</div>
<br>
<div class="mbr-buttons mbr-buttons--center">ASSISTIR</div>
</div>
</div>
<?php } ?>
</div>
</div>
</section>
<?php include "footer.php"; ?>
But when I remove the page css the empty space between the results disappears.
The Empty Space on the midle of my content box :
The result on the right just above the space is shorter, thus the next element goes below it instead of going to next row. I suggest you split elements into groups of 3 so that they can go into rows, or alternatively set the height for each result so that they all line up.
The example below adds a counter; every time you run through an element it checks if the element count divides by three, and if so, starts a new row. The same check is done at the end, except that it checks whether the element is the last in the row-of-three, and if so, ends the row tag.
<?php
$i = 0;
while ($row = mysqli_fetch_array($result)){ ?>
<?php if ($i % 3 == 0): ?><div class="row"><?php endif; ?>
<div class="mbr-section__col col-xs-12 col-sm-4">
<div class="mbr-section__container mbr-section__container--center mbr-section__container--middle">
<figure class="mbr-figure"><img class="mbr-figure__img" src="<?php echo $row['p_thumb']; ?>"></figure>
</div>
<div class="mbr-section__container mbr-section__container--middle">
<div class="mbr-header mbr-header--reduce mbr-header--center mbr-header--wysiwyg">
<h3 class="mbr-header__text"><?php echo $row['nombre_cap']; ?></h3>
</div>
</div>
<div class="mbr-section__container mbr-section__container--last">
<div class="mbr-buttons mbr-buttons--center">DOWNLOAD</div>
<br>
<div class="mbr-buttons mbr-buttons--center">DOWNLOAD</div>
<br>
<div class="mbr-buttons mbr-buttons--center">ASSISTIR</div>
</div>
</div>
<?php if ($i % 3 == 2): ?></div><?php endif;
$i++
?>
<?php } ?>
i'm trying to relay the id through this if statement to see if the file exits. If it does I want to use the id to grab that image from the corporation-logos/ folder. If not i'd like to simply show a default image. I can't tell if its catching the id or not as it keeps spitting out the default.
if ($productCount > 0) {
// get all the product details
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$imgStock="http://www.stocksandstocks.com/corporation-logos/$id.jpg";
$http_image="http://www.stocksandstocks.com/images/no-logo-default.png";
if(file_exists($imgStock))
{
$imgPick = "$imgStock";
}
else
{
$imgPick = "$http_image";
}
echo "
<ul>
<li>
<div class='wrapPicks'>
<div class='symbolPicks'>
<div class='quoteTitle'>$quoteTitle</div>
</div>
<div class='bgPicks'>
<img src='$imgPick' height='50px' widht='80px' alt='stock symbol $quoteTitle logo' />
<div class='separateWrap'>
<div class='quote'>
<b>Entry Price:</b> $$entry
</div>
<div class='quote'>
<b>Last trade:</b> $$lastPrice
</div>
</div>
<div class='quoteReturn'>
<b>Open P/L:</b>
<div class='bigGreen'>
<span style=\"color: $color\">$positive $$profit </span>
</div>
</div>
</div>
</div>
</li>
</ul>";
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.