Im having difficulty displaying videos and images at the same time - php

Here is my code, right now i have 2 filters 1 for displaying just images and the other for displaying just videos. The thing that i am having difficulty with is displaying images and videos in the same row. Because whenever i do so it will show the video/image and then a blank video/image depending on which of the two fields is emtpy in my db. Does anyone know how i can display videos and images as the default?
<?php
include('config.php');
session_start();
?>
<body class="body">
<form method="post" action="index.php">
<input type="submit" name="switch_video" value="switch to videos" id="switch_video">
</form>
<form method="post" action="index.php">
<input type="submit" name="switch_image" value="switch to images" id="switch_image">
</form>
</span>
</div>
</body>
<?php
if(isset($_POST['switch_video'])) {
$query = "SELECT * FROM meme_vote WHERE image = '' ORDER BY vote DESC LIMIT 500";
$res = mysqli_query($conn, $query);
} if(isset($_POST['switch_image'])) {
$query2 = "SELECT * FROM meme_vote WHERE video_location = '' ORDER BY vote DESC LIMIT 500";
$res_image = mysqli_query($conn, $query2); }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meme Voting System</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<?php while($row = mysqli_fetch_assoc($res)){ $location = $row['video_location'];?>
<div class="col-md-4">
<div class="post">
<h4 class="post-title"><?php echo $row['title']?></h4>
<div class="postdesign">
<a href="big_meme.php?id=<?=$row['id'];?>">
<video src="<?php echo $row['video_location'] ?>" width="100%" height="240" controls></video>
</a> <?php /*<img src="data:image/jpeg;base64, <?= base64_encode($row['image']) ?>" height="280" width="240px" class="img-thumnail" />*/ ?>
<span>
<a href="javascript:void(0)" class="btn btn-info btn-lg">
<span class="glyphicon glyphicon-thumbs-up " onclick="like_update('<?php echo $row['id']?>')">Like
(<span class="like_loop_<?php echo $row['id']?>"><?php echo $row['vote']?></span>)
</span> </a>
<p class="post_info"><?php echo 'Uploaded by: '; echo $row['username'] ?></p>
<p class="post_info"><?php echo 'Category: '; echo $row['category']?></p>
</span>
</div>
</div>
</div>
<?php }?>
</div>
</div>
<div class="container">
<div class="row">
<?php while($row = mysqli_fetch_assoc($res_image)){?>
<div class="col-md-4">
<div class="post">
<h4 class="post-title"><?php echo $row['title']?></h4>
<div class="postdesign">
<a href="big_meme_image.php?id=<?=$row['id'];?>">
<img src="data:image/jpeg;base64, <?= base64_encode($row['image']) ?>" height="280" width="240px" class="img-thumnail" />
</a> <?php /*<img src="data:image/jpeg;base64, <?= base64_encode($row['image']) ?>" height="280" width="240px" class="img-thumnail" />*/ ?>
<span>
<a href="javascript:void(0)" class="btn btn-info btn-lg">
<span class="glyphicon glyphicon-thumbs-up " onclick="like_update('<?php echo $row['id']?>')">Like
(<span class="like_loop_<?php echo $row['id']?>"><?php echo $row['vote']?></span>)
</span> </a>
<p class="post_info"><?php echo 'Uploaded by: '; echo $row['username'] ?></p>
<p class="post_info"><?php echo 'Category: '; echo $row['category']?></p>
</span>
</div>
</div>
</div>
<?php }?>
</div>
</div>
<div class="container">
<div class="row">
<?php while($row = mysqli_fetch_assoc($res)){ $location = $row['video_location'];?>
<div class="col-md-4">
<div class="post">
<h4 class="post-title"><?php echo $row['title']?></h4>
<div class="postdesign">
<a href="big_meme.php?id=<?=$row['id'];?>">
<video src="<?php echo $row['video_location'] ?>" width="100%" height="240" controls></video>
</a> <?php /*<img src="data:image/jpeg;base64, <?= base64_encode($row['image']) ?>" height="280" width="240px" class="img-thumnail" />*/ ?>
<span>
<a href="javascript:void(0)" class="btn btn-info btn-lg">
<span class="glyphicon glyphicon-thumbs-up " onclick="like_update('<?php echo $row['id']?>')">Like
(<span class="like_loop_<?php echo $row['id']?>"><?php echo $row['vote']?></span>)
</span> </a>
<p class="post_info"><?php echo 'Uploaded by: '; echo $row['username'] ?></p>
<p class="post_info"><?php echo 'Category: '; echo $row['category']?></p>
</span>
</div>
</div>
</div>
<?php }?>
</div>
</div>
<style>
.post_info {
position: relative; left: 140px; bottom: 40px;
}
.post {
position: relative; top: 100px;
}
</style>
<script>
function like_update(id){
var cur_count = jQuery('.like_loop_'+id).html();
cur_count++
jQuery('.like_loop_'+id).html(cur_count);
jQuery.ajax({
url:'update_count.php',
type:'post',
data:'type=like&id='+id,
success:function(result){
}
})
}
</script>
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
} </script>
</body>
</html>

