php - getting row wise data from the database -
i have table named allocate this
create table allocate( mid int(10), pid int(20), day1 int(2), day2 int(2), ... day31 int (2) );
in mid
, have number corresponding month (1 january, 2 february, etc.). in day1 through day31, have numerical values. i'm trying retrieve , update data same, unable it.
i'm using following code retrieve each month's data:
mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); $sql = "select * allocate product_id = '".$product_id."' "; // $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($res)) { $day1 = $row['day1']; $day2 = $row['day2']; $day3 = $row['day3']; $day4 = $row['day4']; $day5 = $row['day5']; $day6 = $row['day6']; $day7 = $row['day7']; $day8 = $row['day8']; $day9 = $row['day9']; $day10 = $row['day10']; $day11 = $row['day11']; $day12 = $row['day12']; $day13 = $row['day13']; $day14 = $row['day14']; $day15 = $row['day15']; $day16 = $row['day16']; $day17 = $row['day17']; $day18 = $row['day18']; $day19 = $row['day19']; $day20 = $row['day20']; $day21 = $row['day21']; $day22 = $row['day22']; $day23 = $row['day23']; $day24 = $row['day24']; $day25 = $row['day25']; $day26 = $row['day26']; $day27 = $row['day27']; $day28 = $row['day28']; $day29 = $row['day29']; $day30 = $row['day30']; $day31 = $row['day31']; } echo $day1;
here, getting values january day1 day31. how solve this? insertion allocation happening.
in sql query, refering field product_id
select * allocate product_id =
which doesn't exist in schema. print out data row wise should have had echo
inside while loop loops through result row wise.
Comments
Post a Comment