小编dra*_*ndy的帖子

PHP/Mysql array_pop缺少第一个值

基本上会发生这样的事情:

一个人去特定的画廊,比如GalleryID = 42.我执行查询以获取该库中的所有图像(GalleryID = 42的值),并执行单独的查询以获取与该库关联的所有注释(例如GalleryID = 42).在400张总图像中,3张不同图片可能只有4条评论.

当我用do/while循环遍历图像并显示它们时,我搜索每个图片在循环时放置的注释数组.如果找到与特定图片匹配的图片ID,则会显示评论值(Comment,CommentAuthor和CommentDate).

这是图像的查询:

SELECT * FROM GalleryData WHERE GalleryID = 42
Run Code Online (Sandbox Code Playgroud)

以及对评论的查询:

SELECT Comment, CommentAuthor, CommentDate, ID FROM Comments WHERE CategoryID=42
Run Code Online (Sandbox Code Playgroud)

然后我使用此代码将注释放在可重用的查询中:

while(($Comments[] = mysql_fetch_assoc($rsComments)) || array_pop($Comments));
Run Code Online (Sandbox Code Playgroud)

然后我用它来遍历数组以找到与特定图片相关的注释

foreach($Comments as $comment) 
{
  if($comment['ID'] == $row_rsGalleries['ID']) 
  {
    echo '<p>'.$comment['Comment'].' - '.$comment['CommentAuthor'].'</p>';
  }
}
Run Code Online (Sandbox Code Playgroud)

问题是,此代码似乎不包含查询中的第一个注释.

现在,这是我做过这样的第一个项目之一,我不是一个php/mysql专家,一个新手用户.

当我运行查询时,它会得到4个结果,但是数组只包含3个,第一个结果丢失了.

php mysql arrays

0
推荐指数
1
解决办法
903
查看次数

延迟显示页面,直到加载所有内容

我有一个页面有很多进展,当它完成加载它看起来很好,但我想它加载所有的图像等,然后显示页面?可能是另一种方式.

http://www.randykrohn.com/gallery/pictures.php?EventID=279

这是页面的代码

<!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"><!-- InstanceBegin template="/Templates/Primary.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Dragboats.com - Photo Gallery -</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../includes/CSSMenuWriter/cssmw/menu.js"></script>
<link href="../includes/CSSMenuWriter/cssmw/menu.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="/includes/CSSMenuWriter/cssmw/menu_ie.css" />
<![endif]-->
<style type="text/css" media="all">
<!--
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6 {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0; …
Run Code Online (Sandbox Code Playgroud)

html php jquery image

-6
推荐指数
1
解决办法
3721
查看次数

标签 统计

php ×2

arrays ×1

html ×1

image ×1

jquery ×1

mysql ×1