Related

Hide and show button based on user SESSION in php foreach loop

Im trying to not show the remove button to the users that did not uploaded image to website, and I want the remove button be shown only for the user that uploaded a specific image.
The problem is, it is in foreach loop, I tried with
if($user_id == $_GET['id']
but it show every button, but when I put
if($user_id != $_GET['id'])
all button disappear.
This is the button I would like to show/hide
<?php
require('dbconfig.php');
if(!$user->is_loggedIn()) {
$user->Redirect('index.php');
}
$user_id = $_SESSION['user_session'];
$stmt = $db_conn->prepare("SELECT * FROM users WHERE user_id=:user_id");
$stmt->execute(array(":user_id"=>$user_id));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
// print_r($userRow);
if(isset($_POST['ok'])) {
$folder = "/Library/WebServer/Documents/Website/uploads/";
$image = $_FILES['image']['name'];
$path = $folder . $image ;
$target_file=$folder.basename($_FILES["image"]["name"]);
$imageFileType=pathinfo($target_file,PATHINFO_EXTENSION);
$allowed=array('jpeg','png' ,'jpg'); $filename=$_FILES['image']['name'];
$ext=pathinfo($filename, PATHINFO_EXTENSION);
if(!in_array($ext,$allowed)) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
} else {
$success = "Image uploaded successfully";
move_uploaded_file( $_FILES['image'] ['tmp_name'], $path);
$stmt = $db_conn->prepare("INSERT INTO images (img, user_id) VALUES (:image, :user_id)");
$stmt->bindparam(":image",$image);
$stmt->bindparam(":user_id",$user_id);
$stmt->execute();
}
}
$subjects = $db_conn->prepare("SELECT img FROM images");
$subjects->setFetchMode(PDO::FETCH_ASSOC);
$subjects->execute();
$stmt = $db_conn->prepare("SELECT user_id FROM images");
$stmt->execute();
$nesto=$stmt->fetchAll(PDO::FETCH_ASSOC);
echo '<pre>';
print_r($nesto);
echo '</pre>';
// echo $nesto['user_id'];
$ids = $_GET['id'];
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v4.0.1">
<title>Management</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="album.css" rel="stylesheet">
</head>
<body>
<header>
<div class="navbar navbar-dark bg-dark shadow-sm">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="mr-2" viewBox="0 0 24 24" focusable="false"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"></path><circle cx="12" cy="13" r="4"></circle></svg>
<strong>Pictures</strong>
</a>
Home
Profile
</div>
</div>
</header>
<main role="main">
<section class="jumbotron text-center">
<div class="container">
<h1>Shared Gallery</h1>
<p class="lead text-muted"><?php print($userRow['user_name']); ?></p>
<p>
<p><?php echo $success; ?></p>
<!-- Upload Image Form -->
<div>
<form method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" name="ok"/>
</form>
</div>
<!-- End Upload Image Form -->
Logout
</p>
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<div class="row">
<!-- START -->
<?php foreach($subjects as $subject) { ?>
<div class="col-md-4">
<div class="card mb-4 shadow-sm">
<img src="uploads/<?php echo $subject['img']; ?>" class="bd-placeholder-img card-img-top" width="100%" height="225" focusable="false"/>
<div class="card-body">
<p class="card-text">
<ul>
<li>Username</li>
<li>Email</li>
<li>Address</li>
</ul>
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
THIS IS THE BUTTON I WANT TO SHOW AND HIDE
<button type="button" class="btn btn-sm btn-outline-secondary">Remove</button>
THIS IS THE BUTTON I WANT TO SHOW AND HIDE
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<?php } ?>
<!-- END -->
</div>
</div>
</div>
</main>
<footer class="text-muted">
<div class="container">
<p class="float-right">
Back to top
Back to index
</p>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="/docs/4.5/assets/js/vendor/jquery.slim.min.js"><\/script>')</script><script src="/docs/4.5/dist/js/bootstrap.bundle.min.js" integrity="sha384-1CmrxMRARb6aLqgBO7yyAxTOQE2AKb9GfXnEo760AUcUmFx3ibVJJAzGytlQcNXd" crossorigin="anonymous"></script>
</body></html>
If you change these 2 queries into one query, you would have a resultset with the img and the users id, you can then use that to compare with the user that is logged in
//$subjects = $db_conn->prepare("SELECT img FROM images");
//$subjects->setFetchMode(PDO::FETCH_ASSOC);
//$subjects->execute();
//$stmt = $db_conn->prepare("SELECT user_id FROM images");
//$stmt->execute();
//$nesto=$stmt->fetchAll(PDO::FETCH_ASSOC);
Replace as
$result = $db_conn->query("SELECT img, user_id FROM images");
$subjects = $result->fetchAll(PDO::FETCH_ASSOC);
Then around your button you can do
<?php
// If this user uploaded this image they are allowed to remove it
if ($subject->user_id == $_SESSION['user_session']) :
<button type="button" class="btn btn-sm btn-outline-secondary">Remove</button>
endif;
?>
Big Note
I dont see a session_start() in this code, as you are using $_SESSION you would need one of those right at the top of this script.
I decided to do it this way
This worked for me perfectly.
<!-- START -->
<?php foreach($subjects as $subject) : ?>
<div class="col-md-4">
<div class="card mb-4 shadow-sm">
<img src="uploads/<?php echo $subject['img']; ?>" class="bd-placeholder-img card-img-top" width="100%" height="225" focusable="false"/>
<div class="card-body">
<p class="card-text">
<ul>
<li><?php echo $subject['img_id']; ?></li>
<li><?php echo $subject['user_name']; ?></li>
<li><?php echo $subject['user_email']; ?></li>
<li>Address</li>
</ul>
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<?php foreach($subject as $val) : ?>
<?php if ($user_id == $_SESSION['user_session'] && $val == $user_id) : ?>
<?php $id = $subject['img_id']; ?>
<form method="POST" action="<?php echo "delete.php?id=" . $subject['img_id']?>">
<!-- <button name="remove" type="button" class="btn btn-sm btn-outline-secondary">Remove</button> -->
<input type="hidden" name="del" value="1" />
<input type="submit" name="del" class="btn btn-sm btn-outline-secondary" value="Remove" />
</form>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<!-- END -->

