search1.htmlとsearch1.cgi

search1.htmlとsearch1.cgi

You are currently viewing a revision titled "search1.htmlとsearch1.cgi", saved on 2025年10月23日 8:33 PM by 夏茂英
タイトル
search1.htmlとsearch1.cgi
コンテンツ
<html> <head> <title>フォトデータベースsearch1</title> </head> <body> <center> <h1><b>フォトデータベース search1</b></h1> <hr> <form action="search1.cgi"method="POST"> 検索キーワード<br> <input type="text"name="kyeword"><br> <input type="submit"value="検索"> <input type="reset"value="リセット"> </form> </center> </body> </html>   #!/usr/bin/perl BEGIN{ $| = 1; print "Content-type: text/html\n\n"; open(STDERR, ">&STDOUT"); } use CGI; $query = new CGI; $kensaku = $query->param('kyeword'); #dataフォルダーのテキストデータ読み込み######################## open(IN,"<save.txt"); @data=<IN>; close(IN); ########################################################### print<<END; <html> <head> <title>フォトデータベース search1</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <div align="center"> <h1><b>フォトデータベース search</b></h1> </div> <hr> END #配列@dataの中身を########################################### for($i=0;$i<@data;$i++){ @retudata=split(/\t/,$data[$i]); if($data[$i]=~m/$kensaku/){ #ここが検索したい言葉と@dataの中にある言葉が合致下場合 #その一列@retudataを単語単位でくぎりprint書き出し print"年月日:@retudata[0]<br>\n"; print"名前:@retudata[1]<br>\n"; print"category:@retudata[2]<br>\n"; print"画像:<a href=\"images/@retudata[3]\"target=\"blank\"> <img src =\"images/@retudata[3]\"width=\"150px\"height=\"auto\"></a><br>\n"; print"<hr>\n"; } } print"</body>\n"; print"</html>\n";  
抜粋
脚注


Old New Date Created Author Actions
2025年10月23日 11:33 AM 夏茂英

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です