php while loop images that store in mysql and onlick modal - php

My intention is to display the content(which is stored in mysql) if the picture is clicked.
<?php
$query = "SELECT * FROM pet where pet_cat = 'D' ORDER BY petid ";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result))
{
$_SESSION['petname'] = $row['petname'];
$_SESSION['petdesc'] = $row['petdesc'];
$_SESSION['petimg'] = $row['petimg'];
echo '<li style="
padding-right: 20px;
padding-left: 20px;">';
echo '<a style= "cursor: pointer;"onclick= "document.getElementById(\'dogmod\').style.display=\'block\'">';
echo '<img src="data:image/jpeg;base64,'.base64_encode($_SESSION['petimg'] ).'" />';
echo '<h4>';
echo $_SESSION['petname'] ;
echo '</h4>';
include 'desca.php';
echo '</a>';
echo '</li>';
}
?>
The modal only display one content and that is the first content of the first picture.(sorry for bad english )
This is the code of my modal:
<div id="dogmod" class="modal">
<center>
<form class="modal-content animate" style="margin: 0; padding-left:50px; padding-right:50px; padding-bottom:50px;">
<div class="imgcontainer">
<span onclick="document.getElementById('dogmod').style.display='none'" class="close" title="Close">×</span>
<h1 align=center>Description</h1>
<?php echo '<img src="data:image/jpeg;base64,'.base64_encode($_SESSION['petimg'] ).'" style="margin-top:50px;float:left; margin-right:50px;"/>'; ?>
<h1 style="margin-top:50px;margin-bottom:50px">
<?php echo $_SESSION['petname'] ;?>
</h1>
<p style="margin-bottom:50px;">
<?php echo $_SESSION['petdesc'] ;?>
</p>
<input type="button" value="Back" onclick=location.href='doga.php' class="button_1" style=" width: auto;padding: 10px 18px; background-color: #f44336; border:0px; color:white;">
<h2> </h2>
</form>
</center>
<script>
// Get the modal
var modal = document.getElementById('dogmod');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</div>

The problem is that you are generating many modals with the same "id".
What happens in this case is that you will be displayed only the last image in the table.
Generate your modal id dynamically.
Use php and add an affix to the id attribute of the modal and call that one in your onclick event.
Here is how you do it:
$query = "SELECT * FROM pet where pet_cat = 'D' ORDER BY petid ";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result))
{
$_SESSION['petname'] = $row['petname'];
$_SESSION['petdesc'] = $row['petdesc'];
$_SESSION['petimg'] = $row['petimg'];
$_SESSION['petid'] = $row['petid'];
echo '<li style="
padding-right: 20px;
padding-left: 20px;">';
echo '<a style= "cursor: pointer;"onclick= "document.getElementById(\'dogmod'.$row['petid'].'\').style.display=\'block\'">';
echo '<img src="data:image/jpeg;base64,'.base64_encode($_SESSION['petimg'] ).'" />';
echo '<h4>';
echo $_SESSION['petname'] ;
echo '</h4>';
include 'desca.php';
echo '</a>';
echo '</li>';
}
And in your modal php file, change only your first line to:
<div id="dogmod<?=$_SESSION['petid']?>" class="modal">
You should be good to go.
To make it close just fine, do the following in your modal php template find the 'close' link:
<span onclick="document.getElementById('dogmod<?= $_SESSION['petid'] ?>').style.display='none'" class="close" title="Close">×</span>

Related

Post method not return value

I just want to share my details to another php file using POST with Ajax, in my code the post value not initiated to share,
Here is my code :
<?php
include('database_connection.php');
if(isset($_POST["action"]))
{
// some logic
// some logic
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$total_row = $statement->rowCount();
$output = '';
if($total_row > 0)
{
foreach($result as $row)
{
$output .= '
<div class="col-sm-3 col-lg-4 col-md-3">
<div style="border:1px solid #ccc; border-radius:5px; padding:10px; margin-bottom:16px; height:300px;">
<audio controls controlsList="nodownload" style="padding: 10px 10px 10px 10px;margin-left: -21px;">
<source src="audio_sample/'. $row['voice_audio_file'] .'" alt="" class="img-responsive">
</audio>
<p align="center"><strong> '. $row['voice_name'] .'</strong></p>
<p style="font-size: 12px;">
Voice Id : '. $row['voice_id'].' <br />
Voice Name : '. $row['voice_name'].' <br />
Gender : '. $row['voice_gender'].' <br />
Genres : '. $row['voice_genres'].' <br />
Voice Modulation : '. $row['voice_voice_modulation'].' <br />
Languages : '. $row['voice_languages'].' <br />
Jingle Moods : '. $row['voice_jingle_moods'].' <br />
Ivr : '. $row['voice_ivr'].' <br /> </p>
<button type="button" class="btn btn-primary" style="padding: 5px 83px 5px 83px;
"data-voice-id="'.$row["voice_id"].'
" data-voice-name="'.$row["voice_name"].'
"data-voice-id="'.$row["voice_gender"].'">Add to Playlist</button>
</div>
</div>
';
}
}
else
{
$output = '<h3>No Data Found</h3>';
}
echo $output;
}
?>
<script>
$('.btn').on('click',function() {
var voice_id = $(this).data("voice_id");
var voice_name = $(this).data("voice_name");
var voice_gender = $(this).data("voice_gender");
$.ajax({
method : "POST",
url : "manage_cart.php",
datatype : "text",
data :
{
voice_id: voice_id, voice_name: voice_name, voice_gender: voice_gender
},
success: function(data)
{
// console.log(data);
console.log('success',data);
}
});
});
</script>
I want to share voice_id, voice_name, voice_gender to manage_cart.php,
my manage_cart.php file,
<?php
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$voice_id = '';
$voice_name = '';
$voice_gender = '';
if(isset($_POST['voice_id']) && isset($_POST['voice_name']) && isset($_POST['voice_gender']) )
{
$voice_id = $_POST['voice_id'];
$voice_name = $_POST['voice_name'];
$voice_name = $_POST['voice_gender'];
}
echo $voice_id ."&". $voice_name ."&". $voice_gender;
?>
Here my post value not pass to manage_cart.php.
How can i solve the issue?
Your button attribute doesn't have data-voice-gender. There are duplicate data-voice-id, and use the same style of variable like data-voice-id but in javascript you're using $(this).data('voice_id')

Adding Sort by Price and Sort by Name

