overflow isnt working when loading data into div from another page - php

hey guys after working on the script, im facing a problem where im fetching the data from another php page through ajax.
here is my div where the data is to be shown..
<div id="show_msg">
</div>
Here is my css :
#show_msg {
width: 100%;
border: 1px solid #D8D4D4;
border-right: none;
border-left: none;
min-height: calc(96% - 4%);
height: calc(96% - 4%);
max-height: calc(96% - 4%);
}
Here is my JS :
$('#send_btn').click(function(){
var msgContent = $('#message_input').val();
if(msgContent == '')
{
alert('message to likh bhai');
}
else
{
$.ajax({
url: 'lib/function.php',
method: 'POST',
data:{func: 'send_msg', msgContent:msgContent},
success: function(data)
{
if(data == 'sent')
{
$('#message_input').val('');
}
}
})
}
});
Here is my php page from where data is getting fetched :
<?php
include 'connect.php';
global $con;
$get_data = mysqli_query($con, "SELECT * FROM messages");
while($row = mysqli_fetch_array($get_data))
{
?>
<div id="chat_box">
<img src="images/user.jpg" id="onio_user_2" style="border: 2px solid lightblue">
<div class="content-2">
<p style="font-weight: bold;font-size:13px;">BaTuTa</p>
<p class="comment"><span><?php echo $row['message_body'] ?> </span></p>
</div>
</div>
<?php
}
?>

Try to add the following line to your #show_msg style :
overflow:both;
So your final style looks like:
#show_msg {
width: 100%;
border: 1px solid #D8D4D4;
border-right: none;
border-left: none;
min-height: calc(96% - 4%);
height: calc(96% - 4%);
max-height: calc(96% - 4%);
overflow:both;
}

Related

while setting cookies getting error of undefined index

