cyborg911
05-09-2011, 07:29 AM
This is a script that dynamically generates radio buttons using ajax. while its working fine, at the end where i put the submit button its not working!!
the button is supposed to lead to a page called "hello.php".
<?php
$q=$_GET["q"];
$con = mysql_connect("localhost", "username", "passwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$sql="SELECT * FROM timing WHERE name = '".$q."'";
$result = mysql_query($sql);
$name=array("Titanic" => "A Romantic Love Story",
"Lord of the Rings" => "Action Adventure",
"Schindlers List" => "A man saves many",
"300" => "300 against a million!");
foreach($name as $keyname => $value)
{
if($q==$keyname)
{
echo $value;
}
}
/**if ($q== "Titanic")
{
echo $name['Titanic'];
}
else if ($q== "Lord of the Rings")
{
echo $name["LOTR"];
}
else if ($q=="Schindlers List")
{
echo $name["SL"];
}
else if ($q=="300")
{
echo $name["300"];
}
**/
echo "<table border='1'>
<tr>
<th>Movie Name</th>
<th>Morning</th>
<th>Afternoon</th>
<th>Evening</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['time']. "</td>";
echo "<td>" . $row['time1']. "</td>";
echo "<td>" . $row['time2']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td> Select Option </td>";
if($row['time']!='')
{
echo "<td>";
echo "<input type = 'radio' Name = 'r1' value='r1' id='rad1' onclick='zing()'>";
echo "</td>";
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
if($row['time1']!='')
{
echo "<td>";
echo "<input type = 'radio' Name = 'r1' value='r2' id='rad2' >";
echo "</td>";
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
if($row['time2']!='')
{
echo "<td>";
echo "<input type = 'radio' Name = 'r1' value='r3' id='rad3' >";
echo "</td>";
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
}
mysql_close($con);
?>
<input type="submit" value="Submit" onclick="hello.php"/>; //** NOT WORKING SUBMIT BUTTON
the button is supposed to lead to a page called "hello.php".
<?php
$q=$_GET["q"];
$con = mysql_connect("localhost", "username", "passwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$sql="SELECT * FROM timing WHERE name = '".$q."'";
$result = mysql_query($sql);
$name=array("Titanic" => "A Romantic Love Story",
"Lord of the Rings" => "Action Adventure",
"Schindlers List" => "A man saves many",
"300" => "300 against a million!");
foreach($name as $keyname => $value)
{
if($q==$keyname)
{
echo $value;
}
}
/**if ($q== "Titanic")
{
echo $name['Titanic'];
}
else if ($q== "Lord of the Rings")
{
echo $name["LOTR"];
}
else if ($q=="Schindlers List")
{
echo $name["SL"];
}
else if ($q=="300")
{
echo $name["300"];
}
**/
echo "<table border='1'>
<tr>
<th>Movie Name</th>
<th>Morning</th>
<th>Afternoon</th>
<th>Evening</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['time']. "</td>";
echo "<td>" . $row['time1']. "</td>";
echo "<td>" . $row['time2']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td> Select Option </td>";
if($row['time']!='')
{
echo "<td>";
echo "<input type = 'radio' Name = 'r1' value='r1' id='rad1' onclick='zing()'>";
echo "</td>";
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
if($row['time1']!='')
{
echo "<td>";
echo "<input type = 'radio' Name = 'r1' value='r2' id='rad2' >";
echo "</td>";
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
if($row['time2']!='')
{
echo "<td>";
echo "<input type = 'radio' Name = 'r1' value='r3' id='rad3' >";
echo "</td>";
}
else
{
echo "<td>";
echo "";
echo "</td>";
}
}
mysql_close($con);
?>
<input type="submit" value="Submit" onclick="hello.php"/>; //** NOT WORKING SUBMIT BUTTON