I created a website selling components. Each component has 9 products. How can I add a dropdown button which can arrange the product showing by its Price or Name?
<?php
$query = "SELECT * FROM products ORDER BY id ASC";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
?>
<div class="col-md-4">
<form method="post" action="shop.php?action=add&id=<?php echo $row["id"]; ?>">
<div style="border: 1px solid #eaeaec; margin: -1px 19px 3px -1px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); padding:10px;" align="center">
<h5 class="text-info"><?php echo $row["p_name"]; ?></h5>
<img src="<?php echo $row["image"]; ?>" class="img-responsive">
<h5 class="text-danger">$ <?php echo $row["price"]; ?></h5>
<div class="col-xs-8">
<input type="text" name="quantity" class="form-control" value="1">
</div>
<input type="hidden" name="hidden_name" value="<?php echo $row["p_name"]; ?>">
<input type="hidden" name="hidden_price" value="<?php echo $row["price"]; ?>">
<input type="submit" name="add" class="btn btn-primary" value="Add to Cart" align="right">
</div>
</form>
</div>
<?php
}
}
?>
<?php
}
?>
</div>
</div>
Perhaps you could use Javascript as well and add a few select boxes to give Users the chance to choose the Attribute they want to sort by and also the Direction of the Sorting as in ASC or DESC. The Code Snippet below might shed some light:
<?php
$query = "SELECT * FROM products ORDER BY id ASC";
$result = mysqli_query($connect, $query);
// CREATE VARIABLES TO HOLD THE SELECT OPTIONS VALUES FOR THE SORTING...
$sortParam1 = 'price';
$sortParam2 = 'name';
$sortDir1 = 'ASC';
$sortDir2 = 'DESC';
// START BUILDING THE OUTPUT...
$output = "<div class='col-md-12'>"; //<== WRAPPER FOR SORING & DIRECTION BOXES
$output .= "<form method='post' action='' id='sorting_form'>"; //<== FORM FOR THE SORTING: SUBMITS TO SAME SCRIPT
// SORTING
$output .= "<div class='col-md-6'>";
$output .= "<select name='sorting' id='sorting'class='form-control'>";
$output .= "<option value='id'>Sorting</option>";
$output .= "<option value='{$sortParam1}'>{$sortParam1}</option>";
$output .= "<option value='{$sortParam2}'>{$sortParam2}</option>";
$output .= "</select>";
$output .= "</div>";
// DIRECTION
$output .= "<div class='col-md-6'>";
$output .= "<select name='direction' id='direction'class='form-control'>";
$output .= "<option value='ASC'>Sort Direction</option>";
$output .= "<option value='{$sortDir1}'>{$sortDir1}</option>";
$output .= "<option value='{$sortDir2}'>{$sortDir2}</option>";
$output .= "</select>";
$output .= "</div>";
$output .= "</form>"; //<== CLOSE SORTING FORM...
$output .= "</div>"; //<== CLOSE WRAPPER...
$rowData = "";
// WE USE JQUERY BELOW TO SUBMIT THE SORTING FORM ONCE USER
// SELECTS ANY OPTION FROM.... SO WE NOW HANDLE THAT SCENARIO HERE USING PHP
if(isset($_POST['sorting']) || isset($_POST['direction']) ){
$sortDirection = isset($_POST['direction']) ? $_POST['direction'] : $sortDir1; // DEFAULTS TO ASC
$sortField = isset($_POST['sorting']) ? $_POST['sorting'] : 'id'; // DEFAULTS TO id
$query = "SELECT * FROM products ORDER BY {$sortField} {$sortDirection}";
$result = mysqli_query($connect, $query);
}
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)) {
// USE HEREDOC TO CAPTURE THE DATA WITHIN THE LOOP...
$rowData .=<<<R_DATA
<div class="col-md-4">
<form method="post" action="shop.php?action=add&id={$row["id"]}">
<div style="border: 1px solid #eaeaec; margin: -1px 19px 3px -1px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); padding:10px;" align="center">
<h5 class="text-info">{$row["p_name"]}</h5>
<img src="{$row["image"]}" class="img-responsive">
<h5 class="text-danger">\$ {$row["price"]}</h5>
<div class="col-xs-8">
<input type="text" name="quantity" class="form-control" value="1">
</div>
<input type="hidden" name="hidden_name" value="{$row["p_name"]}">
<input type="hidden" name="hidden_price" value={$row["price"]}">
<input type="submit" name="add" class="btn btn-primary" value="Add to Cart" align="right">
</div>
</form>
</div>
R_DATA;
} // CLOSE WHILE LOOP
} // CLOSE IF CONDITIONAL LOGIC
// ADD THE DATA GATHERED FROM WHILE LOOP ($rowData) TO THE OUTPUT: $output
$output .= $rowData;
$output .= "</div>\n</div>"; // THESE APPEAR IN YOUR CODE BUT SEEM IRRELEVANT HERE...
// DISPLAY THE OUTPUT
echo $output;
?>
<!-- ENTER JAVASCRIPT: JQUERY -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js" integrity="sha384-I6F5OKECLVtK/BL+8iSLDEHowSAfUo76ZL9+kGAgTRdiByINKJaqTPH/QVNS1VDb" crossorigin="anonymous"></script>
<script type="text/javascript">
(function($){
$(document).ready(function(e){
var sortForm = $("#sorting_form");
var sortBox = $("#sorting");
var directionBox = $("#direction");
var bothBoxes = sortBox.add(directionBox);
// IF EITHER OF THE SORTING OR DIRECTION IS CHANGED
// JUST SUBMIT THE FORM
bothBoxes.on("change", function(evt){
sortForm.submit();
});
});
})(jQuery);
</script>

Equals returns all the values in php

