need help in php data keep after submit

hi,

[code]


Height *
<?php echo $account->getError(Constants::$Height); ?>
<?php $selected =$_POST[‘height’];
<?php if(!empty($_POST['height'])){echo getInputValue('height');}else{echo 'Choose';}?> 4ft - 121 cm 4ft 1in - 124cm 4ft 2in - 127cm 4ft 3in - 129cm 4ft 4in - 132cm 4ft 5in - 134cm 4ft 6in - 137cm 4ft 7in - 139cm 4ft 8in - 142cm 4ft 9in - 144cm 4ft 10in - 147cm 4ft 11in - 149cm 5ft - 152cm 5ft 1in - 154cm 5ft 2in - 157cm 5ft 3in - 160cm 5ft 4in - 162cm 5ft 5in - 165cm 5ft 6in - 167cm 5ft 7in - 170cm 5ft 8in - 172cm 5ft 9in - 175cm 5ft 10in - 177cm 5ft 11in - 180cm 6ft - 182cm 6ft 1in - 185cm 6ft 2in - 187cm 6ft 3in - 190cm 6ft 4in - 193cm 6ft 5in - 195cm 6ft 6in - 198cm 6ft 7in - 200cm 6ft 8in - 203cm 6ft 9in - 205cm 6ft 10in - 208cm 6ft 11in - 210cm 7ft - 213cm
[/code] in this form i only getting value 121 after submit data i need to get 4ft-121cm how it possible please help!

[php]4ft - 121 cm[/php]

are you really storing imperialistic numbers in your db…?

Curious why you are doing it this way. If you want to use a drop down, why not separate the primary and secondary numbers? Or Have a selection to choose either or and use a conversion?

Going the route you are, a look up is the option you want.

hi i’m new in this field how to do this! do i need to value=“4ft - 121 cm” in this form right?

ok

how? when dropdown from data base…id and name… value=“id” name =namehere? how to do this?

If the dropdown is being populated by a data table, you use the id and display name. When you insert the record, you use the ID from the table as a foreign key. When you select (view) their data, it just joins on the table.

tbl_height
ID | value
1 | 6ft

tbl_member
ID | name | height
2 | astonecipher | 1

SELECT m.name, m.height FROM tbl_member m INNER JOIN tbl_height h ON m.height = h.ID WHERE m.ID = 2

i didn’t understand! here is my dropdown country list <?php

$stmt = $DB_con->prepare("SELECT * FROM countries");
$stmt->execute();
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
	?>
    <option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option>
    <?php
} 

?> how to retain input value! after form submit…!

<?php $stmt = $DB_con->prepare("SELECT * FROM countries"); $stmt->execute(); while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) { $selected = ''; if(!empty($_POST['country']) and $_POST['country'] == $row['id']) { $selected = ' selected="selected"'; // hah! } echo ''.$row['name'].''; } ?> here is!

Way to go!

Sponsor our Newsletter | Privacy Policy | Terms of Service