Put MySQL queries into variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darren

    Put MySQL queries into variables

    The following query returns 7 codes, how do I put each of them into a
    separate variable?

    $result = mysql_query("SE LECT day_plan FROM calorie_plan WHERE calories
    = '$calories'");
    if (!$result) {
    die('Invalid query: ' . mysql_error());
    }
    while ($row = mysql_fetch_arr ay ($result))
    {
    $day_plan = $row['day_plan'];
    }

    I'm sure I've done this before but I can't remeber how or where.

    Many thanks

    Darren

  • Ian B

    #2
    Re: Put MySQL queries into variables

    Use an array?

    $day_plan[] = $row['day_plan'];

    Comment

    • Darren

      #3
      Re: Put MySQL queries into variables

      Cheers Ian,

      I couldn't get my head round it.

      Darren

      Comment

      Working...