How Not To Execute Data If imgProductx Is NULL In The Database

I have to following php code where I want to execute the image function if there is an image to show. Which means If the image field is empty/NULL I dont want to show the image, because it will give an error saying 'no image found'.
How can I do this?
Thanks in advance.
<div>
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct2'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct2']);?>" class="img-fluid" alt="Product2" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct3'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct3']);?>" class="img-fluid" alt="Product3" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct4'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct4']);?>" class="img-fluid" alt="Product4" />
<?php } ?>
</div>
(Goes till imgProduct8)
In the Database image, I have my picture data ready. In the last line you see imgProduct1 filled, imgProduct2 filled, imgProduct3 filled. After that imgProduct4 is NULL, so I dont want to execute the image function for that matter.
Database image:
In Result from the database picture, you see the result I am getting. So again imgProduct1, imgProduct2 and imgProduct3 are filled with a link, imgProduct4, imgProduct5 etc are not. So I dont want to show the image, thats not there.
Result from database:
The result I am getting now is 3 pictures in my slide show and after that just blank pictures. So he is still think there are more pictures to show.
my whole code:
<?php
require('../php/connection.php');
$product = $_GET['product'];
$sql = "SELECT * FROM tblproduct WHERE strProductNaam='$product'";
$result = sqlsrv_query($conn,$sql);
if( $result === false ) {
die( print_r( sqlsrv_errors(), true));
}
while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
$datas[] = $row;
}
echo '<pre>';
print_r($datas);
echo '</pre>';
sqlsrv_free_stmt($result);
sqlsrv_close($conn);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Gym</title>
<?php
include('../structure/effects.php');
?>
</head>
<body>
<!-- Header -->
<?php
include('../structure/header.php');
?>
<!-- /Header -->
<!-- Main -->
<main>
<br>
<!-- Product Section -->
<section class="single-product">
<div class="container">
<div class="row">
<div class="col-md-5">
<div class="container-fluid p-0">
<div class="site-slider">
<div class="slider-one">
<div>
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct2'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct2']);?>" class="img-fluid" alt="Product2" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct3'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct3']);?>" class="img-fluid" alt="Product3" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct4']);?>" class="img-fluid" alt="Product4" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct5']);?>" class="img-fluid" alt="Product5" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct6']);?>" class="img-fluid" alt="Product6" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct7']);?>" class="img-fluid" alt="Product7" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct8']);?>" class="img-fluid" alt="Product8" />
<?php } ?>
</div>
</div>
<div class="slider-button">
<span class="prev position-top"><i class="fas fa-chevron-left"></i></span>
<span class="next position-top right-0"><i class="fas fa-chevron-right"></i></span>
</div>
</div>
</div>
</div>
<div class="col-md-7">
<p class="new-arrival text-center">NEW</p>
<div class="product-bottom">
<p><i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
</p>
<p><h3><?php echo ($datas[0]['strProductNaam']); ?></h3></p>
<p class="price"><h5><s>€<?php echo ($datas[0]['intPrijs']); ?></s> <b><span class="make_red">€<?php echo ($datas[0]['strSalePrijs']); ?></span> </b></h5></p>
<p><b>Availability: </b>In Stock</p>
</div>
<div class="positive">
<p><i class="fa fa-plus" aria-hidden="true"></i> <?php echo ($datas[0]['strPlusPunt1']); ?></p>
<p><i class="fa fa-plus" aria-hidden="true"></i> <?php echo ($datas[0]['strPlusPunt2']); ?></p>
</div>
<div class="negative">
</div>
<label>Quantity: </label>
<input class="text-center" type="text" value="1"></input>
<button type="button" class="btn btn-primary">Add to Cart</button>
<table class="content-table">
<thead>
<tr>
<th>Product Specifications</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Type</td>
<td><?php echo ($datas[0]['strSpecSoort']); ?></td>
</tr>
<tr class="active-row">
<td>Guarantee</td>
<td><?php echo ($datas[0]['strSpecGarantie']); ?></td>
</tr>
<tr>
<td>Material</td>
<td><?php echo ($datas[0]['strSpecMateriaal']); ?></td>
</tr>
<tr class="active-row">
<td>Weight</td>
<td><?php echo ($datas[0]['strGewicht']); ?></td>
</tr>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<!-- /Product Section -->
<!-- Product Description -->
<section class="product-description">
<div class="container">
<h6>Product Description</h6>
<p><?php echo ($datas[0]['strBeschrijving']); ?></p>
</div>
</section>
<!-- /Product Descriptionn -->
<br>
<hr class="hr">
<!-- On Sale Product -->
<?php
include('../product-sale.php');
?>
<!-- /On Sale Product -->
</main>
<!-- /Main -->
<!-- Footer -->
<?php
include('../structure/footer.php');
?>
<!-- /Footer -->
<!-- Script: Bootstrap CDN, JS -->
<?php
include('../structure/script.php');
?>
</body>
</html>
you can try updating the query:
SELECT * FROM table_name WHERE image_column != NULL
Hope so it might help you. It would be better if you provide the whole code...
SOLVED:
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<div>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
</div>
<?php } ?>
The div had to be inside of the if function. That's why a white screen popped up.

