Jump to content

viviosoft

Members
  • Posts

    85
  • Joined

  • Last visited

Posts posted by viviosoft

  1. Hello all,

     

    I have form that has several fields.  Each field will be saved to a table (which is a relations table we will call markups).  The form is built from another table which is an array of categories.  The output will build a form with each category and allow the end-user to input data for each category.  The information the user will be entering is markup values. 

     

    Cat1 | Markup Input

    Cat2 | Markup Input

    Cat3 | Markup Input

     

    I'll be saving the data in their own columns and not as an serialized array to the database.  I'm currently looping through the arrayed fields and saving the data to the markup relations table.  I've read other forums and serializing the data will be to difficult to retrieve for relationship purposes??  Anyway, here's my question:

     

    Let's say the user is entering the markups for the first time.  They go down the list of categories and add their markups for each and click save.  Cool, no problem just do an INSERT INTO. Then, they go into the category setup screen and add a category then go back to the markup screen and now have to update the category markup that was just added. 

     

    So now I have to do an UPDATE to the current listed markups table (no problem). But now I have to add another row in the same table from that array.  Is there a logical way of handling this.  I guess I'm looking for some ideas on how to accomplish this task.  I hope you guy understand what I'm after here.  Thanks for any suggestions on this.

     

     

  2. Hello all,

     

    Okay, I have one for ya.  I have the following arrayed data:

     

    <?php
    
    $fetch = mysql_query("SELECT * FROM plist WHERE item_num REGEXP '^$param' LIMIT 5"); 
    
    /* Retrieve and store in array the results of the query.*/
    
    while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
    
    	$row_array['euc'] 	        = $row['euc'];
    	$row_array['value'] 		= $row['item_num'];
    	$row_array['item_disc'] 	= ucfirst(strtolower($row['item_disc_1']));
    	$row_array['item_cost'] 	= $row['price'];
    
            array_push($return_arr,$row_array);
        }
    
    ?>
    

     

    I can get the data I'm after just fine in the above array.  However,  I want to go a step further and get some more data from another table in the same database.  The data in the second table is serialized and relates to the data in the first table which is NOT serialized.  The data in the first array has a id that relates to both tables (euc).

     

    I can't seem to figure out how to fetch the data from the second table that has the serialized data in it. So I can output the related data from both tables for each row fetched. 

     

    I understand that UNION or JOIN might work but since the data in the second table is serialized I'm not sure those methods will work.  Any ideas how I can make this work?  Thanks for any help on this one guys!!

     

  3. Hello all,

     

    I have a problem I'm not sure how to tackle.  I have data in a database that looks looks like this:

     

    Field1  |    Field2

    AA        |    AA Row 1 Data

    AA        |    AA Row 2 Data 

    AA        |    AA Row 3 Data 

    AB        |    AB Row 4 Data

    AB        |    AB Row 5 Data

    AB        |    AB Row 6 Data

    AC        |    AB Row 7 Data

    AC        |    AB Row 8 Data

    AC        |    AB Row 9 Data

    AC        |    AB Row 10 Data

     

    I would like to grab and output JUST the first AA, AB, AC  and the the row data in field two?  So the loop would catch the first AA then when field1 data has changed it will output the first AB and so on... 

     

    So the output would look like:

     

    Row1:  AA : AA Row 1 Data

    Row2:  AB : AA Row 4 Data

    Row3:  AC : AA Row 7 Data

     

    Is there a way to accomplish this?  Any help would be great!

     

    Thanks!

  4. Hello all,

     

    I have a simple question (well, not for me anyway).  I have two tables in the same database.  Each table has different field names and not the same amount of fields. Not sure if that matters or not?  Anyway,  I want to combine the two.  I'm working on a autocomplete form which allow the user to start typing a word and they get a list of related words that match their input (much like google.com does).

     

    How would write such an SQL statement?  Thanks for any help on this.

  5. No, I understood what you said.  I should have said that the information is coming from the database that way.  I'm using serialized data from the database.  Each row in the database table is a built array.  So, array one are items, and array two are the descriptions and so on.  The sample code that I provided was just an example... Does that clarify things a bit?

  6. Hello all!

     

    I can't seem to wrap my head around how to accomplish my problem.  Here's my problem.  I have several array's (only two this example).

     

    <?php
    	$item_num =   array ( 0 => "00000", 1 => "00001", 2 => "00002" ),
                    $item_disc =    array ( 0 => "Some info for 0", 1 => "Some info for 1", 2 => "Some info for 2" )
    ?>
    

     

    I want to build a table using the arrayed information.  Something like:

     

    <table>
    
       <tr>
          <td><input value="'.$item_num[0].'" name="item[]" size="9"></input></td>
          <td><input value="$item_disc[0]" name="disc[]" size="33"></input></td> 
       </tr>
    
       <tr>
          <td><input value="'.$item_num[1].'" name="item[]" size="9"></input></td>
          <td><input value="$item_disc[1]" name="disc[]" size="33"></input></td> 
       </tr>
    
    <table>
    

     

    I know how to loop through an array but this is a bit different in that I each array would need extracted in the loop.  If you notice I want to build rows and the values for each row are in separate arrays.  So $item_num and $item_disc are in the same row and exacts ['0'] and the next row is [1] and the next row is [2], etc...

     

    Any help would be great.  Thanks.

     

    viviosoft -

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.