By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,612 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Radio buttons not showing values from database

P: 37
Hi All
I'm a noob and wanted to show records from my db with one field using radio buttons. Problem is that I can't get the values from the table to check the appropriate radio button.

Any help MUCH appreciated

Cheers :)
[php]
$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";

while($show = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." 'IsSponsored'\" value=\"1\" ".$sponsored.">";

echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." 'IsSponsored'\" value=\"0\" ".$notsponsored.">";


echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}[/php]

Use the appropriate code tags around your code - moderator
Feb 26 '08 #1
Share this Question
Share on Google+
62 Replies


hsriat
Expert 100+
P: 1,654
What is IsSponsored?
Feb 26 '08 #2

P: 37
What is IsSponsored?
IsSponsored is a field in table

Has value of "1" or "0"
Feb 26 '08 #3

hsriat
Expert 100+
P: 1,654
[php]$sponsored = array("";"checked");
$not_sponsored = array("checked";"");
while($show = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored ']]."></input>Is sponsored";

echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored ']]."></input>Is not sponsored";

echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}[/php]

Check this... is this what you wanted or not?
Feb 26 '08 #4

P: 37
[php]$sponsored = array("";"checked");
$not_sponsored = array("checked";"");
while($show = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored ']]."></input>Is sponsored";

echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored ']]."></input>Is not sponsored";

echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}[/php]

Check this... is this what you wanted or not?
Sorry but tried this and page wouldn't run.
Feb 26 '08 #5

hsriat
Expert 100+
P: 1,654
Sorry but tried this and page wouldn't run.
isSponsored is a field in database, right?

And is there any error?
Feb 26 '08 #6

P: 37
isSponsored is a field in database, right?

And is there any error?
"IsSponsored" is a field in the database

This page is returning a query from another page. When this page tries to display the results the browser comes back with the generic "The page cannot be displayed" message. Here is all the code from the page.

many thanks


/////////////////////////////////////////////////////////////////////////////////////////////////////

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>

<?php
$link ="<br><br><a href='searchpage.php'>Click here to go back to the search page.</a>";

$countryName = $_POST['countryName'];
$gender = $_POST['gender'];
$ChildID = $_POST['ChildID'];


//Just checking that values are being submitted properly
echo $countryName;
echo"<br>";
echo $gender;
echo"<br>";
echo $ChildID;
echo"<br>";

$db = mysql_connect('localhost', 'xxxx', 'xxxxx');
mysql_select_db("child",$db);

if ($ChildID != "")
{$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender') and

(ChildID ='$ChildID')";
}else{
$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender')";
}


$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "sorry, no matching results.";
echo $link;
exit;
}


echo "<table border='1' >";
echo "<tr><th>ChildID</th>
<th>givenName</th>
<th>gender</th>
<th>countryName</th>
<th>favouritePlay</th>
<th>Sponsored</th>
<th>Not Sponsored</th>
<th>dateOfBirth</th>
</tr>";
// keeps getting the next row until there are no more to get


$sponsored = array("";"checked");

$not_sponsored = array("checked";"");

