0

より具体的には、私は受け取っています:

*注意: C:\xampp\htdocs\Project1_Tables\index.php の 38 行目の配列から文字列への変換 注意: 39 行目の C:\xampp\htdocs\Project1_Tables\index.php の配列から文字列への変換*

これがコードです

<?php

    //SETUP FOR CONNECTION
    $host = "localhost";
    $user = "root";
    $password = "password";
    $database = "test";

    $con = mysqli_connect($host, $user, $password, $database);

    $tableName = "funding";
    $sql = "";

    //QUERIES NEEDED TO GATHER DATA FOR DROP-DOWN MENU'S (Research Theme and Institution)
    $column = "research_theme";
    $query = sprintf("SELECT DISTINCT %s FROM ", $column);
    $sql = $query.$tableName;
    $ddThemeList = mysqli_query($con, $sql);

    $column = "institution";
    $query = sprintf("SELECT DISTINCT %s FROM ", $column);
    $sql = $query.$tableName;
    $ddInstitutionList = mysqli_query($con, $sql);

    $list1 = mysqli_fetch_array($ddThemeList, MYSQLI_NUM);
    $list2 = mysqli_fetch_array($ddInstitutionList, MYSQLI_NUM);
    require_once("support.php");

    $body="";

    $scriptName = $_SERVER["PHP_SELF"];
    $topPart =  <<<EOBODY
            <form action="$scriptName" method="post">
                <p>
                    Theme
                    <select name="theme">
                        <?php if(mysqli_num_rows($list1) != 0) { ?>
                            <?php while ($list1) { ?>
                                <option value="<?php echo $list1[0]; ?>">
                                    <?php echo $list1[0]; ?>
                                </option>
                            <?php } ?>
                        <?php } ?>
                    </select>
                </p>

            </form>
EOBODY;

    $body = $topPart.$body;

    $page = generatePage($body);
    echo $page;

?>
4

3 に答える 3

0

あなたの問題は から来ました。 の代わりにarray (list1)inを使用します。mysqli_num_rowsmysqli_result

39 行目では、string/int/bool の代わりにarray、条件文としてan を使用しています。while

<?php

/*
** SOME CODE
**
*/

$list1 = mysqli_fetch_array($ddThemeList, MYSQLI_NUM);

/*
** MORE CODE
**
*/

                    <select name="theme">
                        <?php if(mysqli_num_rows($ddThemeList) != 0) { ?>
                            <?php for($i = 0;$list1[$i]; $i++) { ?>
                                <option value="<?php echo $list1[$i]; ?>">
                                    <?php echo $list1[$i]; ?>
                                </option>
                            <?php } ?>
                        <?php } ?>
                    </select>

/*
** MORE CODE
*/

?>
于 2013-07-18T14:00:09.890 に答える
0

この行は何もしません:

<?php while ($list1) { ?>

しばらく mysql または mysqli_ 関数を使用していませんが、次のようなものがおそらく必要なものに似ています。

  <?php

      //SETUP FOR CONNECTION
      $host = "localhost";
      $user = "root";
      $password = "password";
      $database = "test";

      $con = mysqli_connect($host, $user, $password, $database);

      $tableName = "funding";
      $sql = "";

      //QUERIES NEEDED TO GATHER DATA FOR DROP-DOWN MENU'S (Research Theme and Institution)
      $column = "research_theme";
      $query = sprintf("SELECT DISTINCT %s FROM ", $column);
      $sql = $query.$tableName;
      $ddThemeList = mysqli_query($con, $sql);

      $column = "institution";
      $query = sprintf("SELECT DISTINCT %s FROM ", $column);
      $sql = $query.$tableName;
      $ddInstitutionList = mysqli_query($con, $sql);

      $list1 = mysqli_fetch_array($ddThemeList, MYSQLI_NUM);
      $list2 = mysqli_fetch_array($ddInstitutionList, MYSQLI_NUM);
      require_once("support.php");

      $body="";

      $scriptName = $_SERVER["PHP_SELF"];
      $topPart =  <<<EOBODY
              <form action="$scriptName" method="post">
                  <p>
                      Theme
                      <select name="theme">
  EOBODY;


            foreach ($list1 as $item) {
              $topPart .= "<option value='{$item}'>{$item}</option>";
            }

        TopPart .= <<<EOBODY
                      </select>
                  </p>

              </form>
  EOBODY;

      $body = $topPart.$body;

      $page = generatePage($body);
      echo $page;
于 2013-07-18T14:05:30.680 に答える