<script>
$(document).ready(function(){
setTimeout(function(){
if(!mag_cookie_val)
$("#myNav").show();
}, 12000);
$("#close_magnet").click(function(){
$("#myNav").hide();
});
$("#magnet_email").keyup(function(){
$("#magnet_email").css("border-color","#67AEE9");
});
$("#magnet_continue").click(function(){
var MagEmail = $("#magnet_email").val();
atpos = MagEmail.indexOf("#");
dotpos = MagEmail.lastIndexOf(".");
if(atpos < 1 || ( dotpos - atpos < 2 ))
{
$("#magnet_email").css("border-color","red");
}else{
/*
$.ajax({
url: "leadmagnet_res.php",
method: 'POST',
data:{magemail:MagEmail}
}).done(function(data) {
//alert(data)
if(data !=0){
$("#myNav").css("height","0%");
}
});
*/
$.ajax({
url: 'leadmagnet_res.php',
type: 'post',
data: {magemail:MagEmail},
//processData: false,
success: function( res ){
//alert(res);
},
error: function(){
alert( "error occured" );
},
complete: function(){
$("#myNav").hide();
}
});
}
});
//Lead magnet close code End
$(document).ready(function() {
//setTimeout(function(){ $("#myNav").show(); }, 12000);
$("#magnet_email").css("border-color","#67AEE9");
//Lead magnet close code start
$("#close_magnet").click(function(){
$("#myNav").css("height","0%");
});
$("#magnet_email").keyup(function(){
$("#magnet_email").css("border-color","#67AEE9");
});
$("#magnet_continue").click(function(){
var MagEmail = $("#magnet_email").val();
atpos = MagEmail.indexOf("#");
dotpos = MagEmail.lastIndexOf(".");
if(atpos < 1 || ( dotpos - atpos < 2 ))
{
//alert(1);
$("#magnet_email").css("border-color","red");
}else
{
//alert(2);
$.ajax({
url: siturl_mag+"leadmagnet_res.php",
method: 'POST',
data:{magemail:MagEmail}
}).done(function(data) {
//alert(data)
if(data !=0){
$("#myNav").css("height","0%");
}
});
}
});
//Lead magnet close code End
</script>
<style>
.overlay_magnet {
height: 0% !important;
width: 100% !important;
position: fixed !important;
z-index: 94 !important;
top: 0;
left: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.3);
transition: 0.5s;
}
.overlay_magnet-content {
margin-left: 27%;
margin-top: 30px;
position: relative;
text-align: center;
top: 0;
width: 45%;
}
.overlay_magnet a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.overlay_magnet a:hover, .overlay a:focus {
color: #f1f1f1;
}
.overlay_magnet .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
}
#media screen and (max-height: 450px) {
.overlay_magnet {}
.overlay_magnet a {font-size: 20px}
.overlay_magnet .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
.circle_magnet {
width: 100%;
padding: 10%;
background: white;
border-radius: 50px;
border-style: solid;
border-color: #FE0000;
border-width:4px;
}
.circle_magnet-wrapper {
margin: 0 5%;
position: relative;
}
.circle_magnet .list-inline {
font-size: 0px;
margin: 0;
}
.circle_magnet .list-inline li {
font-size: 20px;
display: block;
}
.circle_magnet p {
padding-top: 10%;
margin: 0;
}
#media (min-width:460px) {
.circle_magnet .list-inline li {
font-size: 50px;
display: inline-block;
}
.circle_magnet-wrapper {
width: 100%;
position: relative;
margin:0 auto;
}
.circle_magnet {
height: 0px;
padding: 50%;
border-radius: 50%;
}
.circle_magnet > div {
position: absolute;
text-align: center;
left: 10%;
right: 10%;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
top:20%\9; /* ie8 hack test this out it's a guess */
}
}
.circle_text_magnet{
cursor:pointer;
}
.circle_text_magnet:hover {
text-decoration: underline;
}
.arrow{
height:25px;
width:25px;
}
</style>
<div id="myNav" class="overlay_magnet hidden-xs hidden-sm" <?php if ($magstatus !=0){?>style="height:0% !important;display:none;" <?php }else{ ?>style="height:100% !important;display:none;" <?php } ?> >
<div class="overlay_magnet-content" >
<div class="circle_magnet-wrapper">
<div class="circle_magnet text-center">
<div class="row" style="margin-top:-40%;">
<div class="col-md-12">
<center>
<label style="font-family: Roboto;color: green;text-shadow: rgb(46, 46, 46) 0px 4px 5px;font-size: 42px;font-weight: bold !important;margin: 0 !important;">Sign Up!</label>
</center>
</div>
</div>
<div class="row" style="margin-top:-24%;">
<div class="col-md-12">
<center>
<label style="font-family: Roboto;color: #00006A;font-size: 20px;font-weight: normal !important;margin: 0 !important;">Join our Travel Community.</label>
<label style="font-family: Roboto;color: #00006A;font-size: 20px;font-weight: normal !important;margin: 0 !important;">Get Free Exclusive Travel Tips and<br> Links to our New Travel Videos.</label>
</center>
</div>
</div>
<div class="row" style="margin-top:-12%;">
<div class="col-md-12">
<center>
<label style="font-family: Roboto;color: #fe0000;font-size: 20px;font-weight: normal !important;margin: 0 !important;">Enter your email below</label>
</center>
</div>
</div>
<div class="row" >
<div class="col-md-12" style="border: 1px solid #00006A;border-radius: 7px;padding: 18px;box-shadow: inset 0px 0px 50px 0px #ABABAB, 0px 2px 9px 1px #242424;">
<div class="col-md-9">
<input id="magnet_email" class="form-control" placeholder="Enter your email address " type="text" >
</div>
<div class="col-md-3" >
<button class="btn btn-primary pull-left " id="magnet_continue">Continue</button>
</div>
</div>
</div>
<div class="row" style="margin-top:20%;">
<div class="col-md-12">
<span style="font-family: Roboto;color: #00006A;font-size: 12px;font-weight: normal !important; ">By clicking Continue, I agree to the </span>
<span> Terms of Service</span>
</div>
</div>
<div class="row" style="margin-top:35%;">
<div class="col-md-12">
<center><h2 id="close_magnet" class="circle_text_magnet" style="font-family: Roboto;color: #00006A;font-weight: normal !important; margin-left:10px; ">No Thanks</h2></center>
</div>
</div>
</div>
</div>
</div>
this is a code of cookies which i m setting for a form to be displayed
but always getting a error of Undefined
index: MagnetStatus in line 3
which is
$magstatus = $_COOKIE[$cookie_name];
code:
$magstatus = $_COOKIE[$cookie_name];
if(!$magstatus) {
$cookie_value = 0;
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
}
?>
so can u help me out or any idea regarding this
you can either use isset() or empty() to prevent such warnings if the cookie with the specified name doesnt exist
$magstatus = (isset($_COOKIE[$cookie_name])) ? $_COOKIE[$cookie_name] : 'default_value_here';
You have to use following code to check whether cookie is set or not:
if(!isset($_COOKIE[$cookie_name])) {
$cookie_value = 0;
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
}
Remove $magstatus = $_COOKIE[$cookie_name]; line only check cookie with isset method

how to open multiple modal click on id?

code:
<style>
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
<script>
var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
<?php
$sql = "select * from enquires2";
$result = mysqli_query($link,$sql);
while ($row = mysqli_fetch_array($result))
{
?>
<tr>
<td>
<span><img src='gridview/view.png' alt='View' id='myBtn<?php echo $row['id']; ?>'></span>
</td>
</tr>
<div id='myModal' class='modal'>
<div class='modal-content'>
<span class='close'>×</span>
<p>Some text in the Modal..</p>
</div>
</div>
<?php
}
?>
In this code when I click on id i.e.
id='myBtn<?php echo $row['id']; ?>'
it display only one modal but when I click on new row id it show nothing. so, I want to open multiple modal with different row id. How can I fix this issue ? please help.
Thank You

Displaying MySQL data with PHP & jQuery

With help from some of you guys, I managed to partially get the functionality I wanted. Now I'm stuck again, and I'd need some more help.
Check the live version here, the code is below. What I need is:
-
Figure out how to switch to the next/previous product on both sides of the screen with a single click of the arrows. The left side works as expected, the right one doesn't switch in any case.
-
Make the results of slika1, slika2 and slika3 (they contain the filenames of three separate images) on the right side display as links that will switch the image on the left side.
-
Modify the code to prevent SQL injection attacks (optional at the moment, but it would be welcome)
I'm pretty sure the whole functionality could be contained in a single file to be called with POST, but I'm really not sure how to do it properly. That would be a bonus too!
Here's my code:
HTML (index.php):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="layout.css">
<link href='https://fonts.googleapis.com/css?family=Syncopate' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.post( "art.php", { pic: "1"}, function( data ) {
$("#picture").html( data );
});
$.post( "info.php", { id: "1"}, function( data ) {
$("#info").html( data );
});
$("#picture").on("click",".get_pic", function(e){
var picture_id = $(this).attr('data-id');
$("#picture").html("<div style=\"margin:50px auto;width:50px;\"><img src=\"loader.gif\" /></div>");
$.post( "art.php", { pic: picture_id}, function( data ) {
$("#picture").html( data );
});
return false;
});
$("#info").on("click",".get_info", function(e){
var info_id = $(this).attr('data-id');
$("#info").html("<div style=\"margin:50px auto;width:50px;\"><img src=\"loader.gif\" /></div>");
$.post( "info.php", { pic: info_id}, function( data ) {
$("#info").html( data );
});
return false;
});
});
</script>
<title>2199</title>
</head>
<body>
<div class="navbar-wrapper">
<div class="container"> <img src="logo.png" class="boxy"> </div>
</div>
<div class="jumbotron special">
<div id="picture" align="center"> </div>
</div>
<div class="jumbotron special2">
<div id="info" align="center"> </div>
</div>
</body>
</html>
HTML (art.php):
$username = "root"; //mysql username
$password = ""; //mysql password
$hostname = "localhost"; //hostname
$databasename = '2199'; //databasename
//get pic id from ajax request
if(isset($_POST["pic"]) && is_numeric($_POST["pic"]))
{
$current_picture = filter_var($_POST["pic"], FILTER_SANITIZE_NUMBER_INT);
}else{
$current_picture=1;
}
//Connect to Database
$mysqli = new mysqli($hostname, $username, $password, $databasename);
if ($mysqli->connect_error){
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
//get next picture id
$result = $mysqli->query("SELECT id FROM gola WHERE id > $current_picture ORDER BY id ASC LIMIT 1")->fetch_object();
if($result){
$next_id = $result->id;
}
//get previous picture id
$result = $mysqli->query("SELECT id FROM gola WHERE id < $current_picture ORDER BY id DESC LIMIT 1")->fetch_object();
if($result){
$prev_id = $result->id;
}
//get details of current from database
$result = $mysqli->query("SELECT artikel, slika1 FROM gola WHERE id = $current_picture LIMIT 1")->fetch_object();
if($result){
//construct next/previous button
$prev_button = (isset($prev_id) && $prev_id>0)?'<span class="glyphicon glyphicon-circle-arrow-left rujz"></span>':'';
$next_button = (isset($next_id) && $next_id>0)?'<span class="glyphicon glyphicon-circle-arrow-right rujz"></span>':'';
//output html
echo '<div class="prod_img" style="background-image: url(pictures/';
echo $result->slika1;
echo '); background-size: contain; background-repeat: no-repeat; background-position: center center;">';
echo '<h3>';
echo $prev_button;
echo $result->artikel;
echo $next_button;
echo '</h3>';
echo '</div>';
}
HTML (info.php):
<?php
$username = "root"; //mysql username
$password = ""; //mysql password
$hostname = "localhost"; //hostname
$databasename = '2199'; //databasename
//get pic id from ajax request
if(isset($_POST["info"]) && is_numeric($_POST["info"]))
{
$current_info = filter_var($_POST["info"], FILTER_SANITIZE_NUMBER_INT);
}else{
$current_info=1;
}
//Connect to Database
$mysqli = new mysqli($hostname, $username, $password, $databasename);
if ($mysqli->connect_error){
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
//get next picture id
$result2 = $mysqli->query("SELECT id FROM gola WHERE id > $current_info ORDER BY id ASC LIMIT 1")->fetch_object();
if($result2){
$next_id = $result2->id;
}
//get previous picture id
$result2 = $mysqli->query("SELECT id FROM gola WHERE id < $current_info ORDER BY id DESC LIMIT 1")->fetch_object();
if($result2){
$prev_id = $result2->id;
}
//get details of current from database
$result2 = $mysqli->query("SELECT artikel, slika1, slika2, slika3, dim1, dim2, dim3, obdelava, dodatno FROM gola WHERE id = $current_info LIMIT 1")->fetch_object();
if($result2){
//construct next/previous button
$prev_button = (isset($prev_id) && $prev_id>0)?'<span class="glyphicon glyphicon-circle-arrow-left rujz-wht"></span>':'';
$next_button = (isset($next_id) && $next_id>0)?'<span class="glyphicon glyphicon-circle-arrow-right rujz-wht"></span>':'';
//output html
echo '<div class="info">';
echo '<h3 style="color: #fff !important;">';
echo $prev_button;
echo $result2->artikel;
echo $next_button;
echo '</h3>';
echo '<br />';
echo '<p>';
echo $result2->slika1;
echo '<br />';
echo $result2->slika2;
echo '<br />';
echo $result2->slika3;
echo '<br />';
echo $result2->dim1;
echo '<br />';
echo $result2->dim2;
echo '<br />';
echo $result2->dim3;
echo '<br />';
echo $result2->obdelava;
echo '<br />';
echo $result2->dodatno;
echo '</p>';
echo '</div>';
}
CSS:
html, body {
height: 100%;
background-color: #fff;
font-size: 62.5%;
}
.special, .special .jumbotron {
height: 100%;
background-color: white;
border: 0px solid red;
margin-bottom: 0px !important;
}
.special2, .special2 .jumbotron {
height: 100%;
background-color: #62a70f;
border: 0.5rem solid #fff;
border-radius: 3rem;
margin-bottom: 0px !important;
padding: 1rem;
}
.logo {
border: 1px solid red;
width: 10%;
min-height: 100%;
position: relative;
height: 100%;
}
#picture {
border: 0px red solid;
height: 100%;
background: #fff;
}
.prod_img {
height: 100%;
}
h3 {
font-family: 'Syncopate', sans-serif;
font-size: 24px;
font-size: 2.4rem;
color: #62a70f;
}
.boxy {
border: 0.5rem solid white;
position: fixed;
bottom: 2.5%;
right: 5%;
width: 25%;
padding: 1rem;
/* height: 30rem;*/
background-color: rgba(64,64,64,1);
border-radius: 3rem;/* background-image: url(logo.png);
background-size: contain;
background-repeat: no-repeat;*/
}
#media (min-width:768px) {
.boxy {
border: 0.5rem solid white;
position: fixed;
bottom: 5%;
right: 45%;
width: 10%;
/* height: 30rem;*/
background-color: rgba(64,64,64,1);
border-radius: 3rem;/* background-image: url(logo.png);
background-size: contain;
background-repeat: no-repeat;*/
}
.navbar {
min-height: 10% !important;
max-height: 10% !important;
height: 10%;
background-image: url(logo.png);
background-size: contain;
background-repeat: no-repeat;
border: 0px solid green;
background-color: #0e0e0e;
animation-name: example;
animation-duration: 1s;
animation-timing-function: ease;
}
.navbar-header {
border: 0px solid green;
min-height: 100%;
}
.logo {
visibility: collapse;
}
.special, .special .jumbotron {
width: 50%;
float: left;
margin-bottom: 0px !important;
}
.special2, .special2 .jumbotron {
width: 50%;
float: left;
margin-bottom: 0px !important;
}
h3 {
font-size: 48px;
font-size: 4.8rem;
}
.rujz {
font-size: 36px;
font-size: 3.6rem;
color: #62a70f;
margin: 0.5em;
}
.rujz-wht {
font-size: 36px;
font-size: 3.6rem;
color: #fff;
margin: 0.5em;
}
}
#keyframes example {
0% {
bottom:-10%;
}
100% {
bottom:0%;
}
}
As always, thanks in advance!
i suggest using the carousel in bootstrap, since it's much better than what you are trying to achieve using Javascript.
Also, your MySQL queries can be shortened and changed into a more efficient code, by using a whileloop to output in to different sections.
But to not complicate things,
I assume that you are trying to get 2 different sections, one with a image and another with infomation? If so, you would want to cycle between 2 same slideshow with the same function. To do this,
<div id="Section1">Description</div>
<div id="Section1">slika1</div>
<div id="Shift"> Next </div>
and having a seperate javascript to cycle through each section
$(document).ready(function () {
$("#Section1").cycle();
$("#shift").click(function () {
$("#Section1").cycle('next');
});
});
a live example could be viewed here : http://jquery.malsup.com/cycle/pager11.html
edit: i wrote this entire answer without understanding your code.. so.. further clarifications could help :)