while($show = mysql_fetch_array( $result )) {

/*Print out the contents of each row into a table*/

echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored ']]."></input>Is sponsored";
echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored ']]."></input>Is not sponsored";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}

echo "</table>";

?>

</body>
</html>
Feb 26 '08 #7

hsriat
Expert 100+
P: 1,654
The code seems to be fine, the problem may be with the file name or directory.
Feb 26 '08 #8

P: 37
The code seems to be fine, the problem may be with the file name or directory.
stupid IE
Firefox returned this error
"PHP Parse error: syntax error, unexpected ';', expecting ')' in C:\Inetpub\wwwroot\practice\childc.php on line 63"

am looking into this now
Feb 26 '08 #9

hsriat
Expert 100+
P: 1,654
stupid IE
Firefox returned this error
"PHP Parse error: syntax error, unexpected ';', expecting ')' in C:\Inetpub\wwwroot\practice\childc.php on line 63"

am looking into this now
oops...
My fault...
Array fields are separated with comma, not semicolon!
Like this...
$sponsored = array("","checked");
$not_sponsored = array("checked","");
Feb 26 '08 #10

P: 37
oops...
My fault...
Array fields are saperated by comma, not semicolon!
Like this...
$sponsored = array("","checked");
$not_sponsored = array("checked","");
sorry.......
another error

Undefined index: IsSponsored in C:\Inetpub\wwwroot\practice\childc.php on line 83

Undefined index: IsSponsored in C:\Inetpub\wwwroot\practice\childc.php on line 87
Feb 26 '08 #11

hsriat
Expert 100+
P: 1,654
sorry.......
another error

Undefined index: IsSponsored in C:\Inetpub\wwwroot\practice\childc.php on line 83

Undefined index: IsSponsored in C:\Inetpub\wwwroot\practice\childc.php on line 87
remove the space after IsSponsored (in line 83 and 87) and check its spelling against the one in the db.
Feb 26 '08 #12

Markus
Expert 5K+
P: 6,050
Use code tags
[php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>

<?php
$link ="<br><br><a href='searchpage.php'>Click here to go back to the search page.</a>";

$countryName = $_POST['countryName'];
$gender = $_POST['gender'];
$ChildID = $_POST['ChildID'];


//Just checking that values are being submitted properly
echo $countryName;
echo"<br>";
echo $gender;
echo"<br>";
echo $ChildID;
echo"<br>";

$db = mysql_connect('localhost', 'xxxx', 'xxxxx');
mysql_select_db("child",$db);

if ($ChildID != "")
{$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender') and

(ChildID ='$ChildID')";
}else{
$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender')";
}


$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "sorry, no matching results.";
echo $link;
exit;
}


echo "<table border='1' >";
echo "<tr><th>ChildID</th>
<th>givenName</th>
<th>gender</th>
<th>countryName</th>
<th>favouritePlay</th>
<th>Sponsored</th>
<th>Not Sponsored</th>
<th>dateOfBirth</th>
</tr>";
// keeps getting the next row until there are no more to get


$sponsored = array("";"checked");

$not_sponsored = array("checked";"");

while($show = mysql_fetch_array( $result )) {

/*Print out the contents of each row into a table*/

echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored ']]."></input>Is sponsored";
echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored ']]."></input>Is not sponsored";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}

echo "</table>";

?>

</body>
</html>
[/php]
Feb 26 '08 #13

P: 37
remove the space after IsSponsored (in line 83 and 87) and check its spelling against the one in the db.
removed space and works PERFECTLY in Firefox........however get this error from IE6

Undefined index: countryName in C:\Inetpub\wwwroot\practice\childc.php on line 15 PHP
Undefined index: gender in C:\Inetpub\wwwroot\practice\childc.php on line 16 PHP
Undefined index: ChildID in C:\Inetpub\wwwroot\practice\childc.php on line 17
Feb 26 '08 #14

Markus
Expert 5K+
P: 6,050
removed space and works PERFECTLY in Firefox........however get this error from IE6

Undefined index: countryName in C:\Inetpub\wwwroot\practice\childc.php on line 15 PHP
Undefined index: gender in C:\Inetpub\wwwroot\practice\childc.php on line 16 PHP
Undefined index: ChildID in C:\Inetpub\wwwroot\practice\childc.php on line 17
It wont be the browser as the errors are given from the server.

Place an @ symbol before the post:
[php]
$_something = @$_POST['something'];
[/php]
So, if the post isnt there, it won't throw an error.
Feb 26 '08 #15

P: 37
It wont be the browser as the errors are given from the server.

Place an @ symbol before the post:
[php]
$_something = @$_POST['something'];
[/php]
So, if the post isnt there, it won't throw an error.
code (php)
$countryName = @$_POST['countryName'];
$gender = @$_POST['gender'];
$ChildID = @$_POST['ChildID'];
(/php)

Tried this. Still works fine in Firefox but returns no results in IE6
Feb 26 '08 #16

hsriat
Expert 100+
P: 1,654
removed space and works PERFECTLY in Firefox........however get this error from IE6

Undefined index: countryName in C:\Inetpub\wwwroot\practice\childc.php on line 15 PHP
Undefined index: gender in C:\Inetpub\wwwroot\practice\childc.php on line 16 PHP
Undefined index: ChildID in C:\Inetpub\wwwroot\practice\childc.php on line 17
These are the names of the HTML form input fields which you used in the searchpage.php
Check out the spellings.

You may add one more thing to your code.
In the first line, add this PHP code..
[php]
<?php
//file starts
if (!isset($_POST['Submit']))
header("Location: searchpage.php");
else
{
?>
//paste whole of your code here.
<?php
}
//file ends
?>[/php]

And add name="Submit" to your submit button in searchpage.php
Feb 26 '08 #17

hsriat
Expert 100+
P: 1,654
It wont be the browser as the errors are given from the server.

Place an @ symbol before the post:
[php]
$_something = @$_POST['something'];
[/php]
So, if the post isnt there, it won't throw an error.

He's not getting the error in FF, coz, apparently, he is refreshing the page, and page is retaining the previous posted values.

And in IE, either he has opened the link straight away, or IE doesn't retain the posted values on refresh.
Feb 26 '08 #18

Markus
Expert 5K+
P: 6,050
He's not getting the error in FF, coz, apparently, he is refreshing the page, and page is retaining the previous posted values.

And in IE, either he has opened the link straight away, or IE doesn't retain the posted values on refresh.
I see.
Nice thinking.

Still, errors in php are never caused by the browser (@ op)
Feb 26 '08 #19

P: 37
These are the names of the HTML form input fields which you used in the searchpage.php
Check out the spellings.

You may add one more thing to your code.
In the first line, add this PHP code..
[php]
<?php
//file starts
if (!isset($_POST['Submit']))
header("Location: searchpage.php");
else
{
?>
//paste whole of your code here.
<?php
}
//file ends
?>[/php]

And add name="Submit" to your submit button in searchpage.php
Really Sorry about this. I tried your suggestion but god a bit mixed up:

code(php)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP tutorial</title>
</head>
<body>
<?php
//file starts
if (!isset($_POST['Submit']))
header("childc.php");
else
{
?>
<h2>Search for child</h2>
<br />
<FORM ACTION="childc.php" METHOD="POST">


Which country are seeking:
<br />
<SELECT NAME="countryName">
<option value="Bangladesh">Bangladesh
<option value="Honduras">Honduras
<option value="Mali">Mali
<option value="Malawi">Malawi
<option value="Niger">Niger
<option value="Nicaragua">Nicaragua
<option value="Tanzania">Tanzania
<option value="Uganda">Uganda
<option value="Zambia">Zambia

</select>
<br />
<SELECT NAME="gender">
<!--<option value="'LIKE %'">Male or Female-->
<option value="M">Male
<option value="F">Female

</select>
<br />


ChildID:<input type="text" size="12" maxlength="18" name="ChildID">
<br />
<br />

<INPUT TYPE="submit" VALUE="search" name="submit">
</FORM>
<?php
}
//file ends


?>
</body>
</html>
(/php)
Feb 26 '08 #20

Markus
Expert 5K+
P: 6,050
What is the problem now?
Feb 26 '08 #21

hsriat
Expert 100+
P: 1,654
Really Sorry about this. I tried your suggestion but god a bit mixed up:

code(php)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP tutorial</title>
</head>
<body>
<?php
//file starts
if (!isset($_POST['Submit']))
header("childc.php");
else
{
?>
<h2>Search for child</h2>
<br />
<FORM ACTION="childc.php" METHOD="POST">


Which country are seeking:
<br />
<SELECT NAME="countryName">
<option value="Bangladesh">Bangladesh
<option value="Honduras">Honduras
<option value="Mali">Mali
<option value="Malawi">Malawi
<option value="Niger">Niger
<option value="Nicaragua">Nicaragua
<option value="Tanzania">Tanzania
<option value="Uganda">Uganda
<option value="Zambia">Zambia

</select>
<br />
<SELECT NAME="gender">
<!--<option value="'LIKE %'">Male or Female-->
<option value="M">Male
<option value="F">Female

</select>
<br />


ChildID:<input type="text" size="12" maxlength="18" name="ChildID">
<br />
<br />

<INPUT TYPE="submit" VALUE="search" name="submit">
</FORM>
<?php
}
//file ends


?>
</body>
</html>
(/php)
Ok, that was not something for this page, that was for the childc.php
That thing would actually redirect the user to searchpage.php in case you open childc.php directly in your browser.
Feb 26 '08 #22

hsriat
Expert 100+
P: 1,654
[php]
<?php
if(!isset($_POST['Submit']))
{
header ("Location: searchpage.php");
}
else
{
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>

<?php
$link ="<br><br><a href='searchpage.php'>Click here to go back to the search page.</a>";

$countryName = $_POST['countryName'];
$gender = $_POST['gender'];
$ChildID = $_POST['ChildID'];


//Just checking that values are being submitted properly
echo $countryName;
echo"<br>";
echo $gender;
echo"<br>";
echo $ChildID;
echo"<br>";

$db = mysql_connect('localhost', 'xxxx', 'xxxxx');
mysql_select_db("child",$db);

if ($ChildID != "")
{$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender') and

(ChildID ='$ChildID')";
}else{
$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender')";
}


$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "sorry, no matching results.";
echo $link;
exit;
}


echo "<table border='1' >";
echo "<tr><th>ChildID</th>
<th>givenName</th>
<th>gender</th>
<th>countryName</th>
<th>favouritePlay</th>
<th>Sponsored</th>
<th>Not Sponsored</th>
<th>dateOfBirth</th>
</tr>";
// keeps getting the next row until there are no more to get


$sponsored = array("","checked");

$not_sponsored = array("checked","");

while($show = mysql_fetch_array( $result )) {

/*Print out the contents of each row into a table*/

echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>Is sponsored";
echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."></input>Is not sponsored";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}

echo "</table>";

?>

</body>
</html>

<?php
}
?>
[/php]

PS: Don't forget to add name="Submit" to the submit button on searchpage.php
Feb 26 '08 #23

P: 37
Ok, that was not something for this page, that was for the childc.php
That thing would actually redirect the user to searchpage.php in case you open childc.php directly in your browser.
sorry still confused. I had a go but am a bit slow :)