In this code I tried to filter some data records from the database using CategoryId but it returns all the category Id's. In my database Category Id's are INT field.
If I echo $data['Category']; then it shows all the categoryId's But after the variable comparison it not work.
I mean if($cat == 1) is Not working(It's not filter/Show data)
//Some coding here
<section id="section-1">
<div class="vs-content">
<div class="widgets-container">
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());
$sql = "SELECT Id,Title,description,Image,Category from News ";
$query = mysql_query($sql);
?>
<div class="blocks">
<?php while($data = mysql_fetch_array($query)){
$cat = $data['Category'];
if($cat == 1){
?>
<h3 style="margin-left: 10px;"><?php echo $data['Title'] ?></h3>
<div style="width: 50%; margin-right: auto; margin-left: auto;">
<img src="images/drink2.jpg" /></div>
<img src="data:image/jpeg;base64,<?php base64_encode( $data['Image'] )?>"/>
<p style="color: white; font-size: 0.6em;"><?php echo $data['Description'] ?></p>
<?php
}
}
?>
</div>
<div class="blocks">
<?php while($data = mysql_fetch_array($query)){
$cat = $data['Category'];
if($cat == 2){
?>
<h3 style="margin-left: 10px;"><?php echo $data['Title'] ?></h3>
<div style="width: 50%; margin-right: auto; margin-left: auto;">
<img src="images/drink2.jpg" /></div>
<img src="data:image/jpeg;base64,<?php base64_encode( $data['Image'] )?>"/>
<p style="color: white; font-size: 0.6em;"><?php echo $data['Description'] ?></p>
<?php
}
}
?>
</div>
<div class="blocks">
<?php while($data = mysql_fetch_array($query)){
$cat = $data['Category'];
if($cat == 3){
?>
<h3 style="margin-left: 10px;"><?php echo $data['Title'] ?></h3>
<div style="width: 50%; margin-right: auto; margin-left: auto;">
<img src="images/drink2.jpg" /></div>
<img src="data:image/jpeg;base64,<?php base64_encode( $data['Image'] )?>"/> -->
<p style="color: white; font-size: 0.6em;"><?php echo $data['Description'] ?></p>
<?php
}
}
?>
</div>
</div>
</div>
// Some coding here
Why not filter the records in your database query? This would mean changing your database query as follows:
$sql = "SELECT Id,Title,description,Image,Category from News WHERE Category = 1";
By taking this approach less data will be returned to PHP and the database call will execute a little faster :)
Update: You only really need the three different <div class="blocks"> sections if the contents within them is going to be different. Otherwise you could simply use a single while loop and output the content for all categories in sequence using the data as ordered by the SQL statement.
//Some coding here
<section id="section-1">
<div class="vs-content">
<div class="widgets-container">
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());
$sql = "SELECT Id,Title,description,Image,Category from News ORDER BY Category";
$query = mysql_query($sql);
?>
<div class="blocks">
<?php while($data = mysql_fetch_array($query)){
?>
<h3 style="margin-left: 10px;"><?php echo $data['Title'] ?></h3>
<div style="width: 50%; margin-right: auto; margin-left: auto;">
<img src="images/drink2.jpg" /></div>
<img src="data:image/jpeg;base64,<?php base64_encode( $data['Image'] )?>"/>
<p style="color: white; font-size: 0.6em;"><?php echo $data['Description'] ?></p>
<?php
}
?>
</div>
</div>
</div>
</section>
// Some coding here
If you only need data rendered for a single category then use the WHERE clause in SQL (See first example) to filter the data you require to reduce the SQL call and improve performance.
Why cant you check the condition in select query, Try this,
$sql = "SELECT Id,Title,description,Image,Category from News where Category='1'";
Update:
<div class="blocks">
<?php
while($data = mysql_fetch_array($query)){
$cat = $data['Category'];
if($cat == 1){ ?>
//Your code
<?php }else if($cat == 2){ ?>
// Your code
<?php }else{ ?>
<?php }?>
<?php }?>
</div>

CSS li inline & jquery sortable