Jquery flip script not showing unique content on flip back side

I am trying to implement Rotate3Di, found here: http://www.zachstronaut.com/projects/rotate3di/
I can get my images to flip, but the back side is only showing a mirror image of the front and not unique content that I am pulling from a database. Thanks for any help in advance.
<script type="text/javascript" language="javascript" charset="utf-8">
$(document).ready(function () {
$('#movienav li div.back').hide().css('left', 0);
function mySideChange(front) {
if (front) {
$(this).parent().find('div.front').show();
$(this).parent().find('div.back').hide();
} else {
$(this).parent().find('div.front').hide();
$(this).parent().find('div.back').show();
}
}
$('#movienav li').hover(
function () {
$(this).find('div').stop().rotate3Di('flip', 180, 1000, {direction: 'clockwise', sideChange: mySideChange});
},
function () {
$(this).find('div').stop().rotate3Di('unflip', 1000, {sideChange: mySideChange});
}
);
});
</script>
HTML
<div id="movienav">
<ul>
<li><div class="front"><img src="<?php echo $imglink; ?>" width="340" height="450" class="dvdcover" /></div>
<div class="back">
<?php echo $description; ?>
</div>
</li>
</ul>
</div>
CSS
#movienav {
height: 450px;
width:75%;
float:left;
margin-top:25px;
clear:left;
padding-bottom: 45px;
}
#movienav li {
width: 340px;
height: 450px;
float: left;
margin-right: 10px;
position: relative;
display:inline;
list-style:none;
}
#movienav li div {
width: 340px;
height: 450px;
overflow: hidden;
background: #161616;
position: absolute;
top: 0;
left: 0;
}
#movienav li div.back {
left: -999em;
padding-bottom: 15px;
background-color:#161616; /*max-height:450px; overflow:auto;*/
margin-top: 0;
}
SOLVED
Changed above lines to:
$('#movienav li').hover(
function () {
$(this).find('div').stop().rotate3Di('180', 400, {direction: 'clockwise', sideChange: mySideChange});
},
function () {
$(this).find('div').stop().rotate3Di('unflip', 400, {sideChange: mySideChange});
}
);
http://davidwalsh.name/css-flip
I think you want backface-visibility: hidden;
I'll be honest I've only done this via CSS and not with javascript, but I had the same issue at first until I set the backface-visibility. Doing everything via javascript might require some extra magic.