code(php)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>
<?php
//file starts
if (!isset($_POST['Submit']))
header("childa.php");
else
{
?>
<?php
$link ="<br><br><a href='childa.php'>Click here to go back to the search page.</a>";
$countryName = @$_POST['countryName'];
$gender = @$_POST['gender'];
$ChildID = @$_POST['ChildID'];


//Just checking that values are being submitted properly
echo $countryName;
echo"<br>";
echo $gender;
echo"<br>";
echo $ChildID;
echo"<br>";

$db = mysql_connect('localhost', 'xxxx', 'xxxxx');
mysql_select_db("child",$db);

if ($ChildID != "")
{$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender') and

(ChildID ='$ChildID')";
}else{
$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender')";
}


$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "sorry, no matching results.";
echo $link;
exit;
}


echo "<table border='1' >";
echo "<tr><th>ChildID</th>
<th>givenName</th>
<th>gender</th>
<th>countryName</th>
<th>favouritePlay</th>
<th>Sponsored</th>
<th>Not Sponsored</th>
<th>dateOfBirth</th>
</tr>";
// keeps getting the next row until there are no more to get

$sponsored = array("","checked");
$not_sponsored = array("checked","");


while($show = mysql_fetch_array( $result )) {

/*Print out the contents of each row into a table*/

echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>";
echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."></input>";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}

