php Doubt

January 28th, 2020

Hi is this correct?
<?
$link=mysql_connect("localhost","root","1234") or die("�s�u����");
mysql_select_db("festival");
mysql_query("SET NAMES BIG5");
mysql_query("SET CHARACTER_SET BIG5");
?>
<form id="form1" name="form1">
<?php
$sql=mysql_query("SELECT * FROM a01 order by id asc");
$nt=mysql_num_rows($sql);
if ($nt == "0")
echo "�d���������F��";
else
//echo "�@��".$nt."���ﶵ";
echo "<select name=select onchange=\"mclick(this.form)\">";
echo "<option value='' selected>�п��ܥH�U�ﶵ</option>";
while($row=mysql_fetch_array($sql))
{
echo "<option value=$row[0]>$row[1]</option>";
}
mysql_free_result($sql);
echo "</select></form>";
echo "<script>";
echo "function mclick(theform)   {
   var a=theform.select.options[theform.select.selectedIndex].value;
   switch (a){";
   for ($i=1; $i<=$nt; $i++)   {
echo "case \"$i\":
   window.open(\"festival.php?id=$i\");
   break;";
   }
echo "}}";
echo "</script>";
?>

Answer #1
It looks pretty much OK. Notice that you haven’t closed your connection to the MySQL server. This may be intentional but if you want to keep a constant connection with the server using the mysql_pconnect function might have been better. Good luck mate ^_^
Answer #2
Thanks

 

| Sitemap |