jcarousel is not scrolling through images

i have a jcarousel gallery of images
but the jcarousel is not working at all it's not scrolling through images at all
this is my code :
<ul id="mycarousel" class="jcarousel-skin-tango">
<?php foreach ($images as $image_item) : ?>
<li><img src="<?php echo $image_item['Path']; ?>"/></li>
<?php endforeach; ?>
</ul>
and this is my css :
.jcarousel-skin-tango .jcarousel-container {
width:500px;
height:250px;
background: none;
border: none;
}
.jcarousel-skin-tango .jcarousel-container-horizontal {
height:250px;
padding: 20px 40px;
}
.jcarousel-skin-tango .jcarousel-clip-horizontal {
width: 500px;
height: 250px;
}
.jcarousel-skin-tango .jcarousel-item {
width: 500px;
height: 250px;
}
.jcarousel-skin-tango .jcarousel-item-horizontal {
margin-left: 0;
margin-right: 10px;
}
and there is my js :
$(document).ready(function(){
$('#mycarousel').jcarousel({wrap:'circular'});
});
Your code is almost correct — you just need to add "auto: 1" (or some other non-zero number of seconds) and it'll start auto-scrolling. If you don't want auto-scroll, you need to specify the "buttonNextHTML" and "buttonPrevHTML" parameters to get buttons.

Categories