Hosting company updated servers or added new patchs can't get a straight answer.
I updated code looked online and stuck. Tried to have hosting check with server and company keeps coming back and saying its the code.
Don't know what else to do and help would be appreciated.
<?
include_once("mysql_nitrousgarage.inc");
$clean_url = substr($PHP_SELF,1);
$clean_url = substr($clean_url,0,-5);
$q = "SELECT * from NG_product where active='Y' and
clean_url='$clean_url'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$product_id = $row["product_id"];
$product_name = $row["product_name"];
$sku = $row["sku"];
$description = $row["description"];
$meta_title = $row["meta_title"];
$meta_description = $row["meta_description"];
$magiczoomplus = "Y";
include_once("topnav.inc")
?>
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<meta name="viewport" content="width=400, user-scalable=no">
<script type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-
52f96c9761c7b0cb" async="async"></script>
<div class="box-border">
Home ›
<?
if ($saved_category_id || !$saved_brand_id)
{
if ($saved_category_id)
$q = "SELECT * from NG_category where
category_id='$saved_category_id'";
else
$q = "SELECT * from NG_product_category as pc, NG_category
as c where pc.product_id='$product_id' and
pc.category_id=c.category_id order by c.order_placement limit 1";
$results = mysql_nitrousgarage.inc($q);
$row = mysql_fetch_array($results);
$category_id = $row["category_id"];
$category = $row["category"];
$category_clean_url = $row["clean_url"];
echo "<a href='$category_clean_url'>$category Wheels</a>";
}
else
{
$q = "SELECT * from NG_brand where brand_id='$saved_brand_id'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$brand_id = $row["brand_id"];
$brand = $row["brand"];
$brand_clean_url = $row["clean_url"];
echo "<a href='$brand_clean_url'>$brand Wheels</a>";
}
?>
› <?echo $product_name?>
<div class="page-numbers">
<a href="<?echo $category_clean_url?>">‹ Back to <?echo
$category?> Wheels</a>
</div>
</div>
<div class="space20"></div>
<?
$image_id_arr = array();
$q1 = "SELECT * from NG_finish as f, NG_product_finish as pf, NG_finish_image as fi where f.active='Y' and f.finish_id=pf.finish_id and pf.active='Y' and pf.product_id='$product_id' and pf.product_finish_id=fi.product_finish_id and fi.active='Y' order by f.order_placement,fi.order_placement";
$r1 = mysql_query($q1);
while ($row1 = mysql_fetch_array($r1))
{
$image_id = $row1["image_id"];
$product_finish_name = $row1["product_finish_name"];
if (!$main_image)
{
$main_image = "finish-$image_id.jpg";
$selected_finish = $product_finish_name;
}
$image_id_arr[] = $image_id;
$product_finish_name_arr[] = $product_finish_name;
}
?>
<div class="simpletable">
<div class="row">
<div class="simplecell details-cll1">
<div id="m-container">
<img class="maxwidth" id="m-img" src="productphotos/<?echo $main_image?>" width=488>
</div>
</div>
<div class="simplecell" style="width: 3%"></div>
<div class="simplecell details-cll2">
<!--<div class="details-share">
<img src="images/facebook.jpg">
<br class="nomobile">
<img src="images/twitter.jpg">
<br class="nomobile">
<img src="images/mail.jpg">
<br class="nomobile">
<img src="images/plus.jpg">
</div>-->
<span class="details-title"><?echo $product_name?></span>
<div class="style-number">Style: <?echo $sku?></div>
<div class="selected-finish">Selected Finish: <span id=finish_layer>
<?echo $selected_finish?></span>
</div>
<div class="space30"></div>
<br>
<div class="simpleinline">
<div class="like-wheel">Like this Wheel?</div>
<div class="more-info-via">GET MORE INFO VIA</div>
</div>
<div class="simpleinline">
<a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=C">CALL/TEXT</a> <a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=E">EMAIL</a>
</div>
<div class="space50 nomobile"></div>
<div class="space30"></div>
<?
while(list($k,$v) = each($image_id_arr))
{
$product_finish_name = $product_finish_name_arr[$k];
echo "<img class='maxwidth' src='productphotos/finish-$v.jpg' width=145>";
}
?>
</div>
</div>
</div>
<div class="space20"></div>
<div class="box-border">
<div class="simpletable">
<div class="row">
<div class="simplecell product-desc">
<?echo $description?>
</div>
<!--<div class="simplecell price-notshow">
<b>Why are prices not shown?</b>
<br><br>
Many of our customers frequently ask us why are the prices not show.
</div>-->
</div>
</div>
</div>
<div class="space20"></div>
<?
$q = "SELECT * FROM NG_gallery WHERE active='y' and product_id='$product_id' ORDER BY featured desc, orderplacement limit 3";
$results = mysql_query($q);
if (mysql_num_rows($results) > 0) { ?>
<b><?echo $product_name?></b> Vehicle Gallery
<div class="page-numbers">
CLICK IMAGE TO <b>ENLARGE | VIEW MORE</b>
</div>
<?
while ($row = mysql_fetch_array($results))
{
$gallery_id = $row["gallery_id"];
$gallery_title = $row["gallery_title"];
$gallery_pics .= "<a href='productphotos/gallery_$gallery_id-l.jpg' class='MagicZoomPlus' id='Zoomer$gallery_id' rel='zoom-position: inner; zoom-width:400px;zoom-height:500px;' title='$gallery_title'><img class='maxwidth' src='productphotos/gallery_$gallery_id-l.jpg' width=380 border=0></a>";
}
?>
<div class="details-img-container">
<nobr>
<?echo $gallery_pics?>
</nobr>
</div>
<div class="details-img-container2">
<?echo $gallery_pics?>
</div>
<?}?>
<? include_once("footer.inc") ?>
Before updates of server page was working fine.
Related
Like written in the title my code works okay except for the quantity for the first product when there are multiple products, where you can remove by clicking update but cant change the quantity.
<?php
include("functions/functions.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.12/css/all.css" integrity="sha384-G0fIWCsCzJIMAVNQPfjH08cyYaUtMwjJwqiRKxxE/rx96Uroj1BtIQ6MLJuheaO9" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="styles/style.css" />
<title>Prodavnica+</title>
</head>
<body>
<div id="header" class="cf">
<img src="images/logo.png" />
<div id="navbar">
<ul>
<li>
Home
</li>
<li>
Products
</li>
<li>
My Account
</li>
<li>
Sign Up
</li>
<li>
Shopping Card
</li>
<li>
Contact Us
</li>
</ul>
</div> <!-- END navbar -->
<div id="search">
<form method="get" action="results.php" enctype="multipart/form-data">
<input type="text" name="search_query" placeholder="Search Product" />
<input type="submit" name="search_button" value="Search" />
</form>
</div>
</div> <!-- END header -->
<?php cart(); ?>
<div id="shop-bar">
<p>
Total items: <?php totalItems() ?>
</p>
<p>
Total price: <?php totalPrice()?>
</p>
<i class="fas fa-shopping-cart"> | </i>
<span> Welcome Guest! </span>
</div> <!-- END shop-bar -->
<div id="container">
<div id="main">
<div id="product-box-cart">
<form action="" method="post" enctype="multipart/form-data">
<table>
<thead>
<th>Product</th>
<th>Quantity</th>
<th>Remove</th>
<th>Price</th>
</thead>
<tbody>
<?php
$total = 0;
global $con;
$ip = getIp();
$run_price = mysqli_query($con,"SELECT * FROM cart WHERE ip_add = '$ip'");
while($row_pro_price = mysqli_fetch_array($run_price)) {
$pro_id = $row_pro_price['p_id'];
$pro_qty = $row_pro_price['qty'];
$run_pro_price2 = mysqli_query($con,"SELECT * FROM products WHERE product_id = '$pro_id'") or die(mysqli_error($con));
while($row_pro_price2 = mysqli_fetch_array($run_pro_price2)) {
$pro_price = array($row_pro_price2['product_price']);
$pro_title = $row_pro_price2['product_title'];
$product_image = $row_pro_price2['product_image'];
$single_price = $row_pro_price2['product_price'];
$pro_price_values = array_sum($pro_price);
$total += $pro_price_values;
?>
<tr>
<td>
<h2><?php echo $pro_title ?></h2>
<img src="admin/product_images/<?php echo $product_image;?>">
</td>
<td>
<input type="text" name="qty[]" value = "<?php echo $pro_qty;?>">
</td>
<td>
<input type="checkbox" name="remove[]" value="<?php echo $pro_id ?>" />
</td>
<td>
<?php echo "$" . $single_price; ?>
</td>
</tr>
</tbody>
<?php }} ?>
</table>
<p>
<b> Total Value: </b> <?php echo "$" . $total;?>
</p>
<div id="check-buttons">
<input type="submit" name="update_cart" value="Update Cart" />
<input type="submit" name="continue" value="Continue Shopping" />
<input type="button" value="Checkout" />
</div>
</form>
<?php
//pressing update cart ->
if(isset($_POST['update_cart'])) {
//removing the products
if(isset($_POST['remove'])) {
foreach($_POST['remove'] as $remove_id) {
$delete_product = "DELETE FROM cart WHERE p_id = '$remove_id' AND ip_add = '$ip'";
$run_delete = mysqli_query($con,$delete_product);
if($run_delete) {
echo "<script>window.open('cart.php','_self')</script>";
}
}
}
//quantity of product
if(isset($_POST['qty'])) {
foreach($_POST['qty'] as $qty_id) {
$update_qty = "UPDATE cart SET qty = '$qty_id' WHERE p_id = '$pro_id' AND ip_add = '$ip'";
$run_qty = mysqli_query($con, $update_qty) or die(mysqli_error($con));
}
}
}
elseif(isset($_POST['continue'])) {
echo "<script>window.open('index.php','_self')</script>";
}
?>
</div> <!-- END product box -->
</div> <!-- END main -->
<div id="side">
<div id="side-category">
<h2>Categories</h2>
<hr />
<table id="mw">
<tr>
<?php
getBrands();
?>
</tr>
</table>
<ul>
<?php
getCats();
?>
</ul>
</div><!-- END side-category-->
</div> <!-- END side -->
</div> <!--END container -->
<div id="footer">
<p>© 2018 by </p>
</div> <!-- END footer -->
</body>
</html>
This is my cart.php page where the code executes. The $pro_id variable is from GET method for adding to cart. Therefore the $pro_id = $_GET[add_cart] which is in index.php. I will also include the index.php file bellow so if needed, one can take a look.
Quick answer would mean a lot. Thanks
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.12/css/all.css" integrity="sha384-G0fIWCsCzJIMAVNQPfjH08cyYaUtMwjJwqiRKxxE/rx96Uroj1BtIQ6MLJuheaO9" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="styles/style.css" />
<title>Prodavnica+</title>
</head>
<body>
<div id="header" class="cf">
<img src="images/logo.png" />
<div id="navbar">
<ul>
<li>
Home
</li>
<li>
Products
</li>
<li>
My Account
</li>
<li>
Sign Up
</li>
<li>
Shopping Card
</li>
<li>
Contact Us
</li>
</ul>
</div> <!-- END navbar -->
<div id="search">
<form method="get" action="results.php" enctype="multipart/form-data">
<input type="text" name="search_query" placeholder="Search Product" />
<input type="submit" name="search_button" value="Search" />
</form>
</div>
</div> <!-- END header -->
<?php cart(); ?>
<div id="shop-bar">
<p>
Total items: <?php totalItems() ?>
</p>
<p>
Total price: <?php totalPrice()?>
</p>
<i class="fas fa-shopping-cart"> | </i>
<span> Welcome Guest! </span>
</div> <!-- END shop-bar -->
<div id="container">
<div id="main">
<div id="product-box">
<?php
if(isset($_GET['cat'])) {
getCatPro();
}
elseif(isset($_GET['brand'])) {
getBrandPro();
}
else {
getPro();
}
?>
</div> <!-- END product box -->
</div> <!-- END main -->
<div id="side">
<div id="side-category">
<h2>Categories</h2>
<hr />
<table id="mw">
<tr>
<?php
getBrands();
?>
</tr>
</table>
<ul>
<?php
getCats();
?>
</ul>
</div><!-- END side-category-->
</div> <!-- END side -->
</div> <!--END container -->
<div id="footer">
<p>© 2018 by Djordje Stamenkovic</p>
</div> <!-- END footer -->
</body>
</html>
functions.php
<?php
//database connection
$con = mysqli_connect("localhost","root","","eprodavnica");
// function for getting ip address of the client
/*In this PHP function, first attempt is to get the direct IP address of client’s machine, if not available then try for forwarded for IP address using HTTP_X_FORWARDED_FOR. And if this is also not available, then finally get the IP address using REMOTE_ADDR.*/
function getIp()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
//adding a single product to cart
function cart() {
if(isset($_GET['add_cart'])) {
global $con;
$ip = getIp();
$pro_id = $_GET['add_cart'];
$run_check = mysqli_query($con,"SELECT * FROM cart WHERE ip_add = '$ip' AND p_id = '$pro_id'") or die(mysqli_error($con));
if(mysqli_num_rows($run_check)>0) {
echo "";
} else {
$run_pro = mysqli_query($con, "INSERT INTO cart (p_id, ip_add, qty) values ('$pro_id','$ip',1)") or die(mysqli_error($con));
echo "<script>window.open('index.php','_self')</script>";
}
}
}
//getting the total added items
function totalItems() {
if(isset($_GET['add_cart'])) {
global $con;
$ip = getIp();
$run_items = mysqli_query($con, "SELECT * FROM cart WHERE ip_add='$ip'");
$count_items = mysqli_num_rows($run_items);
} else {
global $con;
$ip = getIp();
$run_items = mysqli_query($con, "SELECT * FROM cart WHERE ip_add='$ip'") or die(mysqli_error($con));
$count_items = mysqli_num_rows($run_items);
}
echo $count_items;
}
//getting the total Price of items in the cart
function totalPrice() {
$total = 0;
global $con;
$ip = getIp();
$run_price = mysqli_query($con,"SELECT * FROM cart WHERE ip_add = '$ip'");
while($row_pro_price = mysqli_fetch_array($run_price)) {
$pro_id = $row_pro_price['p_id'];
$run_pro_price2 = mysqli_query($con,"SELECT * FROM products WHERE product_id = '$pro_id'");
while($row_pro_price2 = mysqli_fetch_array($run_pro_price2)) {
$pro_price = array($row_pro_price2['product_price']);
$pro_price_values = array_sum($pro_price);
$total += $pro_price_values;
}
}
echo "$" . $total;
}
//getting the categories
function getCats() {
global $con;
$run_cats = mysqli_query($con,"SELECT * FROM categories");
while($row_cats = mysqli_fetch_array($run_cats)) {
$cat_id = $row_cats['cat_id'];
$cat_title = $row_cats['cat_title'];
echo "<li>
<a href='index.php?cat=$cat_id'>$cat_title</a>
</li>";
}
}
//getting the brands
function getBrands() {
global $con;
$run_brands = mysqli_query($con,"SELECT * FROM brands");
while($row_brands = mysqli_fetch_array($run_brands)) {
$brand_id = $row_brands['brand_id'];
$brand_title = $row_brands['brand_title'];
echo "<td>
<a href='index.php?brand=$brand_id'>$brand_title</a>
</td>";
}
}
//getting products on main page
function getPro() {
if(!isset($_GET['cat'])){
if(!isset($_GET['brands'])) {
global $con;
$run_pro = mysqli_query($con,"SELECT * FROM products ORDER BY RAND() LIMIT 0,9");
while($row_pro = mysqli_fetch_array($run_pro)) {
$pro_id = $row_pro['product_id'];
$pro_cat = $row_pro['product_cat'];
$pro_brand = $row_pro['product_brand'];
$pro_title = $row_pro['product_title'];
$pro_price = $row_pro['product_price'];
$pro_image = $row_pro['product_image'];
echo "
<div class='single-product cf'>
<h4><a href='#'>$pro_title</a></h4>
<a href='details.php?pro_id=$pro_id'><img src='admin/product_images/$pro_image' /></a>
<p>
Price: $ $pro_price
</p>
<a href='index.php?add_cart=$pro_id'><button>Add To Cart</button></a>
</div>
";
}
}
}
}
//getting the category products
function getCatPro() {
if(isset($_GET['cat'])){
$cat_id = $_GET['cat'];
global $con;
$run_cat_pro = mysqli_query($con,"SELECT * FROM products WHERE product_cat = '$cat_id'");
$count_cats = mysqli_num_rows($run_cat_pro);
if($count_cats == 0) {
echo "<div class='no-cat'>
<h1> We're sorry! There are currently no products with that category. :(</h1>
</div>";
} else {
while($row_cat_pro = mysqli_fetch_array($run_cat_pro)) {
$pro_id = $row_cat_pro['product_id'];
$pro_cat = $row_cat_pro['product_cat'];
$pro_brand = $row_cat_pro['product_brand'];
$pro_title = $row_cat_pro['product_title'];
$pro_price = $row_cat_pro['product_price'];
$pro_image = $row_cat_pro['product_image'];
echo "
<div class='single-product cf'>
<h4><a href='#'>$pro_title</a></h4>
<a href='details.php?pro_id=$pro_id'><img src='admin/product_images/$pro_image' /></a>
<p>
Price: $ $pro_price
</p>
<a href='index.php?add_cart=$pro_id'><button>Add To Cart</button></a>
</div>
";
}
}
}
}
//getting the brand products (in this case sex)
function getBrandPro() {
if(isset($_GET['brand'])){
$brand_id = $_GET['brand'];
global $con;
$run_brand_pro = mysqli_query($con,"SELECT * FROM products WHERE product_brand = '$brand_id'") or die(mysqli_error($con));
$count_brands = mysqli_num_rows($run_brand_pro);
if($count_brands == 0) {
echo "<div class='no-cat'>
<h1> We're sorry! There are currently no products for that sex. :(</h1>
</div>";
} else {
while($row_brand_pro = mysqli_fetch_array($run_brand_pro)) {
$pro_id = $row_brand_pro['product_id'];
$pro_cat = $row_brand_pro['product_cat'];
$pro_brand = $row_brand_pro['product_brand'];
$pro_title = $row_brand_pro['product_title'];
$pro_price = $row_brand_pro['product_price'];
$pro_image = $row_brand_pro['product_image'];
echo "
<div class='single-product cf'>
<h4><a href='#'>$pro_title</a></h4>
<a href='details.php?pro_id=$pro_id'><img src='admin/product_images/$pro_image' /></a>
<p>
Price: $ $pro_price
</p>
<a href='index.php?add_cart=$pro_id'><button>Add To Cart</button></a>
</div>
";
}
}
}
}
NOTE: It works fine when one product is in the cart.
I'm trying to materialize pagination. I want to fetch like
$sql2 = "select * from phptest.memo order by num desc limit $start,$start+$scale";
and i used while paragraph to show memo and ripple (ripple database has parent field that what number of memo and it's order num primary field) but I think it seems like typed wrong code what should i do? It's image that I want make
Expected result:
Error:
<?php
session_start();
// echo "<a href='memo.php?page=$i'> $i </a>";
$scale=5; // page per writing
// start recored number newest writing is up
// $page 값에 다른 시작 레코드 넘버값, 가장 높은 글번호(최신글 부터 밑으로)
$start = ($page - 1) * $scale; //0,5,10 ...
if(!isset($_REQUEST["page"]))
{
$page = 1; // initialize seeing page
}else{
$page = $_REQUEST["page"];
}
require_once '../lib/dbconn.php';
$pdo = db_connect();
if(isset($_SESSION["userid"])){
$userid = $_SESSION["userid"];
}else{
$userid = "";
}
// start recored number newest writing is up
try{
//$sql = "select * from phptest.memo order by num desc";
$sql2 = "select * from phptest.memo order by num desc limit $start,$start+$scale";
$stmh = $pdo->query($sql2);
} catch (PDOException $ex) {`enter code here`
print "오류: ".$ex->getMessage();
}
$total_record = $stmh->rowCount();
$number = $total_record - $start;
// 전체 페이지 수 계산..
if ($total_record % $scale == 0)
$total_page = floor($total_record/$scale);
else
$total_page = floor($total_record/$scale) + 1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<link href="../css/common.css" rel="stylesheet" type="text/css" media="all">
<link href="../css/memo.css" rel="stylesheet" type="text/css" media="all">
</head>
<body>
<div id="wrap">
<div id="header">
<?php include "../lib/top_login2.php"; ?>
</div> <!-- end of header -->
<div id="menu">
<?php include "../lib/top_menu2.php"; ?>
</div> <!-- end of menu -->
<div id="content">
<div id="col1">
<div id="left_menu">
<?php
include "../lib/left_menu.php";
?>
</div>
</div>
<div id="col2">
<div id="title">
<img src="../img/title_memo.gif">
</div>
<?php
// if(isset($_SESSION["userid"])){
?>
<div id="memo_row1">
<form name="memo_form" method="post" action="insert.php">
<?php if(isset($_SESSION['nick'])){ ?>
<div id="memo_writer"><span >▷ <?=$_SESSION['nick'] ?> </span></div>
<?php }?>
<div id="memo1"><textarea rows="6" cols="95" name="content"></textarea></div>
<div id="memo2"><input type="image" src="../img/memo_button.gif"></div>
</form>
</div> <!-- end of memo_row1 -->
<?php // }
while ($row = $stmh->fetch(PDO::FETCH_ASSOC))
{
// $stmh = $pdo->query($sql2);
//$row[$i] = $row;
// $row = $stmh2->fetch(PDO::FETCH_ASSOC);
$memo_id = $row['id'];
$memo_num = $row['num'];
$memo_date = $row['regist_day'];
$memo_nick = $row['nick'];
$memo_content = $row['content'];
$memo_content = str_replace("\n", "<br>", $row['content']);
$memo_content = str_replace(" ", " ", $memo_content);
?>
<div id="memo_writer_title">
<ul>
<li id="writer_title1"><?= $memo_num ?></li> <!--article number -->
<li id="writer_title2"><?= $memo_nick ?></li>
<li id="writer_title3"><?= $memo_date ?></li>
<li id="writer_title4">
<?php
if($userid=="admin" || $userid==$memo_id)
echo "<a href='delete.php?num=$memo_num'>[삭제]</a>";
?>
</li>
</ul>
</div>
<div id="memo_content"><?= $memo_content ?>
</div>
<div id="ripple">
<div id="ripple1">덧글</div>
<div id="ripple2">
<?php
$sql3 = "select * from phptest.memo_ripple where parent=$memo_num";
$stmh3 = $pdo->query($sql3);
while ($row_ripple = $stmh3->fetch(PDO::FETCH_ASSOC))
{
$ripple_num = $row_ripple["num"];
$ripple_id = $row_ripple["id"];
$ripple_nick = $row_ripple["nick"];
$ripple_content = str_replace("\n", "<br>", $row_ripple["content"]);
$ripple_content = str_replace(" ", " ", $ripple_content);
$ripple_date = $row_ripple["regist_day"];
?>
<div id="ripple_title">
<ul>
<li><?= $ripple_nick ?> <?= $ripple_date ?></li>
<li id="mdi_del">
<?php
if($userid=="admin" || $userid==$ripple_id)
echo "<a href='delete_ripple.php?num=$ripple_num'>삭제</a>";
?>
</li>
</ul>
</div>
<div id="ripple_content"> <?= $ripple_content ?></div>
<?php
}
if(isset($_SESSION["userid"])){
?>
<form name="ripple_form" method="post" action="insert_ripple.php">
<input type="hidden" name="num" value="<?= $memo_num ?>">
<div id="ripple_insert">
<div id="ripple_textarea">
<textarea rows="3" cols="80" name="ripple_content"></textarea>
</div>
<div id="ripple_button"><input type="image" src="../img/memo_ripple_button.png"></div>
</div>
</form>
<?php } ?>
</div> <!-- end of ripple2 -->
<div class="clear"></div>
<div class="linespace_10"></div>
<?php
//$number--;
}
?>
<div id="page_num"> ◀ 이전
<?php
// page link num
// 게시판 목록 하단에 페이지 링크 번호 출력
for ($i=1; $i<=$total_page; $i++)
{
if ($page == $i) // ���� ������ ��ȣ ��ũ ����
{
echo "<b> $i </b>";
}
else
{
echo "<a href='memo.php?page=$i'> $i </a>";
}
}
?>
다음 ▶</div>
</div> <!-- end of ripple -->
</div> <!-- end of col2 -->
</div> <!-- end of content -->
</div> <!-- end of wrap -->
</body>
</html>
The SQL doesn't like doing maths in the limit clause. Do it first in PHP:
$sql2 = "select * from phptest.memo order by num desc limit $start," . ($start+$scale);
I've been coding PHP for 2 weeks (it's not pretty) and I have not been able to find the answer to my question. I want an admin type user to be able to fill a form and post it to a page where base level users can view the content. I've gotten all of this to work like a charm, but my dilemma is to allow the admin user to include an image as well. Maybe I just don't know what to search for.
Here is the php code and the form for the admin user page:
<?php
error_reporting(E_ALL & ~E_NOTICE);
session_start();
include_once("connection.php");
if (isset($_SESSION['adminid'])) {
$adminid = $_SESSION['adminid'];
$adminemail = $_SESSION['adminemail'];
if ($_POST['submit']) {
$title = $_POST['title'];
$deadline = $_POST['deadline'];
$content = $_POST['content'];
$sql_blog = "INSERT INTO blog (title, deadline, content, logoname) VALUES ('$title', '$deadline', '$content', '$logoname')";
$query_blog = mysqli_query($dbcon, $sql_blog);
echo "<script>alert('Your inquiry has been posted')</script>";
}
} else {
header('Location: index.php');
die();
}
$sql = "SELECT adminid, adminemail, adminpassword, adminname FROM admin WHERE adminemail = '$adminemail' LIMIT 1";
$query = mysqli_query($dbcon, $sql);
if ($query) {
$row = mysqli_fetch_row($query);
$adminname = $row[3];
}
?>
and here is the code for the base level user page: (i commented out the image block where I want the admin's image to be shown.
<main>
<div class="container">
<div class="row topbuffpost">
<h1>business inquiries</h1>
<hr>
<?php
include_once('connection.php');
$sql = "SELECT * FROM blog ORDER BY id DESC";
$result = mysqli_query($dbcon, $sql);
while ($row = mysqli_fetch_array($result)) {
$title = $row['title'];
$content = $row['content'];
$date = strtotime($row['deadline']);
?>
<div class="col-md-4 col-lg-3">
<div class="card hoverable">
<!-- <div class="card-image">
<div class="view overlay hm-white-slight z-depth-1">
<img src="">
<a href="#">
<div class="mask waves-effect">
</div>
</a>
</div>
</div> -->
<div class="card-content">
<h5> <?php echo $title; ?> <br/> <h6>Deadline |<small> <?php echo date("j M, Y", $date); ?> </small> </h6></h5> <br/>
<p> <?php echo $content; ?> </p>
<div class="card-btn text-center">
Read more
<i class="fa fa-lightbulb-o"></i>  propose a plan
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</main>
All of this works perfectly, I just can't figure out how to have an image display in the same way as the title, deadline, and content. Youtube wont help either, too much outdated php + I haven't been coding long enough to really work things out on my own.
You can save all user images under a folder (let's call /images/user) and record the file name into database.
if ($_POST['submit']) {
$title = $_POST['title'];
$deadline = $_POST['deadline'];
$content = $_POST['content'];
$logoname = basename($_FILES["fileToUpload"]["logoname"]; // <-- Make sure your form is ready to submit an file
// Update below as per your need.
$target = 'images/users/' . $logoname;
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target);
$sql_blog = "INSERT INTO blog (title, deadline, content, logoname) VALUES ('$title', '$deadline', '$content', '$logoname')";
$query_blog = mysqli_query($dbcon, $sql_blog);
echo "<script>alert('Your inquiry has been posted')</script>";
}
You can then display the image your page
<main>
<div class="container">
<div class="row topbuffpost">
<h1>business inquiries</h1>
<hr>
<?php
include_once('connection.php');
$sql = "SELECT * FROM blog ORDER BY id DESC";
$result = mysqli_query($dbcon, $sql);
while ($row = mysqli_fetch_array($result)) {
$title = $row['title'];
$content = $row['content'];
$date = strtotime($row['deadline']);
$logoname = 'images/user/' . $row['logoname'];
?>
<div class="col-md-4 col-lg-3">
<div class="card hoverable">
<div class="card-image">
<div class="view overlay hm-white-slight z-depth-1">
<img src="<?php echo $logoname; ?>">
<a href="#">
<div class="mask waves-effect">
</div>
</a>
</div>
</div>
<div class="card-content">
<h5> <?php echo $title; ?> <br/> <h6>Deadline |<small> <?php echo date("j M, Y", $date); ?> </small> </h6></h5> <br/>
<p> <?php echo $content; ?> </p>
<div class="card-btn text-center">
Read more
<i class="fa fa-lightbulb-o"></i>  propose a plan
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</main>
I am working on a little search engine in PHP & MySQL. Yesterday, I restyled (I did changes only at the HTML part, no php code was touched) the result page, after that I was unable to search for a term.
New code:
<?php
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
require_once("lucene.php");
?>
<?php
$row1 = [];
$row2 = [];
$search_word = false;
if(isset($_POST["submit"])) {
//edit this with your credentials
$con = mysqli_connect("localhost", "root", "pass", "db");
if(mysqli_connect_error()) echo "Connection Fail";
else {
$search_word = true;
$input = $_POST["s_input"];
// tokenize input
$tokens = tokenize($input);
//compute weight of every token
$token_weight = compute_weight($tokens, $con);
$sql1 = "SELECT *, match(description) against('". $input ."') as score FROM web where match(description) against('".$input."') order by score desc";
$sql2 = "SELECT *, match(description) against('". $input ."') as score FROM web where match(description) against('".$input."') order by score desc";
$result1 = mysqli_query($con, $sql1);
$result2 = mysqli_query($con, $sql2);
$sql3 = "SELECT * FROM web";
$numDocs = (mysqli_num_rows(mysqli_query($con, $sql3)));
$maxOverlap = sizeof($tokens);
$ctr2 = 0;
while($ctr2 != $maxOverlap){
//compute inverse_document_frequency of term
$sql3 = "SELECT *, match(description) against('".$tokens[$ctr2]."') FROM web where match(description) against('".$tokens[$ctr2]."')";
$docFreq = (mysqli_num_rows(mysqli_query($con, $sql3)));
$idf[$tokens[$ctr2]] = idf($numDocs, $docFreq);
$ctr2++;
}
$ctr = 0;
while($r1 = mysqli_fetch_array($result1)){
$row1[$ctr]['ID'] = $r1['ID'];
$row1[$ctr]['title'] = $r1['title'];
$row1[$ctr]['description'] = highlight_words($r1['description'], $tokens);
$row1[$ctr]['credit'] = $r1['credit'];
$row1[$ctr]['url'] = $r1['url'];
$document = strtolower($row1[$ctr]['description']);
$ctr2 = 0;
$summation = 0;
while ($ctr2 != sizeof($tokens)) {
//compute term_frequency(term in document)
$term_frequency = tf($tokens[$ctr2], $document);
//get idf of term
$inverse_document_frequency = $idf[$tokens[$ctr2]];
//compute norm
$norm = norm($document);
$ctr2++;
$summation += $term_frequency*$inverse_document_frequency*$inverse_document_frequency*$norm;
}
$queryNorm = queryNorm($idf, $tokens);
$coord = coord($tokens, $document, $token_weight);
$lucene_score = $summation * $coord * $queryNorm;
$row1[$ctr]['score'] = $lucene_score;
$ctr++;
}
$row1 = orderBy($row1);
/*
desc score = number of word ocurrences * weight + match_against weight
+ 2(if exact words occur)
*/
$ctr = 0;
while($r2 = mysqli_fetch_array($result2)){
$row2[$ctr]['ID'] = $r2['ID'];
$row2[$ctr]['title'] = $r2['title'];
$row2[$ctr]['description'] = highlight_words($r2['description'], $tokens);
$row2[$ctr]['credit'] = $r2['credit'];
$row2[$ctr]['url'] = $r2['url'];
$desc = strtolower($row2[$ctr]['description']);
$ctr2 = 0;
$total_weight = 0;
$flag = 0;
while ($ctr2 != sizeof($tokens)) {
$weight = substr_count($desc, $tokens[$ctr2]) * $token_weight[$tokens[$ctr2]];
if ($weight == 0)
$flag++;
$total_weight += $weight;
$ctr2++;
}
//occurence of exact word * weight * 2
$exact_word_weight = substr_count($desc, $input) * $total_weight * 5;
$total_weight += $flag;
$row2[$ctr]['score'] = $r2['score'] + $total_weight + $exact_word_weight;
$ctr++;
}
$row2 = orderBy($row2);
}
mysqli_close($con);
}
?>
<!DOCTYPE>
<html>
<head>
<TITLE>Search Engine</TITLE>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/search.css">
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Solve Simplex JavaScript -->
<script src="js/validation.js"></script>
</head>
<body>
<div id="wrapper">
<nav>
<form name="search_form" id="search_form" validate method="post">
<div class="left">
<img src="images/logo.png" attr="google logo">
<input type="text" class="textbox" id="obj_function" name="s_input">
<button type="submit" id="search_button" name="submit">
</form>
</div>
<div class="right">
<img src="images/button.png">
Sign In
</div>
</nav>
<div class="nav2">
<ul>
<li class="active">Web</li>
<li>Images </li>
<li>Videos</li>
<li>More <span><img src="images/dropdown.png"></span></li>
<li>Search Tools</li>
</ul>
</div>
<div class="search_results">
<ol>
<li>
<?php
$ctr = 0;
while ($ctr != count($row2)){
echo "<h1><a href=''#'> ".$row2[$ctr]['title']."</a></h1>";
echo "<div class='grey_green_links'>";
echo "<p class='green'>".$row2[$ctr]['url']."<span><img src='images/search_result_link_dropdown.png'></span></p>";
echo "<tr class = 'active'><td>"."<b>Description: </b>".($row2[$ctr]['description']."</td><td></td></tr>");
echo "<tr><td><br></br></td><td></td></tr>";
$ctr++;
}
?>
</li>
</ol>
<div class="page_nav">
<img src="images/pagination_logo.png" alt="pagination page logo">
<ol>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li id="next">10</li>
<li>Next</li>
</ol>
</div>
<footer>
<div class="top">
<p>
<img src="images/your_location_dot.png">
<span class="light_grey">Mars, TX - From your Internet address -</span> Use precise lcoation - Learn more
</p>
</div>
<div class="bottom">
<ul>
<li>Help</li>
<li>Send feedback</li>
<li>Privacy</li>
<li>Terms</li>
</ul>
</div>
</footer>
</div>
</body>
</html>
I personally thinks that bug is somewhere in this section of code, but I can't figure out where it should be. Can someone look at it, and maybe lend me a hand ?
<form name="search_form" id="search_form" validate method="post">
<div class="left">
<img src="images/logo.png" attr="google logo">
<input type="text" class="textbox" id="obj_function" name="s_input">
<button type="submit" id="search_button" name="submit">
</form>
I rewrited it a little bit and it's working, thanks to everyone for help.
Got some trouble when i tried to use an url to image.
<div class="col-lg-12">
<h1 class="page-header">Anime!</h1>
</div>
<?php
include "config/database.php";
$sql = "SELECT * FROM anime WHERE status = 'On Going' ORDER BY id";
$query = mysql_query($sql);
if ($query > 0){
?>
<div class="container">
<div class="description-plate">
<?php
while
($row = mysql_fetch_array($query)){
$id = $row['id'];
$image = $row['image'];
$title = $row['title'];
$genre = $row['genre'];
$start = $row['start'];
$schedule = $row['schedule'];
$description = $row['description'];
?>
<!--div class="caption-btm">
<p style="margin-left:6px; margin-top:175px;">Start Airing From:</p>
<h5 style="margin-left:10px;"><?php echo $start; ?></h5>
<p style="margin-left:6px;">Airing Schedule:</p>
<h5 style="margin-left:10px;"><?php echo $schedule; ?></h5>
</div-->
<div class="thumbnail-fluid">
<a href="<?php echo $row['image']; ?>">
<div id="og-plate">
<div><img src="admin/<?php echo $row['image']; ?>"></div>
<?php } ?>
</div>
</a>
</div>
</div>
<?php } ?>
</div>
So when i tried to call the image using php, the tag only appear on the last image. What i'm trying to do is having the tag on every images. Would appreciate any help, thanks :)
Right now you are going through the loop (not sure why you are using while) and each time creating
<div class="thumbnail-fluid">
<a href="<?php echo $row['image']; ?>">
<div id="og-plate">
<div><img src="admin/<?php echo $row['image']; ?>"></div>
<?php } ?>
</div>
</a>
</div>
What you want to do is build up an html string on each pass appending the next image tag, something more like
...
$myimages = '';
while // skipped details
$myimages .= ' <div class="thumbnail-fluid">
<a href=". $row['image'] . '>
<div id="og-plate">
<div><img src="admin/' . $row['image'] . '></div>'
. '</div>
</a>
</div>';
}
Its appear last image because ORDER BY id and the condition status = 'On Going' can return one image. Your html structure should be like this.
<div class="col-lg-12">
<h1 class="page-header">Anime!</h1>
</div>
<?php
include "config/database.php";
$sql = "SELECT * FROM anime WHERE status = 'On Going' ORDER BY id";
$result = mysql_query($sql);
$n = mysql_num_rows($result);
if ($n > 0) {
?>
<div class="container">
<div class="description-plate">
<?php
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$image = $row['image'];
$title = $row['title'];
$genre = $row['genre'];
$start = $row['start'];
$schedule = $row['schedule'];
$description = $row['description'];
?>
<div class="thumbnail-fluid">
<a href="<?php echo $row['image']; ?>">
<div id="og-plate">
<div><img src="admin/<?php echo $row['image']; ?>"></div>
</div>
</a>
</div>
<?php } ?>
</div>
</div>
<?php } ?>