echo "</table>";

?>

<?php
}
//file ends
?>




</body>
</html>
(/php)
Feb 26 '08 #24

hsriat
Expert 100+
P: 1,654
And while posting your code, don't forget to use [php] and [/php] tags in the starting and the end respectively.
Feb 26 '08 #25

P: 37
[php]
<?php
if(!isset($_POST['Submit']))
{
header ("Location: searchpage.php");
}
else
{
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>

<?php
$link ="<br><br><a href='searchpage.php'>Click here to go back to the search page.</a>";

$countryName = $_POST['countryName'];
$gender = $_POST['gender'];
$ChildID = $_POST['ChildID'];


//Just checking that values are being submitted properly
echo $countryName;
echo"<br>";
echo $gender;
echo"<br>";
echo $ChildID;
echo"<br>";

$db = mysql_connect('localhost', 'xxxx', 'xxxxx');
mysql_select_db("child",$db);

if ($ChildID != "")
{$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender') and

(ChildID ='$ChildID')";
}else{
$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender')";
}


$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "sorry, no matching results.";
echo $link;
exit;
}


echo "<table border='1' >";
echo "<tr><th>ChildID</th>
<th>givenName</th>
<th>gender</th>
<th>countryName</th>
<th>favouritePlay</th>
<th>Sponsored</th>
<th>Not Sponsored</th>
<th>dateOfBirth</th>
</tr>";
// keeps getting the next row until there are no more to get


$sponsored = array("","checked");

$not_sponsored = array("checked","");

while($show = mysql_fetch_array( $result )) {

/*Print out the contents of each row into a table*/

echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>Is sponsored";
echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."></input>Is not sponsored";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}

echo "</table>";

?>

</body>
</html>

<?php
}
?>
[/php]

PS: Don't forget to add name="Submit" to the submit button on searchpage.php

tyvm.........however firefox is still fine and ie6 doesn't load childc.php (or rather goes there and then returns to childa.php
Feb 26 '08 #26

hsriat
Expert 100+
P: 1,654
tyvm.........however firefox is still fine and ie6 doesn't load childc.php (or rather goes there and then returns to childa.php

Do one thing,

Clear the cookies and cache, and open your searchpage.php on both the browsers.
Feb 26 '08 #27

P: 37
[php]
<?php
if(!isset($_POST['Submit']))
{
header ("Location: searchpage.php");
}
else
{
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>

<?php
$link ="<br><br><a href='searchpage.php'>Click here to go back to the search page.</a>";

$countryName = $_POST['countryName'];
$gender = $_POST['gender'];
$ChildID = $_POST['ChildID'];


//Just checking that values are being submitted properly
echo $countryName;
echo"<br>";
echo $gender;
echo"<br>";
echo $ChildID;
echo"<br>";

$db = mysql_connect('localhost', 'xxxx', 'xxxxx');
mysql_select_db("child",$db);

if ($ChildID != "")
{$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender') and

(ChildID ='$ChildID')";
}else{
$query ="SELECT * FROM child.child
where (countryName = '$countryName') and (gender ='$gender')";
}


$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "sorry, no matching results.";
echo $link;
exit;
}


echo "<table border='1' >";
echo "<tr><th>ChildID</th>
<th>givenName</th>
<th>gender</th>
<th>countryName</th>
<th>favouritePlay</th>
<th>Sponsored</th>
<th>Not Sponsored</th>
<th>dateOfBirth</th>
</tr>";
// keeps getting the next row until there are no more to get


$sponsored = array("","checked");

$not_sponsored = array("checked","");

