0

現在、データベースから2つの異なるアイテムを取得する必要があるデータベースへの単純なクエリがあります。データベースを見つけて取得していることは知っていますが、1 つのレコードしか取得していないようです。

私の質問は次のとおりです。以下のコードがデータベースから 1 つ以上のレコードを取得しないのはなぜですか?

<?php

include('config.php');

$sql = "SELECT * FROM sponsoredBackground ORDER BY id DESC LIMIT 3";
$retval = mysql_query( $sql, $con ); 
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}

echo "<div id=\"headerSlider\">";

while($row = mysql_fetch_array($retval))
{

?>
<div class="headerContainer" style="background: transparent url('/images/<?php echo $row['imageName']; ?>') 0 0 no-repeat;">
        <div class="headerLeftContent">
            <div class="sponsoredBackground">
                <a href="http://<?php echo $row['url']; ?>">        
                    View this Opportunity
                </a>
            </div>
            <p style="font-size:18px; color:white;">Search by Location:</p>
                <select id="location" name="location" class="selectDropDown">
                    <option>Select Location...</option>
                    <option value="AcrossScotland">Across Scotland</option>
                    <option value="Aberdeen">Aberdeen</option>
                    <option value="Aberdeenshire">Aberdeenshire</option>
                    <option value="Angus">Angus</option>
                    <option value="Argyll/Bute">Argyll And Bute</option>
                    <option value="Clackmannanshire">Clackmannanshire</option>
                    <option value="Dumfries/Galloway">Dumfries And Galloway</option>
                    <option value="Dundee">Dundee</option>
                    <option value="EastAyrshire">East Ayrshire</option>
                    <option value="EastDunbartonshire">East Dunbartonshire</option>
                    <option value="EastLothian">East Lothian</option>
                    <option value="EastRenfrewshire">East Renfrewshire</option>
                    <option value="Edinburgh">Edinburgh</option>
                    <option value="EileanSiar">Eilean Siar</option>
                    <option value="Falkirk">Falkirk</option>
                    <option value="Fife">Fife</option>
                    <option value="Glasgow">Glasgow</option>
                    <option value="Highlands">Highlands</option>
                    <option value="Inverclyde">Inverclyde</option>
                    <option value="Midlothian">Midlothian</option>
                    <option value="Moray">Moray</option>
                    <option value="NorthAyrshire">North Ayrshire</option>
                    <option value="NorthLanarkshire">North Lanarkshire</option>
                    <option value="Orkney">Orkney</option>
                    <option value="Perth/Kinross">Perth And Kinross</option>
                    <option value="Renfrewshire">Renfrewshire</option>
                    <option value="ScottishBorders">Scottish Borders</option>
                    <option value="ShetlandIslands">Shetland Islands</option>
                    <option value="SouthAyrshire">South Ayrshire</option>
                    <option value="SouthLanarkshire">South Lanarkshire</option>
                    <option value="Stirling">Stirling</option>
                    <option value="WestDunbartonshire">West Dunbartonshire</option>
                    <option value="WestLothian">West Lothian</option>
            </select>
            <p style="font-size:18px; color:white;">Search by Category:</p>
            <select id="category" name="category" class="selectDropDown">
                    <option>Select Category...</option>
                    <option value="AllCategories">All Categories</option>
                    <option value="Financial">Financial</option>
                    <option value="Administration">Business And Administration</option>
                    <option value="Care">Care</option>
                    <option value="Construction">Construction</option>
                    <option value="Creative">Creative</option>
                    <option value="Energy">Energy</option>
                    <option value="Engineering">Engineering</option>
                    <option value="Food/Drink">Food And Drink</option>
                    <option value="Hair/Beauty">Hair And Beauty</option>
                    <option value="Hospitality">Hospitality</option>
                    <option value="IT">IT</option>
                    <option value="Landbased">Landbased</option>
                    <option value="Mechanics/Transport">Motor And Transport</option>
                    <option value="Retail">Retail</option>
                    <option value="Scientific">Scientific</option>
                    <option value="Sport/Leisure">Sport And Leisure</option>
            </select>
            <p style="font-size:18px; color:white;">Search by Type:</p>
            <select id="type" class="selectDropDown">
                    <option>Select Type...</option>
                    <option value="AllTypes">All Types</option>
                    <option value="Apprenticeships">Apprenticeships</option>
                    <option value="Enterprise">Enterprise</option>
                    <option value="College">College</option>
                    <option value="University">University</option>
                    <option value="WorkExperience">Work Experience</option>
                    <option value="Voluntary">Voluntary</option>
                    <option value="Graduate">Graduate</option>
            </select>
        </div>  
        <div class="headerCenterContent">   
        </div>
        <div class="headerRightContent">
            <?php include('featuredEvents.php'); ?>
        </div>      
 </div>

<?php    
} 

echo "</div>";
echo "</div>";

echo "</body>";
echo "</html>";

?>

前もって感謝します。

4

1 に答える 1

0

featuredEvents.phpページに含めると、いくつかのSQL処理が行われるだけでなく、変数が含まれていないことを再確認するだけである可能性があります$retval

于 2013-05-13T09:49:17.950 に答える