PDOException syntax error?

I am getting an error when I try to edit/update my table. It's weird because I can insert new data into the database fine and I can delete it afterwards fine. I only have problems when editing/updating the data.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='1'' at line 6' in C:\Program Files (x86)\Ampps\www\Gats\editargat.php on line 64
This is the code:
<?php
error_reporting( ~E_NOTICE );
require_once 'dbconn.php';
if(isset($_GET['edit_id'])){
$id = $_GET['edit_id'];
$editar = $conn->prepare('SELECT nom, sexe, edat, foto FROM TaulaGats WHERE id=:uid');
$editar->execute(array(':uid'=>$id));
$edit_row = $editar->fetch(PDO::FETCH_ASSOC);
extract($edit_row);
}
else{
header("Location: index.php");
}
if(isset($_POST['btn_save_updates'])){
$nom = $_POST['nom'];
$sexe = $_POST['sexe'];
$edat = $_POST['edat'];
$foto = $_FILES['imatge']['name'];
$carpeta_tmp = $_FILES['imatge']['tmp_name'];
$imatge_mida = $_FILES['imatge']['size'];
if($foto){
$carpetaImatges = 'imatges/';
$imatge_ext = strtolower(pathinfo($foto, PATHINFO_EXTENSION));
$extensions_vàlides = array('jpeg', 'jpg', 'png', 'gif');
$pic = rand(1000,1000000).".".$imatge_ext;
if(in_array($imatge_ext, $extensions_vàlides)){
if($imatge_mida < 5000000){
unlink($carpetaImatges.$edit_row['foto']);
move_uploaded_file($carpeta_tmp, $carpetaImatges.$pic);
}
else{
$error = "La foto és massa gran.";
}
}
else{
$error = "Només les extensions JPG, JPEG, PNG & GIF són admeses.";
}
}
else{
$pic = $edit_row['foto'];
}
if(!isset($error)){
$prepIexec = $conn->prepare('UPDATE TaulaGats
SET nom=:unom,
sexe=:usexe,
edat=:uedat,
foto=:ufoto,
WHERE id=:uid');
$prepIexec->bindParam(':unom', $nom);
$prepIexec->bindParam(':usexe', $sexe);
$prepIexec->bindParam(':uedat', $edat);
$prepIexec->bindParam(':ufoto', $pic);
$prepIexec->bindParam(':uid', $id);
if($prepIexec->execute()){
header("refresh:1;index.php");
}
else{
$error = "No s'ha pogut editar.";
}
}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Gats</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="estil.css">
<link rel="stylesheet" href="estil_2.css">
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="jquery-1.11.3-jquery.min.js"></script>
</head>
<body>
<div class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php" title='Gats disponibles'>Disponibles</a>
<a class="navbar-brand" href="reservats.php" title='Gats reservats'>Reservats</a>
<a class="navbar-brand" href="adoptats.php" title='Gats adoptats'>Adoptats</a>
<a class="navbar-brand" href="acollida.php" title="Cases d'acollida">Acollida</a>
<a class="navbar-brand" href="voluntaris.php" title="Llista voluntaris">Voluntaris</a>
</div>
</div>
</div>
<div class="container">
<div class="page-header">
<h1 class="h2">Editar<a class="btn btn-default" href="index.php">Veure llista gats</a></h1>
</div>
<div class="clearfix"></div>
<form method="post" enctype="multipart/form-data" class="form-horizontal">
<?php
if(isset($error)){
?>
<div class="alert alert-danger">
<?php echo $error; ?>
</div>
<?php
}
?>
<table class="table table-bordered table-responsive">
<tr>
<td><label class="control-label">Nom</label></td>
<td><input class="form-control" type="text" name="nom" value="<?php echo $nom; ?>" /></td>
</tr>
<tr>
<td><label class="control-label">Sexe</label></td>
<td><input class="form-control" type="text" name="sexe" value="<?php echo $sexe; ?>" /></td>
</tr>
<tr>
<td><label class="control-label">Edat</label></td>
<td><input class="form-control" type="text" name="edat" value="<?php echo $edat; ?>" /></td>
</tr>
<tr>
<td><label class="control-label">Foto</label></td>
<td>
<p><img src="imatges/<?php echo $foto; ?>" height="150" width="200" /></p>
<input class="input-group-edit" type="file" name="imatge" accept="image/*" />
</td>
</tr>
<tr>
<td colspan="2"><button type="submit" name="btn_save_updates" class="btn btn-default btn-guardar">
Guardar
</button>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
Index.php:
<?php
require_once 'dbconn.php';
if(isset($_GET['eliminar_id']))
{
$prepIexec = $conn->prepare('SELECT foto FROM TaulaGats WHERE id =:uid');
$prepIexec->execute(array(':uid'=>$_GET['eliminar_id']));
$imatgeRow = $prepIexec->fetch(PDO::FETCH_ASSOC);
unlink("imatges/".$imatgeRow['foto']);
$eliminar = $conn->prepare('DELETE FROM TaulaGats WHERE id =:uid');
$eliminar->bindParam(':uid', $_GET['eliminar_id']);
$eliminar->execute();
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Gats</title>
<link rel="stylesheet" href="estil_index.css">
<link rel="stylesheet" href="estil.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">
</head>
<body>
<div class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php" title='Gats disponibles'>Disponibles</a>
<a class="navbar-brand" href="reservats.php" title='Gats reservats'>Reservats</a>
<a class="navbar-brand" href="adoptats.php" title='Gats adoptats'>Adoptats</a>
<a class="navbar-brand" href="acollida.php" title="Cases d'acollida">Acollida</a>
<a class="navbar-brand" href="voluntaris.php" title="Llista voluntaris">Voluntaris</a>
</div>
</div>
</div>
<div class="container">
<div class="page-header">
<h1>Gats en adopció
<a class="btn btn-default" href="afegirgat.php"> + Afegir nou gat </a>
</h1>
</div>
<br />
<div class="row">
<?php
$prepIexec = $conn->prepare('SELECT id, nom, sexe, edat, foto FROM TaulaGats ORDER BY id ASC');
$prepIexec->execute();
if($prepIexec->rowCount() > 0)
{
while($row = $prepIexec->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<div class="col-xs-3">
<p class="page-header infoGats_nom"><?php echo $nom ?></p>
<p class="infoGats">
<?php echo $sexe." / ".$edat; ?>
</p>
<img src="imatges/<?php echo $row['foto']; ?>" class="img-rounded" width="250px" height="200px" />
<p class="page-header">
<span>
<a class="btn btn-info" href="editargat.php?edit_id=<?php echo $row['id']; ?>" title="click per editar"><span class="glyphicon glyphicon-edit"></span> Editar </a>
<a class="btn btn-success" href="mouregat.php?moure_id=<?php echo $row['id']; ?>" title="click per moure"><span class="glyphicon glyphicon-edit"></span> Moure </a>
<a class="btn btn-danger" href="?eliminar_id=<?php echo $row['id']; ?>" title="click per eliminar" onclick="return confirm('Estàs segur que vols el·liminar aquestes dades?')"><span class="glyphicon glyphicon-remove-circle"></span> El·liminar </a>
</span>
</p>
</div>
<?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
No hi ha gats per adoptar.
</div>
</div>
<?php
}
?>
</div>
</div>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

Php code in html not working as expected

I want to use this code to get results from my database and show it in html but this is not happening. Getting all weird results and am not able to fix it.
it display } ? > on my webpage at the end wonder why.And i cannot get any results from my database displayed either.
Database is proper I believe some error in html and php code(php variables in html tags).
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src=''$row['Image_URL_M']'' style='border: 0;' alt=''$row['Book_Title']''/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title=''$row['Book_Title']'' >$row['Book_Title']</a></p></div>
<div class="book-display-author"><p>$row['Book_Author']</p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price">$price</div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>
}
?>
Thanks in advance
You forget to add echo for the li element. You can try following:
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price; ?>
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src='<?php echo $row['Image_URL_M']; ?>' style='border: 0;' alt='<?php echo $row['Book_Title']; ?>'/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title='<?php echo $row['Book_Title']; ?>' ><?php echo $row['Book_Title']; ?></a></p></div>
<div class="book-display-author"><p><?php echo $row['Book_Author']; ?></p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price"><?php echo $price; ?></div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li><?php
}
?>
or You can do it this way:
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
echo '<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href="product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html" >
<img src="' . $row['Image_URL_M'] . '" style="border: 0;" alt="$row[\'Book_Title\']"/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href="product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html" title="' . $row['Book_Title'] . '" >' . $row['Book_Title'] . '</a></p></div>
<div class="book-display-author"><p> ' .$row['Book_Author'] . '</p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price">' . $price . '</div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>';
}
?>
hope it helped
Please do use open and close braces correctly.
If you want to use the HTMl code in php then all you have to do is echo
for example:
<?php
while($row = mysqli_fetch_array($result)) {
echo "<div class='book-display-centered'>{$row['Book_Author']}</div>"
}
?>
And since you have lot of data in html you can use it like this
<?php
while($row = mysqli_fetch_array($result)) {
?>
<div class='book-display-centered'><?php echo $row['Book_Author'] ?></div>
<?php
}
?>
You must echo html content or close php tag before them
Try this:
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
?>
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src="<?php echo $row['Image_URL_M']?>" style='border: 0;' alt=" <?php echo $row['Book_Title']?>"/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title="<?php echo $row['Book_Title'] ?>" > <?php echo $row['Book_Title']?></a></p></div>
<div class="book-display-author"><p><?php echo $row['Book_Author'] ?></p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price"><?php echo $price ?></div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>
<?php
}
?>
Use below code...
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
?>
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src=''$row['Image_URL_M']'' style='border: 0;' alt=''$row['Book_Title']''/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title=''$row['Book_Title']'' >$row['Book_Title']</a></p></div>
<div class="book-display-author"><p>$row['Book_Author']</p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price">$price</div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>
<?php
}
?>