while($show = mysql_fetch_array( $result )) {

/*Print out the contents of each row into a table*/

echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";

/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>Is sponsored";
echo "</td> <td>";

/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." ''\" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."></input>Is not sponsored";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}

echo "</table>";

?>

</body>
</html>

<?php
}
?>
[/php]

PS: Don't forget to add name="Submit" to the submit button on searchpage.php

I am really a noob (King noob in fact). I was constantly clearing cookies etc and then shut down IE and now everything is good.

Thank you so much for spending all this time helping me. I really appreciate it.

I have one final question. Originally I used

code (php)
$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";
(/php)

your idea of using an array worked well. I still don't really know why my logic and approach failed.

thanks again

Loz
Feb 26 '08 #28

hsriat
Expert 100+
P: 1,654
I am really a noob (King noob in fact). I was constantly clearing cookies etc and then shut down IE and now everything is good.

Thank you so much for spending all this time helping me. I really appreciate it.

I have one final question. Originally I used

code (php)
$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";
(/php)

your idea of using an array worked well. I still don't really know why my logic and approach failed.

thanks again

Loz
You had made two mistakes...
1. You had kept 'IsSponsored' as it is, but actually, it should be $show['IsSponsored']
2. You had kept [php]$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";[/php] out of the while loop, but actually it should be in the while loop.

Come anytime with any other problem, I'll be glad to help you, if I could. :)
Feb 26 '08 #29

P: 37
You had made two mistakes...
1. You had kept 'IsSponsored' as it is, but actually, it should be $show['IsSponsored']
2. You had kept [php]$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";[/php] out of the while loop, but actually it should be in the while loop.

Come anytime with any other problem, I'll be glad to help you, if I could. :)
Thank you so much for all your time and help. I had been banging my head against a wall for a week on this one.

I really really appreciate it.

Loz :)
Feb 26 '08 #30

ronverdonk
Expert 2.5K+
P: 4,258
lozwaldo:

This the 3rd remark on your use of code tags.

Before you post anything further here, enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

moderator
Feb 26 '08 #31

P: 37
Thank you so much for all your time and help. I had been banging my head against a wall for a week on this one.

I really really appreciate it.

Loz :)
Hi
Now the correct value for the radio button is shown but when I click on the non selected radio button it becomes selected but the other radio button does not deselect

help please
Feb 27 '08 #32

hsriat
Expert 100+
P: 1,654
Hi
Now the correct value for the radio button is shown but when I click on the non selected radio button it becomes selected but the other radio button does not deselect

help please
That isn't possible, because name of both the radio buttons is same.

That only happens when you have provided different names to the radio buttons.
Feb 27 '08 #33

P: 37
That isn't possible, because name of both the radio buttons is same.

That only happens when you have provided different names to the radio buttons.
hmmm
The point of this exercise for me was to allow our support team to
1) Search table for record(s)
2)Retrieve data
3)Change status of child by selecting either 'IsSponsored' or 'NotSponsored' radio button
4)Insert new values to table (haven't got to this bit yet)

Am adapting legacy db. Do I need to change my approach or change the db table??

any thoughts appreciated
Feb 27 '08 #34

hsriat
Expert 100+
P: 1,654
hmmm
The point of this exercise for me was to allow our support team to
1) Search table for record(s)
2)Retrieve data
3)Change status of child by selecting either 'IsSponsored' or 'NotSponsored' radio button
4)Insert new values to table (haven't got to this bit yet)

Am adapting legacy db. Do I need to change my approach or change the db table??

any thoughts appreciated
How are you saving the data after changes?
Feb 27 '08 #35

P: 37
How are you saving the data after changes?
not sure what you mean

do you mean: Do I give the radio value a new $name before inserting back into table field. Am still thinking about this one.

After field has been changed the value "1" or "0" this value is then passed to a webpage that displays the children that are able to be sponsored. There is also an image that is called from another table and matched with the "child" details

btw - I work for a humanitarian aid org hence all the talk of "Child sponsorship" :)
Feb 27 '08 #36

hsriat
Expert 100+
P: 1,654
not sure what you mean

do you mean: Do I give the radio value a new $name before inserting back into table field. Am still thinking about this one.

After field has been changed the value "1" or "0" this value is then passed to a webpage that displays the children that are able to be sponsored. There is also an image that is called from another table and matched with the "child" details

btw - I work for a humanitarian aid org hence all the talk of "Child sponsorship" :)
I mean to ask you, how do you run the update query to update the data (sponsorship information) in the database?
Feb 27 '08 #37

P: 37
I mean to ask you, how do you run the update query to update the data (sponsorship information) in the database?
From the point of this 'admin' module I was hoping to add an insert query and submit button on the results page which would parse the new value selected by user from radio button back into table.

Same sort of concept as when a site admin wanted to update some options for a user
Feb 27 '08 #38

P: 37
mistake here :( ---------------------------------------------------------
Feb 28 '08 #39

P: 37
I mean to ask you, how do you run the update query to update the data (sponsorship information) in the database?
woo hoo
got radio buttons to change value.

Am trying to set up insert query now. If anyone would like to help out it would be really cool. Currently I am still trying to work out which value to parse :)

Expand|Select|Wrap|Line Numbers
  1. /*this box checked if IsSponsored = 1*/
  2. echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>Is sponsored";
  3. echo "</td> <td>";
  4.  
  5. /*this box checked if IsSponsored = 0*/
  6. echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."></input>Is not sponsored";
  7. echo "</td> </tr>";
  8. }
  9.  
  10. echo "</table>";
  11.  
  12. ?>
  13. <FORM ACTION="childa.php" METHOD="POST">
  14. <input type=submit value="submit" />
  15. </FORM>
  16.  
  17. <?php
  18. $db = mysql_connect('localhost', 'xxx', 'xxx');
  19. mysql_select_db("child",$db);
  20.  
  21. /*This is just a guess :)*/
  22. $insertvalue = $not_sponsored[$show['IsSponsored']];
  23.  
  24. if ($insertvalue == "0"){
  25. $update = "INSERT INTO child (IsSponsored)
  26. VALUES ('0')";
  27. }else{
  28. $update = "INSERT INTO child (IsSponsored)
  29. VALUES ('1')";
  30. }
  31. $result = mysql_query($update);
  32. ?>
  33.  
Feb 28 '08 #40

hsriat
Expert 100+
P: 1,654
So you need to learn the following things..

1. How to make HTML forms.
2. How to use PHP $_POST.
Feb 28 '08 #41

P: 37
So you need to learn the following things..

1. How to make HTML forms.
2. How to use PHP $_POST.
Hi Again :)

thanks for the tip

did that but am not sure about syntax when parsing values from db

Expand|Select|Wrap|Line Numbers
  1.  
  2. <FORM ACTION="childa.php" METHOD="POST">
  3. <input type="submit" value="submit" />
  4. </FORM>
  5.  
  6. <?php
  7.     $db = mysql_connect('localhost', 'xxx', 'xxx');
  8.     mysql_select_db("child",$db);
  9.  
  10.     /*Not sure of syntax here as I have only ever used $_POST for static values*/
  11.  
  12.     $IsSponsored = $_POST[$sponsored[$show['IsSponsored']]];
  13.     $NotSponsored = $_POST[$not_sponsored[$show['IsSponsored']]];
  14.  
  15.  
  16.     if ($NotSponsored == "0"){
  17.     $update = "INSERT INTO child (IsSponsored)
  18.     VALUES ('$NotSponsored')";
  19.     }else{
  20.     $update = "INSERT INTO child (IsSponsored)
  21.     VALUES ('$IsSponsored')";
  22.     }
  23.     $result = mysql_query($update);
  24.     ?>
  25.  
  26.  
If you had any suggestions I would really appreciate it. I'm sorry to bother you but I honestly haven't been able to find any tutes on this.

Loz
Feb 29 '08 #42

hsriat
Expert 100+
P: 1,654
$_POST[ ] is an array that is returned by a form when we submit it to a PHP page.

So in that array, the keys (array keys) are the names of the HTML form elements.
eg...[html]<form action="abc.php"><input type="text" name="txt"></input></form>[/html]will return $_POST['txt']. So use it accordingly.
Feb 29 '08 #43

P: 37
$_POST[ ] is an array that is returned by a form when we submit it to a PHP page.

So in that array, the keys (array keys) are the names of the HTML form

elements.
eg...[html]<form action="abc.php"><input type="text" name="txt"></input></form>[/html]will return $_POST['txt']. So use it accordingly.
Just to be clear
1)childa.php
User submits query
2)childc.php
returns results
3)User then changes data displayed in radio button e.g. from "Not_Sponsored" to "Sponsored"
4)User selects submit button
5)db is updated with new value

so
Expand|Select|Wrap|Line Numbers
  1. /*Your comment*/
  2. /*<form action="abc.php">*/
  3. <FORM ACTION="childa.php" METHOD="POST">
  4.  
  5. /*Your comment*/
  6. /*<input type="text" name="txt"></input>*/
  7.  
  8. /*Have used submit in stead of input button*/
  9. <input type="submit" value="submit" />
  10.  
  11. </FORM>
  12.  
  13. <?php
  14.     $db = mysql_connect('localhost', 'root', 'password');
  15.     mysql_select_db("child",$db);
  16.  
  17.     /*will return $_POST['txt']. So use it accordingly.*/
  18.  
  19. /*Have tried to parse either '$IsSponsored ' or '$NotSponsored' from radio buttons. I know how to post using an input box or static radio button but don't quite get how to use data from displayed quesry results*/
  20.  
  21.     $IsSponsored = $_POST[$sponsored[$show['IsSponsored']]];
  22.     $NotSponsored = $_POST[$not_sponsored[$show['IsSponsored']]];
  23.  
  24.  