having an issue with the jquery sortable code - it's not so much the jquery but how my list of images is showing. Prior to adding the sortable code it displayed the images in my wrapper in a grid like formation perfectly - now I have added a little style from the jquery it seems to have thrown it but im not sure why...
here is the Jquery style:
<style>
#sortable { list-style-type: none; margin: 0; padding: 0; width: 450px; }
#sortable li {float: left; }
</style>
Here is my list of images that worked perfectly ok before:
<div id="images">
<hr style="margin-top: 10px" />
<ul id="sortable">
<?php
// get folio for user
if(isset($_GET['userid'])) {
$query = 'SELECT * FROM folio WHERE userid=\'' . $_GET['userid'] . '\' ORDER BY ord';
}
else {
$query = 'SELECT * FROM folio WHERE userid=\'' . $_SESSION['userid'] . '\' ORDER BY ord';
}
$result = mysqli_query($connection, $query);
if(!$result) {
// error with MYSQL
die('Failed to retrieve images! - ' . mysqli_error($connection));
}
// list images
$numRows = mysqli_num_rows($result);
if($numRows < 1) {
echo '';
}
else {
$filepath = 'uploads/folio/';
while($imagerow = mysqli_fetch_assoc($result)) {
?>
<li>
<div class="outimgbox"> <a class="fancybox fancybox.ajax" rel="gallery1" style="text-decoration: none;" data-fancybox-type="ajax" href="profile_image_fancybox.php?imgid=<?php echo $imagerow['imgid']; ?>">
<div id="mainwrapper">
<div id="box-3" class="box"> <img class="uploads" src="<?php echo $filepath . $imagerow['filename']; ?>" alt="<?php echo $imagerow['description']; ?>"/> <span class="caption fade-caption">
<h3 ><?php echo $imagerow['title']; ?></h3>
</span> </div>
</div>
</a> </div>
</li>
<!-- class outingbox -->
<?php }} ?>
</ul>
For some odd reason:
<style>
#sortable { list-style-type: none; }
#sortable li {float: left; }
</style>
This resolved the issue....

While loop looping through data twice

So I have this code, and I've been fretting over it for several hours now and my friend and I can't find the solution. It display reviews based on a descending ID pulled from a database. This is an endless scroll type of script to eliminate pagination. For some reason when I hit the bottom of the page and run the script, the while loop is iterating through the data twice. So if its supposed to display reviews ID 5 - 10, it display 10, 9, 8, 7, 6, 5, 10, 9, 8, 7, 6, 5; instead of 10, 9, 8, 7, 6, 5. This is going to be a very large bit of code, But I hope you can help me with my problem.
Thanks in advance!!
<?php
include("../mysql_server/connect_to_mysql.php");
if($_GET['lastPost']) {
$mysqlQuery = mysql_query('SELECT * FROM `reviews` WHERE `review_id` < "' . $_GET['lastPost'] . '" ORDER BY `review_id` DESC LIMIT 0, 10');
while ($review_row = mysql_fetch_assoc($mysqlQuery)) {
$review_title = $review_row['review_title'];
$user_id = $review_row['user_id'];
$user_firstname = $review_row['user_firstname'];
$user_lastname = $review_row['user_lastname'];
$review_id = $review_row['review_id'];
$review_body = $review_row['review_body'];
$review_referral = $review_row['review_referral'];
// Code to append text for title
// strip tags to avoid breaking any html
$review_title = strip_tags($review_title);
if (strlen($review_title) > 30) {
// truncate string
$stringCut = substr($review_title, 0, 30);
// make sure it ends in a word so assassinate doesn't become ass...
$review_title = substr($stringCut, 0, strrpos($stringCut, ' ')).'...';
}
// Code to append text and add Read More
// strip tags to avoid breaking any html
$review_body = strip_tags($review_body);
if (strlen($review_body) > 230) {
// truncate string
$stringCut = substr($review_body, 0, 230);
// make sure it ends in a word so assassinate doesn't become ass...
$review_body = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a class="reviewContentLink" href="../../pages/home_page/post_content.php?id='. $review_id .'">See Full Post</a>';
} else {
$review_body .= '<a class="reviewContentLink" href="../../pages/home_page/post_content.php?id='. $review_id .'">See Full Post</a>';
}
$review_date = $review_row['review_date'];
$review_date = date_create($review_date);
$review_date = date_format($review_date, 'g:ia \o\n F jS\, Y');
$user_firstname = $review_row['user_firstname'];
$review_rating = $review_row['rating'];
/////// Mechanism to Display Pic. See if they have uploaded a pic or not //////////////////////////
$check_pic = "../members/$user_id/thumb_image01.jpg";
$default_pic = "../members/0/image01.jpg";
if (file_exists($check_pic)) {
$review_pic = "<img src=\"../$check_pic\" width=\"80px\" />";
} else {
$review_pic = "<img src=\"../$default_pic\" width=\"80px\" />";
}
include_once('../include/star_display.php');
//Pull the Review Category from the row
$review_category = "";
$review_category = $review_row['review_category'];
include_once('../include/review_category.php');
//Pull the Referral Category from the row
$referral_category = $review_row['referral_category'];
include_once('../include/referral_category.php');
//Code for URL for Each Review
$review_url = $review_row['review_url'];
if (!function_exists('remove_http')) {
function remove_http($url = '') {
return(str_replace(array('http://','https://'), '', $url));
}
}
//CODE TO DISTINGUISH REFERRALS FROM REVIEWS
//Final Output List
if($review_referral == 0) {
//Code for Displaying URL Link
$review_url = remove_http($review_url);
$review_url = "<a target='_BLANK' href='http://". $review_url ."'>Buy It Here!</a> ";
echo ''. $review_id .' '. $review_referral .'
<div class="display_newsfeed" id="'.$review_id.'">
<table id="'.$review_id.'" style="width:98.5%; border:#00B347 1px solid; margin:10px 0px 20px 10px;">
<td style="float:left; width:15%; border-right:1px solid #DDDDDD; margin:5px 0px 5px 0px;">
<div class="review_user_name">'. $user_firstname.' '. $user_lastname .'</div>
<div class="review_prof_pic">'. $review_pic .'</div>
<div class="bought_it_newsfeed">Bought It!</div>
</td>
<td style="float:right; width:82%;">
<div class="review_title_p">
<p><span class="review_title">'. $review_title .'</span><span class="review_date_p">'. $review_date .'</span><span class="review_stars">'. $review_stars .'</span></p>
</div>
<div class="review_read_more">
<p class="review_body_p">'. $review_body .'</p><br />
<div>
<div style="float:left;" class="review_black_font_link">Website:'.$review_url.'</div>
<div style="float:right; margin-right:20px;" class="review_black_font_link">Category: '.$review_category_post .'</div>
</div>
</div>
</td>
</table>
<hr style="margin:0px 20px 0px 20px;" />
</div>
';
} else if($review_referral == 1) {
//Code for Displaying URL Link
$review_url = remove_http($review_url);
$review_url = "<a target='_BLANK' href='http://". $review_url ."'>Click Here</a> ";
echo '
<div class="display_newsfeed" id="'.$review_id.'">
<table id="'.$review_id.'" style="width:98.5%; border:#0099FF 1px solid; margin:10px 0px 20px 10px;">
<td style="float:left; width:15%; border-right:1px solid #DDDDDD; margin:5px 0px 5px 0px;">
<div class="review_user_name">'. $user_firstname.' '. $user_lastname .'</div>
<div class="review_prof_pic">'. $review_pic .'</div>
<div class="referral_newsfeed">Referral</div>
</td>
<td style="float:right; width:82%;">
<div class="review_title_p">
<p>'. $review_title .'<span class="review_date_p">'. $review_date .'</span><span class="review_stars">'. $review_stars .'</span></p>
</div>
<div class="review_read_more">
<p class="review_body_p">'. $review_body .'</p><br />
<div>
<div style="float:left;" class="review_black_font_link">Business Website:'. $review_url .'</div>
<div style="float:right; margin-right:20px;" class="review_black_font_link">Category: '. $referral_category_post .'</div>
</div>
</div>
</td>
</table>
<hr style="margin:0px 20px 0px 20px;" />
</div>
';
}
}
} else {
echo "didn't work";
}
?>
Are you also sure there is no corruption in your database? you can try just
while ($review_row = mysql_fetch_assoc($mysqlQuery)) {
echo $review_row['review_title'] . "<br />";
}
Can you post the code that calls/posts to this script? As the others stated, it is quite possible this code is being called twice.
Also, if you run this query directly in the database, what is returned?
SELECT *
FROM `reviews`
WHERE `review_id` < (insert the id here)
ORDER BY `review_id` DESC
LIMIT 0, 10

Categories