/    Sign up×
Community /Pin to ProfileBookmark

I need some Help in making logic

Hello,

I create two options Name Gender and Belong as you see in the image[ATTACH]12462[/ATTACH] I want to create a function in php whene the loop run as values comes from database radio buttons create number of time that the possible pairs like image shows a 2 * 2 radio buttons and possible pairs of radio buttons are four. Actualy problem is that I want to make a function that radio button automaticaly checked each pair in the loop as clear from image.

thanks,

usama waleed

[upl-file uuid=e6a23eec-ead6-4212-95e8-86b4336ee518 size=24kB]detail image.JPG[/upl-file]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@usamawaleedauthorMar 27.2009 — if some one not under stand what I want then I tell you in breif that as you see in image file that I attached there is a multidymentional array

like this

<table align="center" width="40%" border="0">

<?php

$optNameValue = array(gender=>array(male,female),Belong=>array(amrica,aisia))

now if i whish to create radio buttons for each array I write code as

foreach($optNameValue as $key=>$value)

$total[] = count($value); // in order to calculate total number of time loop run

$loop=1;
for($i=0; $i<count($total); $i++)
$loop = $total[$i] * $loop;

for($i=0; $i<$loop; $i++)
{
$m =0;
foreach($optNameValue as $key=>$value)
{
$m = $m + 1;
echo "<tr><td width='100px'><b>".$key."</b></td>";
foreach($value as $opt_value=>$name)
{ ?>

<td width="70px" align="right"><?php echo $name; ?> </td>
<td width="20px"><input type="radio" name="<?php echo $i.''.$m; ?>" value="<?php echo $opt_value; ?>" /></td>
<?php
}
echo "</tr>";
}
echo "<tr><td height='30px'></td></tr>";
//echo "<tr><td><b>Price</b></td><td><input type='text' name='price'></td></tr><tr><td height='20px'></td></tr><br>";
}

?>

you see the result same as i show in the image. but now problem is that I want to checked radios button for all possible pairs like

Gender[] = ( male, female);

Belong[] = (africa, asia);

possible pairs are

  • 1. male & africa,

  • 2. male & asia,

    3.female & africa,

    4 female & asia,


  • now I want to checked radio buttons in each loop as possible pairs are made in example.

    now I hope you under stand what I mean

    thanks,

    usama waleed
    ×

    Success!

    Help @usamawaleed spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...