gpt4 book ai didi

php - 我的 php/mysql 不像今天早上那样工作。初级/中级帮助

转载 作者:行者123 更新时间:2023-11-29 06:17:41 26 4
gpt4 key购买 nike

我对代码进行了一些修改,但现在它无法正常运行。我的 img src="https://s3.amazonaws.com/thumbnail/1.pngimg src="https://s3.amazonaws.com/thumbnail/2.png 没有显示(两者都在下面的代码中突出显示)。

我的分页链接“上一页”和“下一页”也没有显示。两者也都突出显示。

无论如何,这基本上是我的 mysql:

CREATE TABLE `images` (
`thumbnailID` int(11) NOT NULL auto_increment,
`link` varchar(100) NOT NULL,
`pic` varchar(100) NOT NULL,
`alt` varchar(100) NOT NULL,
`time` varchar(100) NOT NULL,
PRIMARY KEY (`thumbnailID`)
) ENGINE=MyISAM ;

这是我的 php 代码:

<?php
$objConnect = mysql_connect("sadadsaf","w3f","scdsf")
or die(mysql_error());
$objDB = mysql_select_db("sdfv");
$pic2 = "SELECT * FROM images";

if (!isset($_GET['Page']))
$_GET['Page']='0';

$pic1 = mysql_query($pic2);
$Num_Rows = mysql_num_rows($pic1);
$Per_Page = 16; // Per Page
$Page = $_GET["Page"];

if(!$_GET["Page"]) {
$Page=1;
}

$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);

if($Num_Rows<=$Per_Page) {
$Num_Pages =1;
} else if(($Num_Rows % $Per_Page)==0) {
$Num_Pages =($Num_Rows/$Per_Page) ;
} else {
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}

$pic2 .=" order by thumbnailID ASC LIMIT $Page_Start , $Per_Page";
$pic1 = mysql_query($pic2);
$cell = 0;
$link1 = "SELECT * FROM images";
$link = mysql_fetch_array(mysql_query($link1));**
$alt1 = "SELECT * FROM images";
$alt = mysql_fetch_array(mysql_query($alt1));
$time1 = "SELECT * FROM images";
$time = mysql_fetch_array(mysql_query($time1));
echo '
<div id="tablediv">
<table border="0" cellpadding="17" cellspacing="0" class="table">
<tr>';

while($pic = mysql_fetch_array($pic1)) {

if($cell % 4 == 0) {
echo '</tr><tr>';
}

if($cell == 2) {
echo '
<td>
<div class="customimage">
<a href="/misc/deadend.php">
<img src="https://s3.amazonaws.com/thumbnail/1.png" />
</a>
</div>
</td>'; // This line includes one of the <img> tags having issues
} elseif ($cell == 3) {
echo '
<td>
<div class="customimage">
<a href="/misc/deadend.php">
<img src="https://s3.amazonaws.com/thumbnail/2.png" />
</a>
</div>
</td>'; // This line includes one of the <img> tags having issues
} else {
echo '
<td>
<a href="/' . $link["link"] . '.php">
<div class="image">
<img src="https://s3.amazonaws.com/imagetitle/' . $pic["pic"] . '"
alt="' . $alt["alt"] . '"
height="190"
width="190"
/>
</div>
</a>
<div class="submitted">submitted&nbsp;</div>
<div class="timeago">
<abbr class="timeago" title="' . $time["time"] .'"></abbr>
</div>
</td>';
}
$cell++;
}
echo '</tr></table></div>';
?>

<br />
view more:

<?php
if($Prev_Page) {
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>**prev**</a> |";
}

if($Page!=$Num_Pages) {
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>**next**</a> ";
}
?>

<?php
mysql_close($objConnect);
?>

谢谢!

编辑:没关系,它们没有突出显示。不过,它们周围应该有星号。

最佳答案

更改该行,以便您可以获得有关正在发生的情况的更多信息:

$link1 = "SELECT * FROM images";
$result_link1 = mysql_query($link1);

if(!$result_link1) {
echo mysql_error();
die();
}

// just for testing
echo mysql_num_rows($result_link1) . '<br/>';
$link = mysql_fetch_array($result_link1);

这将帮助您缩小问题范围。

关于php - 我的 php/mysql 不像今天早上那样工作。初级/中级帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5520357/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com