Php file renders blank after being converted with Haml (Ruby)!

In order to test if the converted index.haml would work on with my wamp and localhost i did the following:
First, I renamed my index.php into index.html
Then, I typed html2haml index.html index.haml in the command line
Then, I typed haml index.haml indexnew.html in the command line
I renamed indexnew.html to indexnew.php
I tested it: localhost/projects/cross-browser/base0.9/indexnew.php
but the indexnew.php was rendered blank even if the code inside is ok:
Original Php (index.php):
<?php
include_once 'localization.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>Alex Chen - Web Development, Graphic Design, and Translation</title>
<link rel="stylesheet" type="text/css" href="styles/reset.css" />
<link rel="stylesheet" type="text/css" href="styles/global.css" />
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.1.css" />
<?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" />';} ?>
<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery.validate.js"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.1.pack.js"></script>
<script type="text/javascript" src="scripts/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="scripts/jquery.localscroll-min.js"></script>
<script type="text/javascript" src="scripts/custom.js"></script>
<?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js"></script>';} ?>
<?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js"></script>';} ?>
<?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js"></script>';} ?>
<?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js"></script>';} ?>
</head>
<body id="home">
<div id="header">
<div class="container">
<div id="banner">
<ul id="lang">
<li <?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>>ENGLISH</li>
<li <?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>><?php echo l('nav_a0'); ?></li>
<li <?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>><?php echo l('nav_a1'); ?></li>
<li <?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>><?php echo l('nav_a2'); ?></li>
</ul>
<div id="logo">
<h1><a>ALEXCHEN</a></h1>
</div>
<div id="logo2">
<ul id="nav">
<li><?php echo l('nav1'); ?></li>
<li><?php echo l('nav2'); ?></li>
</ul>
</div>
<div id="logo3">
</div>
</div><!-- #header-bottom -->
</div><!-- .container -->
</div><!-- #header -->
<div id="content">
<div class="container">
<div class="showcase">
<div class="first">
<div id="nopic">
<p><?php echo l('tagline_p'); ?></p>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase1_h3'); ?></h3>
<p><?php echo l('showcase1_p'); ?></p>
<div class="pic">
<a id="showcase1" href="#inline1"><img src="images/showcase1t.png"/></a>
<div id="inline1">
<img src="images/showcase1.png"/>
studyatbest.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase2_h3'); ?></h3>
<p><?php echo l('showcase2_p'); ?></p>
<div class="pic">
<a id="showcase2" href="#inline2"><img src="images/showcase2t.png"/></a>
<div id="inline2">
<img src="images/showcase2.png"/>
spacestudios.com
</div>
</div>
</div><!-- .pushed -->
<div class="pusher">
<h3><?php echo l('showcase3_h3'); ?></h3>
<p><?php echo l('showcase3_p'); ?></p>
<div class="pic">
<a id="showcase3" href="#inline3"><img src="images/showcase3t.png"/></a>
<div id="inline3">
<img src="images/showcase3.png"/>
alexchen.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase4_h3'); ?></h3>
<p><?php echo l('showcase4_p'); ?></p>
<div class="pic">
<a id="showcase4" href="#inline4"><img src="images/showcase4t.png"/></a>
<div id="inline4">
<img src="images/showcase4.png"/>
mattsai.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase5_h3'); ?></h3>
<p><?php echo l('showcase5_p'); ?></p>
<div class="pic">
<a id="showcase5" href="#inline5"><img src="images/showcase5t.png"/></a>
<div id="inline5">
<img src="images/showcase5.png"/>
mattsai.com
</div>
</div>
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase6_h3'); ?></h3>
<p><?php echo l('showcase6_p'); ?></p>
<div class="pic">
<a id="showcase6" href="#inline6"><img src="images/showcase6t.png"/></a>
<div id="inline6">
<img src="images/showcase6.png"/>
mattsai.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase8_h3'); ?></h3>
<p><?php echo l('showcase8_p'); ?></p>
<div class="pic">
<a id="showcase8" href="#inline8"><img src="images/showcase8t.png"/></a>
<div id="inline8">
<img src="images/showcase8.png"/>
mattsai.com
</div>
</div>
</div><!-- .pusher -->
</div><!-- .showcase -->
</div><!-- .container -->
</div><!-- #work -->
<div id="footer">
<div class="container">
<div id="footer-top">
<div id="about">
<h3><?php echo l('about_h3'); ?></h3>
<p><?php echo l('about_p'); ?></p>
</div>
<div id="info">
<h3><?php echo l('info_h3'); ?></h3>
<ul>
<li id="tel"><?php echo l('_info_li2'); ?><p>Tel:</p> 0918051170</li>
<li id="gmail"><?php echo l('_info_li3'); ?><p></p>alexchen.net#gmail.com</li>
<li id="facebook"><?php echo l('_info_li4'); ?> facebook</li>
</ul>
</div>
<div id="contact">
<h3><?php echo l('contact_h3'); ?></h3>
<p><?php echo l('_contact_p'); ?></p>
<form id="sendmail" method="post" action="http://www.emailmeform.com/fid.php?formid=254816">
<label for="name"><?php echo l('form_label1'); ?></label>
<input type="text" id="name" name="FieldData0" />
<label for="email"><?php echo l('form_label2'); ?></label>
<input type="text" id="email" name="FieldData1" />
<label for="message"><?php echo l('form_label3'); ?></label>
<textarea type="text" id="message" name="FieldData2"></textarea>
<input id="button" type="submit" value="<?php echo l('submit'); ?>">
</form>
</div>
</div><!-- #footer-top -->
<div id="footer-bottom">
<p>Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on Zymic. Contact form hosted on Email Me Form.<a id="nr" href="http://www.freedomain.co.nr/cheap_web_hosting.php" target="_blank"><img src="http://ruarmza.4u.com.ru/ch.gif" alt="Cheap Web Hosting Providers" width="88" height="31" border="0" /></a></p>
</div>
</div><!-- .container -->
</div><!-- #footer -->
<script type="text/javascript" src="scripts/google-analytics.js"></script>
<script type="text/javascript" src="scripts/page-tracker.js"></script>
</body>
</html>
Converted Php (indexnew.php):
<?php include_once 'localization.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />
<title>Alex Chen - Web Development, Graphic Design, and Translation</title>
<link href='styles/reset.css' rel='stylesheet' type='text/css' />
<link href='styles/global.css' rel='stylesheet' type='text/css' />
<link href='fancybox/jquery.fancybox-1.3.1.css' rel='stylesheet' type='text/css' />
<?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" ?>
';} ?>
<script src='scripts/jquery-1.3.2.min.js' type='text/javascript'></script>
<script src='scripts/jquery.validate.js' type='text/javascript'></script>
<script src='fancybox/jquery.fancybox-1.3.1.pack.js' type='text/javascript'></script>
<script src='scripts/jquery.scrollTo-min.js' type='text/javascript'></script>
<script src='scripts/jquery.localscroll-min.js' type='text/javascript'></script>
<script src='scripts/custom.js' type='text/javascript'></script>
<?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js?>
';} ?>
<?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js?>
';} ?>
<?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js?>
';} ?>
<?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js?>
';} ?>
</head>
<body id='home'>
<div id='header'>
<div class='container'>
<div id='banner'>
<ul id='lang'>
<li
<?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>
>
</ul>
<a href='index.php?lang=en'>ENGLISH</a>
<li
<?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=es'>
<?php echo l('nav_a0'); ?>
</a>
<li
<?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=zh-tw'>
<?php echo l('nav_a1'); ?>
</a>
<li
<?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=zh-cn'>
<?php echo l('nav_a2'); ?>
</a>
<div id='logo'>
<h1>
<a>ALEXCHEN</a>
</h1>
</div>
<div id='logo2'>
<ul id='nav'>
<li>
<a href='#content'>
<?php echo l('nav1'); ?>
</a>
</li>
<li>
<a href='#contact'>
<?php echo l('nav2'); ?>
</a>
</li>
</ul>
</div>
<div id='logo3'></div>
</div>
<!-- #header-bottom -->
</div>
<!-- .container -->
</div>
<!-- #header -->
<div id='content'>
<div class='container'>
<div class='showcase'>
<div class='first'>
<div id='nopic'>
<p>
<?php echo l('tagline_p'); ?>
</p>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase1_h3'); ?>
</h3>
<p>
<?php echo l('showcase1_p'); ?>
</p>
<div class='pic'>
<a href='#inline1' id='showcase1'>
<img src='images/showcase1t.png' />
</a>
<div id='inline1'>
<img src='images/showcase1.png' />
<a href='http://studyatbest.com'>studyatbest.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase2_h3'); ?>
</h3>
<p>
<?php echo l('showcase2_p'); ?>
</p>
<div class='pic'>
<a href='#inline2' id='showcase2'>
<img src='images/showcase2t.png' />
</a>
<div id='inline2'>
<img src='images/showcase2.png' />
<a href='http://studyatbes.com'>spacestudios.com</a>
</div>
</div>
</div>
<!-- .pushed -->
<div class='pusher'>
<h3>
<?php echo l('showcase3_h3'); ?>
</h3>
<p>
<?php echo l('showcase3_p'); ?>
</p>
<div class='pic'>
<a href='#inline3' id='showcase3'>
<img src='images/showcase3t.png' />
</a>
<div id='inline3'>
<img src='images/showcase3.png' />
<a href='http://studyatbes.com'>alexchen.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase4_h3'); ?>
</h3>
<p>
<?php echo l('showcase4_p'); ?>
</p>
<div class='pic'>
<a href='#inline4' id='showcase4'>
<img src='images/showcase4t.png' />
</a>
<div id='inline4'>
<img src='images/showcase4.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase5_h3'); ?>
</h3>
<p>
<?php echo l('showcase5_p'); ?>
</p>
<div class='pic'>
<a href='#inline5' id='showcase5'>
<img src='images/showcase5t.png' />
</a>
<div id='inline5'>
<img src='images/showcase5.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<!-- .pusher -->
<div class='pusher'>
<h3>
<?php echo l('showcase6_h3'); ?>
</h3>
<p>
<?php echo l('showcase6_p'); ?>
</p>
<div class='pic'>
<a href='#inline6' id='showcase6'>
<img src='images/showcase6t.png' />
</a>
<div id='inline6'>
<img src='images/showcase6.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase8_h3'); ?>
</h3>
<p>
<?php echo l('showcase8_p'); ?>
</p>
<div class='pic'>
<a href='#inline8' id='showcase8'>
<img src='images/showcase8t.png' />
</a>
<div id='inline8'>
<img src='images/showcase8.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<!-- .pusher -->
</div>
<!-- .showcase -->
</div>
<!-- .container -->
</div>
<!-- #work -->
<div id='footer'>
<div class='container'>
<div id='footer-top'>
<div id='about'>
<h3>
<?php echo l('about_h3'); ?>
</h3>
<p>
<?php echo l('about_p'); ?>
</p>
</div>
<div id='info'>
<h3>
<?php echo l('info_h3'); ?>
</h3>
<ul>
<li id='tel'>
<?php echo l('_info_li2'); ?>
<p>Tel:</p>
0918051170
</li>
<li id='gmail'>
<?php echo l('_info_li3'); ?>
<p></p>
<a href='mailto:janoochen#gmail.com'>alexchen.net#gmail.com</a>
</li>
<li id='facebook'>
<?php echo l('_info_li4'); ?>
<a href='http://www.facebook.com/weedd.chen'>facebook</a>
</li>
</ul>
</div>
<div id='contact'>
<h3>
<?php echo l('contact_h3'); ?>
</h3>
<p>
<?php echo l('_contact_p'); ?>
</p>
<form action='http://www.emailmeform.com/fid.php?formid=254816' id='sendmail' method='post'>
<label for='name'>
<?php echo l('form_label1'); ?>
</label>
<input id='name' name='FieldData0' type='text' />
<label for='email'>
<?php echo l('form_label2'); ?>
</label>
<input id='email' name='FieldData1' type='text' />
<label for='message'>
<?php echo l('form_label3'); ?>
</label>
<textarea id='message' name='FieldData2' type='text'></textarea>
<input id='button' type='submit' value="<?php echo l('submit'); ?>" />
</form>
</div>
</div>
<!-- #footer-top -->
<div id='footer-bottom'>
<p>
Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on
<a href='http://www.zymic.com'>Zymic</a>.
Contact form hosted on
<a href='http://www.emailmeform.com'>Email Me Form</a>.
<a href='http://www.freedomain.co.nr/cheap_web_hosting.php' id='nr' target='_blank'>
<img alt='Cheap Web Hosting Providers' border='0' height='31' src='http://ruarmza.4u.com.ru/ch.gif' width='88' />
</a>
</p>
</div>
</div>
<!-- .container -->
</div>
<!-- #footer -->
<script src='scripts/google-analytics.js' type='text/javascript'></script>
<script src='scripts/page-tracker.js' type='text/javascript'></script>
</body>
</html>
Any suggestions?
I'd suggest you try a PHP-specific version of HAML, like PHPHaml or pHAML. The Ruby HAML interpreter is specifically expecting Ruby code, and will likely screw up your PHP syntax.
Having said that, I have used Chaml with some degree of success. HAML for PHP is at a rather experimental stage, and you will come across bugs. If you're writing more HTML than PHP though, it can be a great help.

Categories