Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    92
    Thanks
    8
    Thanked 0 Times in 0 Posts

    inserting the data if the column name matches with it

    I am trying to insert data to the database. In my database i have columns like this:
    Code:
    mid, 1,2,3,4,5 till 31
    and when a user registers (here mid is month id like 1 to 12) , i take the date on that day like this
    Code:
    $date_of_admit=date('Y-m-d');       
    list($year, $month, $day) =explode("-",$date_of_admit);
    $month = (int)$month;
    now, i have to insert 'P' where the day matches, if day is 4 then it should insert 'P' in the column 4 . This i am not getting how to proceed.

    please suggest

    Thanks

  • #2
    New Coder
    Join Date
    Jan 2011
    Posts
    92
    Thanks
    8
    Thanked 0 Times in 0 Posts
    can somebody please reply

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,039
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Firstly, you only posted this about 30 minutes ago.

    Secondly, your database table is laid out like spreadsheet, making it very hard for a program or query to insert, find, or update information.

    Your database table should simply store the data, one item per row. If you are trying to store the day of month, just store the day number (or the whole date) and relate it to the id of whoever the value belongs with.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •