hi everyone i have table in the database from where i fetch data one column of table has user input n i fetch the data on the basis of user input like if user enter 2 in the textbox only that rows that contain number 2 will display like code of insertion on the basis of no of room
<?php
$d=$_POST['roomno'];
echo $d;
?>
<?php
//database connection
$db = new PDO("mysql:host=localhost;dbname=ems",'root','');
//query
$sql = "INSERT INTO table1 (c,c1, c2, c3, c4,c5,c6,c7,c8,c9,c10,c11,c12,c13) VALUES ('',:c1, :c2, :c3, :c4,:c5, :c6, :c7, :c8, :c9,:c10, :c11, :c12,'$d')";
$stmt = $db->prepare($sql);
foreach ($data_t1 as $i => $value) {
$stmt->execute(array(
':c1'=>$data_t1[$i],
':c2'=>$data_t2[$i],
':c3'=>$data_t3[$i],
':c4'=>$data_t4[$i],
':c5'=>$data_t11[$i],
':c6'=>$data_t22[$i],
':c7'=>$data_t33[$i],
':c8'=>$data_t44[$i],
':c9'=>$data_t111[$i],
':c10'=>$data_t222[$i],
':c11'=>$data_t333[$i],
':c12'=>$data_t444[$i],
));
} ?>
coding for fetchng the data
<?php
include('config.php');
$sa="select * from table1 where c13='$d'";
$result=mysql_query($sa) or die(mysql_error());
echo "<table border='1'>
<tr>
</tr>";
<?php
$i = 1;
while($row = mysql_fetch_array($result)) {
echo ${"r" . $i . "1"} = $row['c'];
echo ${"r" . $i . "2"} = $row['c1'] ;
echo ${"r" . $i . "3"} = $row['c2'];
echo ${"r" . $i . "4"} = $row['c3'];
echo ${"r" . $i . "5"} = $row['c4'];
$i++;
}
result
$d=3;mean user enter 3
3 room deatils enter in three rows of table like ths
row1 2 4 5 6 3(user enter value)
row2 12 14 15 16 3(user enter value)
row3 22 44 55 63 3(user enter value)
now as i mention in my fetch query that fetch the data where c13(room)=user input($d);
result of theses above three row display
now i want to store each of theses three row values in different varaibles
in the similar manner if user enter 2 or 4 i want to store two or four rows values in different varaible