jsvb1977
asked on
php mysql results displaying one less record than in database
I am working on a cms app, where i give the end user the ability to create posts and then assign galleries to their posts.
In the page where they are uploading the images, the images are displayed using a select query, and at the same time the post related to the gallery is displayed and is non-editable [i take care of being able to edit the post in a separate process.]
Here is the problem, if the end user uploads 1 image, no images are displayed. If they upload a second image the first image is displayed, and so.
what could be the problem?
Check the code below -- it is the entire page which contains the select queries for displaying the article post, the images, and the form which calls "uploader.php" [the script that uploads and writes the image data into the db].
thank you in advance for any help.
Jason
In the page where they are uploading the images, the images are displayed using a select query, and at the same time the post related to the gallery is displayed and is non-editable [i take care of being able to edit the post in a separate process.]
Here is the problem, if the end user uploads 1 image, no images are displayed. If they upload a second image the first image is displayed, and so.
what could be the problem?
Check the code below -- it is the entire page which contains the select queries for displaying the article post, the images, and the form which calls "uploader.php" [the script that uploads and writes the image data into the db].
thank you in advance for any help.
Jason
<?php
require_once('auth.php');
include('../includes/conn_mysql.inc.php');
include('../includes/corefuncs.php');
$conn = dbConnect('query');
$siteid = mysql_real_escape_string($_GET['pageid']);
$imgarticleid = mysql_real_escape_string($_GET['articleid']);
$articleid = mysql_real_escape_string($_GET['articleid']);
$sql = "SELECT pageid, pagename, url FROM pages ORDER BY pagename";
$result = mysql_query($sql) or die(mysql_error());
$sql3 = "SELECT pageid, pagename, url FROM pages WHERE pageid='".$siteid."' LIMIT 1";
$conn = dbConnect('admin');
$sqlimgselect = "SELECT galleryimgs.imgid, galleryimgs.articleid AS imgarticleid, galleryimgs.title, galleryimgs.img FROM galleryimgs WHERE articleid='".$imgarticleid."' "; //WHERE articleid='".$imgarticleid."'
$resultimgselect = mysql_query($sqlimgselect) or die (mysql_error());
$rowimgselect = mysql_fetch_assoc($resultimgselect);
// get details of selected record
//if ($_GET && !$_POST) {
//if (isset($_GET['articleid']) && is_numeric($_GET['articleid'])) {
//$articleid = $_GET['articleid'];
//}
// else {
// $articleid = NULL;
// }
// if ($articleid) {
//$sql = "SELECT * FROM annualdinnerpage WHERE article_id = $article_id"; //create join with annualdinnergalleryimgs
//$sqlselect = "SELECT articles.*, galleryimgs.articleid AS imgarticleid, galleryimgs.img, galleryimgs.title AS imgtitle
//FROM articles LEFT JOIN galleryimgs ON articles.articleid = galleryimgs.articleid
//WHERE galleryimgs.articleid='".$imgarticleid."' AND articles.articleid='".$imgarticleid."' ";
//ORDER BY imgarticleid "; //create join with galleryimgs
$sqlarticle = "SELECT articles.* FROM articles WHERE articleid='".$articleid."' ";
$resultarticle = mysql_query($sqlarticle) or die (mysql_error());
$rowarticle = mysql_fetch_assoc($resultarticle);
// }
// }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CMS Gallery</title>
<link href="journal.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="../images/bsoc_icon.ico" />
<?php // include('xinha.inc.php'); ?>
</head>
<body>
<div id="navigation">
<?php
$result3 = mysql_query($sql3) or die(mysql_error());
if($row=mysql_fetch_assoc($result3)){
echo "<h1>".$row['pagename']." Gallery</h1>";
}
?>
<?php include('includes/topnav.inc.php'); ?>
</div>
<div id="contentwrapper">
<div id="content">
<div id="contentleft">
<?php include('includes/menunav.inc.php'); ?>
</div>
<div id="contentright">
<?php echo $rowarticle['article'] ?>
<br />
<form id="form1" name="form1" method="post" action="uploader.php?articleid=<?php echo $articleid; ?>&pageid=<?php echo $siteid; ?>" enctype="multipart/form-data">
<table>
<tr>
<td>Title</td>
<td>Path</td>
<td>Upload</td>
</tr>
<tr>
<!--<input type="hidden" name="MAX_FILE_SIZE" value="100000" />-->
<input type="hidden" name="articleid" id="articleid" value="<?php echo $rowarticle['articleid']; ?>" />
<td><input type="text" name="title" id="title" /></td>
<td><input type="file" name="uploadedfile" id="uploadedfile" /></td>
<td><input type="submit" name="insert" value="Upload File" /></td>
</tr>
</table>
</form>
<br />
<?php
while($rowimgselect = mysql_fetch_assoc($resultimgselect)) {
?>
<img src="uploads/thumbs/<?php echo $rowimgselect['img']; ?>" alt="<?php echo $rowimgselect['title']; ?>" title="<?php echo $rowimgselect['title']; ?>" />
<?php } ?>
<div class="push"></div>
</div>
<hr class="cleaner" />
</div>
</div>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I went with solution number two -- thank you for the explanation as well. Much appreciated.
Jason
Jason
ASKER
I went with solution number two -- thank you for the explanation as well. Much appreciated.
ASKER
Jason