• ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:変数の疑問)

変数の疑問

Tacosanの回答

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.1

ドキュメントを読む気はありませんか?

flash0
質問者

お礼

よんでみます

関連するQ&A

  • mysqliについて

    PHP初心者です PHP 5.2.5 MySQL 5.1.22 レンタルサーバーのphpのバージョンが php5.2.5ではpdoがバグで使えないらしいのでmysqliを使おうとしています。PHP 5.2.5でもmysqliはバグありますか? mysqliでMYSQLに接続するにはどうすればいいのでしょうか? いままではこんな感じでしたがmysqliにするとどんなコードになるのでしょうか? $link=mysql_connect('localhost', 'user', 'pass')or die(mysql_error()); mysql_select_db(user'); mysql_query('SET NAMES UTF8'); $start=1; $hyouji=10; $recordSet = mysql_query(sprintf('SELECT * FROM hoge2 ORDER BY id LIMIT %d, %d' , ',$start,$hyouji)); <?php while ($table = mysql_fetch_assoc($recordSet)) { ?> <tr> <td><?php print($table['id']); ?></td> <td><?php print($table['name']); ?></td> </tr> <?php } ?>

    • ベストアンサー
    • PHP
  • 検索機能

    プログラム初心者です 検索機能をつける方法を教えてください 質問1 like検索のLIKE “%value%”でもインデックスを使う方法はありますか?それともインデックスを使わなくても十分速いのでしょうか? 質問2 複数キーワードをスペースをはさんで検索してきた場合、どうやって処理すればいいのでしょうか? and検索のみです 例えばこんな文字の場合です $search = 'ああ いい うう'; $recordSet2 = mysqli_query($link,sprintf('SELECT * FROM table where name LIKE "%%%s%%"', $search )); while($row = mysqli_fetch_assoc($recordSet2)){ ?> <tr> <td><?php print $row['name']; ?></td> </tr> <?php } ?> よろしくお願いします

    • ベストアンサー
    • PHP
  • tableにまとめて関数

    いつもお世話になっております。 今回はtableについてお聞きしたいです。 現在tableの各セルに同じ関数を適用するために以下のようにしています。 <table> <TR> <TD onclick="hoge();"></TD> <TD onclick="hoge();"></TD> ... <TD onclick="hoge();"></TD> </TR> </table> これを一つのtableすべてのTDについて行っているのですがファイルサイズを削りたいということになったので何とかまとめたいと思ったのですがうまい方法がわかりませんでした。 もし方法があるのでしたらご教授をお願いします。

  • テーブルの情報が一部しか表示されません。(php)

    すべてのID分の提出状況を表示させたい("○"か"×")のですが、 id=1の提出状況しか表示されません。 >>CODE $recordSet2 = mysql_query('SELECT * FROM report'); <<CODE をwhileにいれてみたり試行錯誤してみたのですが、上手くいきません。 ご指摘よろしくお願い致します。 プログラム >>CODE <table width="70%"> <tr> <th scope="col"><bl>ID</bl></th> <th scope="col"><bl>教科名</bl></th> <th scope="col"><bl>課題名</bl></th> <th scope="col"><bl>担当教員</bl></th> <th scope="col"><bl>提出期限</bl></th> <th scope="col"><bl>再提出</bl></th> <th scope="col"><bl>再提出期限</bl></th> <th scope="col"><bl>提出状況</bl></th> </tr> <?php $recordSet = mysql_query('SELECT * FROM exercise ORDER BY id'); while ($table = mysql_fetch_assoc($recordSet)){ ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['lessonname'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['teacher'])); ?></td> <td><?php print(htmlspecialchars($table['presentday'])); ?></td> <td><?php print(htmlspecialchars($table['represent'])); ?></td> <td><?php print(htmlspecialchars($table['representday'])); ?></td> <td><?php $recordSet2 = mysql_query('SELECT * FROM report'); $report = mysql_fetch_assoc($recordSet2); if ($table['lessonname'] == $report['lessonname'] && $table['name'] == $report['exercisename']) { if(eregi($member['name'], $report['upfile'])) { echo "○"; }else { echo "×"; } } ?></td> </tr> <?php } ?> </table> <<CODE

    • ベストアンサー
    • PHP
  • テーブルの情報が一部しか表示されません。(php)

    すべてのID分の提出状況を表示させたい("○"か"×")のですが、 id=1の提出状況しか表示されません。 テストデータはid=5までの5件を入力しています。 $recordSet2 = mysql_query('SELECT * FROM report'); をwhileにいれてみたり試行錯誤してみたのですが、上手くいきません。 ご指摘よろしくお願い致します。 プログラム <table width="70%"> <tr> <th scope="col"><bl>ID</bl></th> <th scope="col"><bl>教科名</bl></th> <th scope="col"><bl>課題名</bl></th> <th scope="col"><bl>担当教員</bl></th> <th scope="col"><bl>提出期限</bl></th> <th scope="col"><bl>再提出</bl></th> <th scope="col"><bl>再提出期限</bl></th> <th scope="col"><bl>提出状況</bl></th> </tr> <?php $recordSet = mysql_query('SELECT * FROM exercise ORDER BY id'); while ($table = mysql_fetch_assoc($recordSet)){ ?> <tr> <td><?php print(htmlspecialchars($table['id'])); ?></td> <td><?php print(htmlspecialchars($table['lessonname'])); ?></td> <td><?php print(htmlspecialchars($table['name'])); ?></td> <td><?php print(htmlspecialchars($table['teacher'])); ?></td> <td><?php print(htmlspecialchars($table['presentday'])); ?></td> <td><?php print(htmlspecialchars($table['represent'])); ?></td> <td><?php print(htmlspecialchars($table['representday'])); ?></td> <td><?php $recordSet2 = mysql_query('SELECT * FROM report'); $report = mysql_fetch_assoc($recordSet2); if ($table['lessonname'] == $report['lessonname'] && $table['name'] == $report['exercisename']) { if(eregi($member['name'], $report['upfile'])) { echo "○"; }else { echo "×"; } } ?></td> </tr> <?php } ?> </table>

    • ベストアンサー
    • PHP
  • 検索したときなにも無かった場合

    プログラム初心者です sqlをselectして結果がなかった場合、mysqli_fetch_assocを使うより先に判定する場合はどうすればいいのでしょうか? if(ここがわかりません){ echo '検索結果がありません'; } while($row = mysqli_fetch_assoc($recordSet)){ print $row['id']; } よろしくお願いします

    • ベストアンサー
    • PHP
  • 変数と文字を組み合わせて、表示させるには?

    変数と文字を組み合わせて、表示させたいのですが、 何か良い方法はありませんか? エラーになり、表示できませんでした。 a = 1;の場合 普通は、 ID.innerHTML = '  サンプル'+a; とすると、「サンプル1」と表示されます。 ここは表示できました。 実際は、このように、 ID.innerHTML ='<TABLE width="150" bgcolor="#ffcccc">  <TR><TD>サンプルです</TD></TR><TABLE>';            ↑        ここに変数a の値を入れたかったのですが…  TABLEタグを入れて、色つきで表示したかったのですが、 文字と変数の組み合わせで、エラーになり、うまくいきませんでした。 何かよい方法はないですか? 教えて下さい。

  • テーブルの変数について

    var i; i=10; <table> <tr> <th>見出し</th> <th>見出し</th> </tr> <tr> <td>i<td> <td>data</td> </tr> </table> このようなプログラムを作ったのですが変数の「i」がそのまま表示されてしまうのでどうしたら「i」の中の数字を表示することができるのしょうか。

  • テーブルの変数について

    var i; i=10; <table> <tr> <th>見出し</th> <th>見出し</th> </tr> <tr> <td>i<td> <td>data</td> </tr> </table> このようなプログラムを作ったのですが変数の「i」がそのまま表示されてしまうのでどうしたら「i」の中の数字を表示することができるのしょうか。初心者なのでまだまだわからないことがたくさんありますがよろしくお願いします。

  • データが表示されません

    php4とMySQLを使用しています。 select文でデータを取得したあと while($Row2 = mysql_fetch_array($result2, MYSQL_ASSOC)){ $name = $Row2['name']; $contents = $Row2['contents']; ?> <table> <tr> <td><?=$name?></td> </tr> <tr> <td><?=$contents?></td> </tr> </table> <? } ?>で表示しようとしていますが、10件中の10件目しか表示されません。 上書きされているようです。どこがおかしいでしょうか? 教えてください。お願いいたします。

    • ベストアンサー
    • PHP