<section class="latest-news-index">
<table style="width: 100%; max-width: 100%;margin-bottom: 20px; "class="table table-hover ">
<tbody><tr><td style="border-bottom: 1px solid #9e9e9e;border-top: none;font-size: 2.1em;font-weight: bold;" colspan="99" class="date-header"><?php echo date('m.d.y');?></td></tr>
<?php
$sayfa = $news->pager($SAYFA,15,'haber','h_id',"WHERE onay='1' AND time<='".time()."'");
$sql = $db->sql(
"SELECT haber.h_id,
haber.k_id,
haber.baslik,
haber.baslik_renk,
haber.resim,
haber.k_icerik,
haber.link,
haber.time,
kategori.baslik as kategori
FROM haber
LEFT JOIN kategori ON haber.k_id=kategori.k_id
WHERE kategori.onay='1'
AND haber.onay='1'
AND DATE(FROM_UNIXTIME(haber.time)) = DATE(SYSDATE())
ORDER BY haber.time DESC
"
);
if($db->num_rows($sql)>0):
$i = 1;
while($data = $db->f_array($sql)):
$id = $news->dataview($data['h_id']); // news id
$baslik = $news->dataview($data['baslik']); // news title
$baslik_renk= ($news->dataview($data['baslik_renk']) ? ' style="color:'.$news->dataview($data['baslik_renk']).';"' : ''); // title color
$resim = $news->dataview($data['resim']); // news image
$kIcerik = $news->dataview($data['k_icerik']); // News desc
$time = $news->dataview($data['time']); // News date
$kategori = $news->dataview($data['kategori']); // category
$haberlink = $news->dataview($data['link']); // seo_link
$link = ($haberlink == '' ? $news->url('haber',$id,$baslik) : $haberlink); // generation link
$photo = $news->dataview($data['fg_id']); // getting photo gallery id for news content
$video = $news->dataview($data['vd_id']); // getting video id for news content
?>
<tr class="item">
<?php if($sistem['iceriktarih']): ?>
<td class="time"><?=$news->saat($time)?></td>
<?php endif; ?>
<td class="category"><?=$kategori?> </td>
<td class="title"><b><?=$baslik?><span class="title-icons"></span></b></td>
</tr>
<?php
endwhile;
endif;
?>
</tbody></table>
</section>
Hello friends,
My system has: video, photo, "breaking news"
This is how my system should work:
If news has video it should have video Icon.
If news has photo gallery it should have photo icon.
Can someone help me with this?
Thanks in advance.
#ReshoMarcos that screenshot helped alot. But still i dont know about
your data structure and other sutff, so i cant help you finding the
flag. You may even need to change your database to be able to have
that flag. But after you had flag you can use the answer i gave you
OK with that screen shot you sent its more clear but still i dont know where you store the flag (the data you are gonna decide if the news has video or if it has image)
So as far as i see here is where you want to show the icons
<td class="title"><b>
<?=$baslik?><span class="title-icons">^^^^^^^here^^^^^</span>
</b></td>
So based on your flag. (the variable that holds data that can help you realize if new has image or video). So you may have the flag already stored in your database (like a filed in a table) or you may have to create the flag base on different conditions and checking the news' type or if video src filed in data base is empty or such things. So lets say you have your flag and it is name $newType or $newsHasVideo. So this is how your code should look like.
inside while loop after you set the variables:
<?php
$newsHasVideo= true; // or false i told you about the flag
if($newsHasVideo){
$icon = '<span class="icon vid-icon"></span>';
//$icon should be filled with real icon data based on your
// needs like glyph-icons or font-awesome
}else{
$icon = '<span class="icon img-icon"></span>';
}
?>
<tr class="item">
<?php if($sistem['iceriktarih']): ?>
<td class="time"><?=$news->saat($time)?></td>
<?php endif; ?>
<td class="category"><?=$kategori?> </td>
<td class="title"><b><?=$baslik?><span class="title-icons"><?php echo $icon; ?></span></b></td>
</tr>
Related
I am building a website which will be used for posting tables in each post. For this purpose I have written a custom post code which enables the user to create tables simply by using ACF and data from database.
The thing is I would like to show the table also in the excerpt of the each post but I only get the post text written in the WP Post, written by the end user.
For now i have set it this way:
<!-- Blog Content -->
<?php echo $current_post['content'];
//Start my custom table code (HTML + PHP)?>
<table style="undefined;table-layout: fixed; width: 100%">
.
.
.
.
.
.
</table>
<?php
//End my custom table code
?>
Right now, only the content which is written by the end user ($current_post['content']) is showing in the excerpt, while in full post preview my custom table is showed normally.
What is the best way to solve this?
Thanks in advance!
$head1Title = $_POST['postTitle'];
$text = $_POST['postText'];
<table>
<tr> <th><?php echo $head1Title; ?> </th> </tr>
<tr> <td> <?php echo $text; ?></td></tr>
</table>
maybe try this one example?
I have a problem with $_GET method. I have retrieved some data about admins of a webpage from database & I added a hyperlink for users to get the information about that them.
Here's the code in my 1st page:
<?php if(($adminlevel)==1){
echo '
<h4 class="widgettitle">List of admins</h4>
<table class="table responsive">
<thead>
<tr>
<th>Admin Level</th>
</tr>
</thead>
'; getAdmins(); echo '
</table>
';
}else{
echo '<h4 class="widgettitle">You dont have permission to see this table</h4>';
}
?>
<div class="divider15"></div>
The function getAdmins() goes like this:
<?php
function getAdmins(){
global $con;
$get_admin = "select * from admins order by id";
$run_admin = mysqli_query($con,$get_admin);
while($row_admin = mysqli_fetch_array($run_admin)){
$id_admin = $row_admin['id'];
echo "
<tbody>
<tr>
<td>Trident</td>
<td class='center'><a href='editlevel.php?id=$id_admin' title='Clik to change admin level' target='_blank'>$adminlevel_admin</a></td>
</tr>
</tbody>
";
}
}
?>
As you see I link the users from my first page to another page which is called editlevel.php by the function getAdmins().
Therefore I made my hyperlink like this:
<a href='editlevel.php?id=$id_admin'>$adminlevel_admin</a>
And Here's the editlevel.php page:
<body>
<?php
if (isset($_GET['id_admin'])){
$result_id = $_GET['id_admin'];
$get_result = "select * from admins where id='$result_id'";
$run_result = mysqli_query($con,$get_result);
while($row_result= mysqli_fetch_array($run_result)){
$id_target = $row_result['id'];
$username_target = $row_result['username'];
$adminlevel_target = $row_result['adminlevel'];
$email_target = $row_result['email'];
echo '
<div class="mainwrapper">
<div class="header">
'; include "php/php_includes/overall/header.inc.php"; echo'
</div>
<div class="leftpanel">
';include "php/php_includes/overall/leftpanel.inc.php"; echo '
</div><!-- leftpanel -->
<div class="rightpanel">
'; include "php/php_includes/gadgets/rightpanel.editlevel.php"; echo '
</div><!--rightpanel-->
</div><!--mainwrapper-->
';
}
}
?>
</body>
So basically I used if (isset($_GET['id_admin'])){ to get the results of the item which user clicked & try to retrieve the data of that item from database via that.. But the problem is nothing appears at my screen. No error message & no result. Please if you know how can I solve it please let me know!
It appears that your link is:
<a href='editlevel.php?id=$id_admin'>$adminlevel_admin</a>
When it should be:
<a href='editlevel.php?id_admin=$id_admin'>$adminlevel_admin</a>
In order for it to work with:
if (isset($_GET['id_admin'])){
$result_id = $_GET['id_admin'];
Edit: It goes without saying, you should never trust user input (such as $_GET). These values should be validated and sanitised before being used in SQL queries.
I have here my index.php. It already contains the layout and the php code inside it. I just want to know if there is a new record on the database. From my research it needs to be refreshed. I tried the javascript auto refresh and the whole page now refreshes so if there will be new records the table will automatically show the new record. But now my problem is how to know if there are changes. I am able to show if there is an update on the database through refresh but I am not able to notify if there are changes. I just want to put notification if there are new records. So for now I want to know how to check if there are new records on the database. Here are my code.
<div class="panel panel-default">
<div class ="panel-body">
<!-- TABLE OF REPORTS -->
<div align = "center" style = " font-size: 9000px">
<table class="table table-striped" name = "report">
<thead>
<tr align = "center"class = "active" >
<td class = "theads" >Id</td>
<td class = "theads" >Message</td>
</tr>
</thead>
<!--Start of php code -->
<?php
$page=1;//Default page
$limit=10;//Records per page
$start=0;//starts displaying records from 0
if(isset($_GET['page']) && $_GET['page']!='')
{
$page=$_GET['page'];
}
$start=($page-1)*$limit;
//Get total records (you can also use MySQL COUNT function to count records)
$query=mysql_query("select report_id from reports");
$rows=mysql_num_rows($query);
$query=mysql_query("select * from reports order by datetime DESC LIMIT $start, $limit");
if(mysql_num_rows($query)>0)
{
while($row=mysql_fetch_array($query,1))
{
?>
<tbody>
<tr class = 'active'>
<td align = 'center'><?php echo $row['report_id'] . "<br>";?></td>
<td align = 'center'><?php echo $row['message'] . "<br>";?></td>
</tr>
</tbody>
<?php
}
}
?>
</table>
</div>
</div>
</div>
If you want to do this notification system on client side then you can create a cookie with the latest created date and check if any created date is greater then date of cookie then count the rows which having greater date then cookie's value.
If you want to do it on Server side then you have to save last seen created date some where in database table and do above process.
$query=mysql_query("select * from reports order by datetime DESC LIMIT $start, $limit");
if(isset($_SESSION['chk']))
{
$sql=mysql_query("select count(*) as new_record from reports where datetime>$_SESSION['chk']");
$count=mysql_fetch_array($sql);
$new_record=$count['new_record']; // new records
}
if(mysql_num_rows($query)>0){$i=0;
while($row=mysql_fetch_array($query,1)){if($i==0){$_SESSION['chk']=$row['datetime'];$i++;}
?>
Okay so my code below echoes out two URLs from the database but I want to have the ability to separate the two and update the row where the image is clicked. Example: Two images are output, users clicks image on the left, MySQL knows which row to update depending on which image they clicked. Depending on the image they click it will update the image's votes in MySQL. Ideally I want the "vote-ups" to show in place of the 112 and 156 accordingly from the database.
Let me rephrase to clarify: my code echoes out two images selected from the database. The code should tell you that if you read it. From there, I want to be able to separate the two images so I can do a query to update the specific row with that image and update the total votes that image has from votes to votes+1. I tried doing this but it would update both row's votes by 1.
How can I do this?
<?php
include_once('db.php');
$selectURLSQL = "SELECT * FROM `urls` ORDER BY RAND() LIMIT 3";
$selectURLQuery = mysql_query($selectURLSQL);
$URL_Row = mysql_fetch_array($selectURLQuery);
?>
<?php
while($URL_Row = mysql_fetch_array($selectURLQuery)) {
?>
<img class="img" name="img" src="<?php echo $URL_Row['url']; ?>" style="height:400px;width: 260px;">
<?php
}
?>
<br /><br />
<span style="font-size:18px;font-family:trebuchet ms;">156 Vote-Ups</span>
<small>Vs.</small>
<span style="font-size: 18px; font-family: trebuchet ms;">112 Vote-Ups</span><br /><br />
Say your table urls is structured like this:
id | url | rank
you have to increment the rank column for each click on the image corresponding to the url.
my idea is to create a link around the image, and this link will contain the id of the image so it can be passed in the URL like this ?id=xxx
if you want to show the votes outside the loop, you can save them temporarily in an array
Your Code:
<?php
include_once('db.php');
$selectURLSQL = "select * from urls ORDER BY RAND() LIMIT 2";
$selectURLQuery = mysql_query($selectURLSQL);
if (isset($_GET['id'])){
$id = $_GET['id'];
$sql = "UPDATE urls set rank = rank+1 WHERE id = $id";
mysql_query($sql);
}
$i = 0;
$votes = array();
while ($URL_Row = mysql_fetch_array($selectURLQuery)):
$votes[$i++] = $URL_Row['rank'];
?>
<a href="?id=<?php echo $URL_Row['id']; ?>">
<img class="img" name="img" src="<?php echo $URL_Row['url']; ?>" style="height:400px;width: 260px;">
</a>
<?php endwhile; ?>
<br /><br />
<span style="font-size:18px;font-family:trebuchet ms;"><?php echo $votes[0]; ?> Vote-Ups</span>
<small>Vs.</small>
<span style="font-size: 18px; font-family: trebuchet ms;"><?php echo $votes[1]; ?> Vote-Ups</span><br /><br />
I have a database containing movies Name, their description and their cover picture. The cover picture field type is as blob and the problem is that I can't retrieve it from the database. I want to display the movie name along their cover picture beside them... How to do it.. Here is my code..
<?php
include ("php/connection.php");
$ID = $_GET['id'];
$listmovies = "SELECT * FROM movies where Genres LIKE '%$ID%'";
$result = mysql_query($listmovies);
while ( $row = mysql_fetch_assoc($result) ) {
?>
<table border="1" width="100%">
<tr>
<td rowspan="2" width="90" height="120">
<?php
// set the header for the image
header("Content-type: image/jpeg");
echo $row['Image'];
?> </td>
<td width="200" height="10">
<?php
echo $row['Title'];
?></td>
</tr>
<tr>
<td width="200" height="110">More Detail</td>
</tr>
<?php } ?> </table>
I just want to display The Imgaes beside the title of the movie?
Yes it won't display because any output above header would always generate error ... you need to have a different page to output your image or include it has base64 image
Remove
header("Content-type: image/jpeg");
echo $row['Image'];
And add this :
printf("<img src=\"data:image/jpeg;base64,%s\" />",base64_encode($row['Image']));
^--- Note this is only for jpeg images
I suggest something like that:
Make a new php file called for example image.php; That file will replace physical image file.
In that file you put the code from your post plus some logic to get image data from database;
In parent template(php file maybe) you put code for image:
<img src="image.php?id_movie=<?php echo $id_movie; ?>" width ="200" height="200" /> More Detail
In image.php i suggest to be careful at spaces outside php tags (at the beniging and at the end).
Also to image.php you need to give id of the movie to know what image to load from database.