Feb 29 '08 #44

hsriat
Expert 100+
P: 1,654
Unfortunately, you are missing the basics buddy!

You need to make a third PHP file which will save the submitted data to the Database.
First look how it works:
PHP Forms
PHP and DB
Feb 29 '08 #45

P: 37
Unfortunately, you are missing the basics buddy!

You need to make a third PHP file which will save the submitted data to the Database.
First look how it works:
PHP Forms
PHP and DB
lol - of course I do. I'm just getting a bit ahead of myself. Didn't think that one through.

I'll get back to it then.

tyvm
Feb 29 '08 #46

P: 37
lol - of course I do. I'm just getting a bit ahead of myself. Didn't think that one through.

I'll get back to it then.

tyvm
Set up third page (of course) and have insert query ready to go.

Form on childc.php

Expand|Select|Wrap|Line Numbers
  1. <FORM ACTION="childf.php" METHOD="POST">
  2. <input type="submit" name="IsSponsored[]" value="Submit" />
  3. </FORM>
  4.  
goes to childf.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $db = mysql_connect('localhost', 'xxx', 'xxx');
  3.     mysql_select_db("child",$db);
  4.  
  5.     $IsSponsored = $_POST['IsSponsored[]'];
  6.  
  7.     $update = "INSERT INTO child (IsSponsored)
  8.     VALUES ('$IsSponsored')";
  9.  
  10.     $result = mysql_query($update);
  11.     ?>
  12.  
am i on the right track
Feb 29 '08 #47

hsriat
Expert 100+
P: 1,654
This is actually not the right track.

You badly need to learn the basics first!!

Check out the links I posted earlier and/or consult someone senior there at your workplace.

Make a proper design, how you need to get the things done, then start working. If design is not good, you will need to make changes again and again.

Advice: Leave the coding for a while. Sort out your confusions and then get back to the coding.
Feb 29 '08 #48

ronverdonk
Expert 2.5K+
P: 4,258
This is becoming an endless thread! It looks like there are 2 parties (the thread opener and the rest of the participating members) who do not talk on the same level. And the confusion gets bigger with every post.

Following the discussions I must agree with hsriat that there is a lack of (at least theoretical) skills, which is required for this.

When we let this continue, this thread will eventually bleed dry, so I propose the following:
  • Read the tutorials of which the links are posted by hsriat, so we can discuss the problem on a more levelled field.
  • Explain in clear and concise English what the intention of your application is.
  • Show all (not snippets!) of the code of all involved scripts (3?) and show them within code tags. Then we have all the involved information together and can work from that.

moderator
Feb 29 '08 #49

P: 37
am VERY sorry to waste everyones time

I have gone through the links.

1) I have place a standard radio button to test the syntax etc. I have been able to pass test values through the page which will insert new value into db (childf.php)

Question
What is the syntax for passing the value for the radio buttons populated by the query to the database.

Expand|Select|Wrap|Line Numbers
  1. echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>Is sponsored";
  2.  
I take the name to be
Expand|Select|Wrap|Line Numbers
  1. name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."
  2.  
I have tried to post by using this:
Expand|Select|Wrap|Line Numbers
  1. $IsSponsored = $_POST['".$show['ChildID']." \" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."'];
  2.  
I keep getting this error message
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Inetpub\wwwroot\practice\childf.php on line 16

I have successfully been able to show value from test radio button by using
Expand|Select|Wrap|Line Numbers
  1. $spam = $_POST['spam'];
  2.  
I am sorry that I have not been a good poster. I will understand if you would prefer to close this thread and will not feel any bad feeling towards you.

Also I would like to thank hsriat as he has been so helpful (and patient) despite my limited knowledge.

Here is the code in full.
Search page "childa.php"
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  2.  
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>PHP tutorial</title>
  8. </head>
  9.  
  10. <body>
  11. <h2>Search for child</h2>
  12. <br />
  13. <FORM ACTION="childc.php" METHOD="POST">
  14.  
  15.  
  16. Which country are seeking:
  17. <br />
  18. <SELECT NAME="countryName">
  19. <option value="Bangladesh">Bangladesh
  20. <option value="Honduras">Honduras
  21. <option value="Mali">Mali
  22. <option value="Malawi">Malawi
  23. <option value="Niger">Niger
  24. <option value="Nicaragua">Nicaragua
  25. <option value="Tanzania">Tanzania
  26. <option value="Uganda">Uganda
  27. <option value="Zambia">Zambia
  28.  
  29. </select>
  30. <br />
  31. <SELECT NAME="gender">
  32. <!--<option value="'LIKE %'">Male or Female-->
  33. <option value="M">Male
  34. <option value="F">Female
  35.  
  36. </select>
  37. <br />
  38.  
  39. ChildID:<input type="text" size="12" maxlength="18" name="ChildID">
  40. <br />
  41. <br />
  42.  
  43. <INPUT TYPE="submit" VALUE="search" name="Submit">
  44. </FORM>
  45. </body>
  46. </html>
  47.  
show results page "childc.php"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(!isset($_POST['Submit']))
  3. {
  4.   header ("Location: searchpage.php");
  5. }
  6. else
  7. {
  8. ?>
  9.  
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  11.  
  12. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  13. <html xmlns="http://www.w3.org/1999/xhtml">
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <title>Admin</title>
  17. </head>
  18.  
  19. <body>
  20.  
  21. <?php
  22. $link ="<br><br><a href='searchpage.php'>Click here to go back to the search page.</a>";
  23.  
  24. $countryName = $_POST['countryName'];
  25. $gender = $_POST['gender'];
  26. $ChildID = $_POST['ChildID'];
  27.  
  28.  
  29. //Just checking that values are being submitted properly
  30. echo $countryName;
  31. echo"<br>";
  32. echo $gender;
  33. echo"<br>";
  34. echo $ChildID;
  35. echo"<br>";
  36.  
  37. $db = mysql_connect('localhost', 'xxx', 'xxxx');
  38. mysql_select_db("child",$db);
  39.  
  40. if ($ChildID != "")
  41. {$query ="SELECT * FROM child.child
  42. where (countryName = '$countryName') and (gender ='$gender') and 
  43.  
  44. (ChildID ='$ChildID')";
  45. }else{
  46. $query ="SELECT * FROM child.child
  47. where (countryName = '$countryName') and (gender ='$gender')";
  48. }
  49.  
  50.  
  51. $result = mysql_query($query);
  52. if (mysql_num_rows($result) == 0) {
  53. echo "sorry, no matching results.";
  54. echo $link;
  55. exit;
  56. }
  57.  
  58.  
  59. echo "<table border='1' >";
  60. echo "<tr><th>ChildID</th> 
  61. <th>givenName</th> 
  62. <th>gender</th> 
  63. <th>countryName</th> 
  64. <th>favouritePlay</th> 
  65. <th>Sponsored</th> 
  66. <th>Not Sponsored</th> 
  67. <th>dateOfBirth</th>
  68. </tr>";
  69. // keeps getting the next row until there are no more to get
  70.  
  71.  
  72. $sponsored = array("","checked");
  73. $not_sponsored = array("checked","");
  74.  
  75. while($show = mysql_fetch_array( $result )) {
  76.  
  77. /*Print out the contents of each row into a table*/
  78. ?>
  79. <FORM ACTION="childf.php" METHOD="POST">
  80. <?php
  81. echo "<tr> <td>";
  82. echo $show['ChildID'];
  83. echo "</td> <td >";
  84. echo $show['givenName'];
  85. echo "</td> <td>";
  86. echo $show['gender'];
  87. echo "</td> <td>";
  88. echo $show['countryName'];
  89. echo "</td> <td>";
  90. echo $show['favouritePlay'];
  91. echo "</td> <td>";
  92.  
  93. /*this box checked if IsSponsored = 1*/ 
  94. echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"1\" ".$sponsored[$show['IsSponsored']]."></input>Is sponsored";
  95. echo "</td> <td>"; 
  96.  
  97. /*this box checked if IsSponsored = 0*/
  98. echo "<input type=\"radio\" name=\"".$show['ChildID']." \" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."></input>Is not sponsored";
  99. echo "</td> <td>";
  100. echo $show['dateOfBirth'];
  101. echo "</td> </tr>"; 
  102. }
  103.  
  104. echo "</table>";
  105. /*Test radio button here - which works*/
  106. echo "<input name=\"spam\" type=\"radio\" value=\"1\" /></input>Yes";
  107. echo "<input name=\"spam\" type=\"radio\" value=\"0\" /></input>No";
  108. ?>
  109. <input type="submit" value="submit" />
  110. </FORM>
  111. </body>
  112. </html>
  113.  
  114. <?php
  115. }
  116. ?>
  117.  
Insert page "childf.php"
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10.     $db = mysql_connect('localhost', 'xxx', 'xxx');
  11.     mysql_select_db("child",$db);
  12.  
  13.     $spam = $_POST['spam'];
  14.     echo $spam;
  15.     echo "<br><br>"
  16.     $IsSponsored = $_POST['".$show['ChildID']." \" value=\"0\" ".$not_sponsored[$show['IsSponsored']]."'];
  17.     echo $IsSponsored;
  18.  
  19.     /*$update = "INSERT INTO child (IsSponsored)
  20.     VALUES ('$IsSponsored')";
  21.  
  22.     $result = mysql_query($update);*/
  23.     ?>
  24. </body>
  25. </html>
  26.  
Mar 1 '08 #50

62 Replies

Post your reply

Sign in to post your reply or Sign up for a free account.