• This is the result of my var_dump(). I need to know how to enter the value to the database. I just got the syntax wrong. I can echo it and var_dump()

    object(stdClass)[179]
      public 'cat_assoc_id' => string '4129' (length=4)
      public 'prod_id' => string '179' (length=3)
      public 'cat_id' => string '3' (length=1)
      public 'prod_order' => string '0' (length=1)

    and I am trying to enter the values here. How to I enter the value of prod_order.

    $getem = $wpdb->get_row("SELECT * FROM category_assoc WHERE prod_id = $lastid, ARRAY_N");
    $catCategory = "INSERT INTO category_assoc (prod_id, cat_id, prod_order) VALUES('$lastID', '". $cats[$i] . "', '" .$getem['prod_order']. "')";
    
    I have tried
    $getem['prod_order']
    $getem[]
    $getem
Viewing 1 replies (of 1 total)
  • Thread Starter Bloke

    (@bloke)

    Ok this is what I have so far. It will enter each record but it will not enter the prod_order for each line.

    $getem = $wpdb->get_row("SELECT * FROM category_assoc WHERE prod_id = '$lastID'");
    
    $prodorder = $getem->prod_order;
    
    if($edit)
    
    for($i= 0; $i < count($cats); $i++)
    
        {
    
    $catCategory = "INSERT INTO category_assoc (prod_id, cat_id, prod_order) VALUES('$lastID', '". $cats[$i] . "', '".$prodorder."')";
    
    $wpdb->query($catCategory);
        }

Viewing 1 replies (of 1 total)
  • The topic ‘Put result of array to database’ is closed to new replies.