Jump to content

Recommended Posts

hi,

i have a table.it's structure is like this
itemno--itemname--price
1--abc--200
2--djh--300
3--eee-400

i want to dynamically create 3 radio buttons for prices and to display these records on web page and when a user click radio button of any one the selected values should be stored in some other table.how to do this.i know how to display and store in db.problem is with dynamically creating radio buttons.please any of your help is appreciated.

thanks
mrjameer
Link to comment
https://forums.phpfreaks.com/topic/31256-problem-with-radio-button/
Share on other sites

[code]
// example retrieval of all info in your db

$sql = "select * from table";
$result = mysql_query($sql) or die(mysql_error());

while ($list = mysql_fetch_array($result)) {
  // make a radio button with the item name next to it. radio button will
  // pass all of the info associated with the item as an array called [itemname]
  echo "<input type='radio' name='{$list['itemno']}' value='{$list}'>{$list['itemname']}<br/>";
}
[/code]
[code]
<?php
//Connect to DB here
$sql = mysql_query(\"SELECT * FROM `tablename`\");
?>
<form method=\"PAGE HERE\" action=\"\">
<?php
while($row = mysql_fetch_assoc($sql)){
echo\"<input type=\'radio\' value=\".$row[\'price\'].\" name=\'\".$row[\'itemno\'].\"\'>\".$row[\'itemname\'];
}
?>
</form>
<?php
//Of course, you will need to change some of the information, but that is the basic structure.
?>
[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.