Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:15:15+00:00 2026-06-08T08:15:15+00:00

I wish to store the ingredients if an item as an array or similar

  • 0

I wish to store the ingredients if an item as an array or similar data type in my SQL Database and cannot able to find satisfactory information on the subject

In PHP, the information will get stored as ingredient["$id"]=true or false, where $id represents an ingredient

So for plain bread (please note this is mostly still pseudo code as the data entry side has not yet been started)

//code that creates array this bit is still theory and will be manually emulated in the db for the time being
    $id=1;
    while (isset ($_POST["ingredient part of form".$ID])){
        if ($_POST["ingredient".$id]==checked){
            $p["ingredient"][$id]=true;
        }
        else{
            $p["ingredient"][$id]=false
        }
    $id++;
    }

//the code that gets the values back for the ingredient name we will use a separate array ingredient_n[$id]
echo p[$prod_id]["item"].': '
$id=1
while (isset ($ingredient[$id])){
    if ($p[$prod_id]["ingredient"][$id]==true)
        if ($id!=1){
            echo ', ';
        }
        echo $ingredient_n[$id];
    }
}
echo '.';

This should produce something like

‘PLAIN BREAD: WHEAT FLOUR, WATER, SALT, YEAST.’

I looked in to ENUM and SET but that would make adding new ingredients harder

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:15:17+00:00Added an answer on June 8, 2026 at 8:15 am

    Judging by the topic (Store a PHP array in a single SQL cell) you should serialize this. There are standardized methods for that

    $array["a"] = "Hello";
    $array["b"] = "World";
    $array["c"] = "!";
    
    $str = serialize($array);
    
    // The contents of $str
    // a:3:{s:1:"a";s:5:"Hello";s:1:"b";s:5:"World";s:1:"c";s:1:"!";}
    

    To reverse use unserialize

    $unserializedString = unserialize($str);
    

    You can use this for both arrays and objects.

    • http://php.net/manual/en/function.serialize.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently processing text/html data and I wish to store my results in
I wish to store UUIDs created using java.util.UUID in a HSQLDB database. The obvious
In case of a exception i wish to store data in db (url,description,code,method, referer,clientip,useragent)
I wish to use an SQL database that it already in use on my
I wish to store some binary values in an array in C. How it
If I wish to store application username/passwords in a database, it is unclear whether
I have a Winforms TreeView and I wish to store the node data into
I wish to store URLs in a database (MySQL in this case) and process
I have a store of data objects and I wish to synchronize modifications that
I wish to store the values in a string array i.e. values of arr[16][16].

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.