473,378 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Radio buttons not showing values from database

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
62 4891
hsriat
1,654 Expert 1GB
What is IsSponsored?
Feb 26 '08 #2
What is IsSponsored?
IsSponsored is a field in table

Has value of "1" or "0"
Feb 26 '08 #3
hsriat
1,654 Expert 1GB
[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
[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
1,654 Expert 1GB
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
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
1,654 Expert 1GB
The code seems to be fine, the problem may be with the file name or directory.
Feb 26 '08 #8
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
1,654 Expert 1GB
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
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
1,654 Expert 1GB
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
6,050 Expert 4TB
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
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
6,050 Expert 4TB
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
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
1,654 Expert 1GB
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
1,654 Expert 1GB
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
6,050 Expert 4TB
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
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
6,050 Expert 4TB
What is the problem now?
Feb 26 '08 #21
hsriat
1,654 Expert 1GB
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
1,654 Expert 1GB
[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
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
1,654 Expert 1GB
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
[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
1,654 Expert 1GB
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
[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
1,654 Expert 1GB
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
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
4,258 Expert 4TB
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
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
1,654 Expert 1GB
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
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
1,654 Expert 1GB
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
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
1,654 Expert 1GB
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
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
mistake here :( ---------------------------------------------------------
Feb 28 '08 #39
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
1,654 Expert 1GB
So you need to learn the following things..

1. How to make HTML forms.
2. How to use PHP $_POST.
Feb 28 '08 #41
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
1,654 Expert 1GB
$_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
$_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
1,654 Expert 1GB
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
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
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
1,654 Expert 1GB
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
4,258 Expert 4TB
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
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

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

Similar topics

3
by: Suzanne | last post by:
Hi, I have a form which our clients can fill in with their personal details. As part of the information we store there is a section - areas of interest - this is a number of radio buttons. ...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
4
by: Jay | last post by:
I have a form used to submit data (no surprises there!). I'd like to be able to populate the same form with previously submitted data. The data lives in a database once submitted and using ASP I...
2
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and...
5
by: Dabbler | last post by:
What is the best way to handle data interpolation between form controls and the actual sql data field. I have radio buttons that need to be interpreted, form values that have to be translated.....
0
by: sanmateof | last post by:
My radio buttons are showing the value besides the button even though no text is displayed. Below is my code: <td style="width: 100px"><asp:RadioButtonList ID="RadioButtonList16" runat="server"...
7
by: Jerim79 | last post by:
My situation is that I have a form that asks the user for a number. Next, I execute a while loop that displays a group of questions the amount of times the customer entered. For instance, the loop...
7
by: help4me | last post by:
Hope someone can help me out with this. I'm having trouble getting my radio button values into a MySQL database. And after I do get them inserted I'm going to want to be able to show them back in...
7
by: gengyue | last post by:
Hi, I am running a report using Cold Fusion. This report is generated by cfloop tag. Depends on the record count of a query, the report will list the data retrieved from the database. each row in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.