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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Help code dosen't work

    K, hi guys i am working on a for loop which checks if mysql row is empty then he does nothing else he updates $list_names which are used.

    code:
    Code:
    	
    $user_id = 0;
    $test = mysql_query("SELECT * FROM items WHERE id = ".$user_id."");
                    for($p512_slots = 1; $p512_slots < 5; $p512_slots++) {
    		$item+$p512_slots = $test[$p512_slots];
    		if($item+$p512_slots == NULL) {
    		NULL;
    		} else {
    		$items_1_+$p512_slots = mysql_query("SELECT * FROM items WHERE id = ".$item+$p512_slots."");
    		$test_1_+$p512_slots = mysql_fetch_array($items_1_+$p512_slots);
    		$p3_1_+$p512_slots_iid   	= $item+$p512_slots;
    		$p3_1_+$p512_slots_image 	= $test_1_+$p512_slots['image'];
    		$p3_1_+$p512_slots_type  	= $test_1_+$p512_slots['type'];
    		$p3_1_+$p512_slots_asize 	= $test_1_+$p512_slots['asize'];
    		$p3_1_+$p512_slots_bsize 	= $test_1_+$p512_slots['bsize'];
    		$p3_1_+$p512_slots_taccp 	= $test_1_+$p512_slots['taccp'];
    		$p3_1_+$p512_slots_prei  	= $test_1_+$p512_slots['praeis'];
    		$p3_1_+$p512_slots_prei2 	= $test_1_+$p512_slots['praeis2'];
    		$p3_1_+$p512_slots_prem  	= $test_1_+$p512_slots['premium'];
    		$p3_1_+$p512_slots_ques  	= $test_1_+$p512_slots['quest'];
    		$p3_1_+$p512_slots_encht 	= $test_1_+$p512_slots['enchtype'];
    		$p3_1_+$p512_slots_uniq  	= $test_1_+$p512_slots['unique'];
    		$p3_1_+$p512_slots_level 	= $test_1_+$p512_slots['level'];
    		$p3_1_+$p512_slots_qual  	= $test_1_+$p512_slots['quality'];
    		}
    		}
    As you can see it haves mistakes in code i just can't figure out how to do for loop like this which is working correctly.

    If you ask me what i want to do then i would say something like this:
    there is:
    mysql_rows:
    p512_1_1
    p512_1_2
    p512_1_3
    p512_1_4
    p512_2_1
    p512_2_2
    p512_2_3
    p512_2_4
    p512_3_1
    and soo on until p512_8_4
    i want to make a script that checks if mysql row example p512_1_1 is empty then do nothing else update
    Code:
    $$p3_1_+$p512_slots_iid   	= $item+$p512_slots;
    $p3_1_+$p512_slots_image 	= $test_1_+$p512_slots['image'];
    check with everyone from p512_1_1 to p512_8_4 but as you can see when p512_1_this pasts for number it starts from one and increases the middle one by one. So i thinked and i found only one way by 8 for loops. But when i tryed to make the first one acceptable by the result i want and trying to fix the unnecesarry coding by making it automatic i stucked, so maybe someone got any examples or can help me? really appreaciaty your healp sorry for bad english.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,301
    Thanks
    23
    Thanked 612 Times in 611 Posts
    Please tell us in english what your trying to do. Your code is way bad.
    Please explain what your variables are and where do they come from:
    $items
    $p512_slots
    $p3_1_
    $test_1_
    etc.

    The loop you asked for:
    PHP Code:
    <?php
    $string 
    "";

    for(
    $i 1$i 9$i++)
    {
        for(
    $y 1$y 5$y++)
        
    $string .= "p512_".$i."_".$y."<br />";
    }
    echo 
    $string;
    ?>

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You said "...to check if mysql row is empty ... "

    Do you mean "columns" instead of "rows"?

    Like karolismf, I'm having trouble understanding the OP.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,341
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    My interpretation of this is that the op wants to check if there are results or no results. If thats the case..

    PHP Code:
    $Result mysql_query("your query here");

    $RowCount 0;

    while (
    $Row mysql_fetch_array($Result))
       {
       
    $RowCount++;

       
    //Other stuff here
       
    }

    If (
    $RowCount == 0)
       {
       
    //Do no results stuff here.
       

    Thats off the top of my head without looking at the php.net manual for any better way of doing it.

    If the op wants to check each individual row is empty then its a foreach ($Row as $Key => $Value) method and checking that $Value == '' or empty($Value)
    Last edited by tangoforce; 03-09-2013 at 07:48 PM.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Code:
    CREATE TABLE IF NOT EXISTS `inventory` (
      `id` int(11) NOT NULL,
      `p512_1_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_1_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_1_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_1_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_2_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_2_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_2_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_2_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_3_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_3_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_3_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_3_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_4_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_4_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_4_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_4_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_5_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_5_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_5_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_5_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_6_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_6_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_6_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_6_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_7_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_7_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_7_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_7_4` text COLLATE utf8_polish_ci NOT NULL,
      `p512_8_1` text COLLATE utf8_polish_ci NOT NULL,
      `p512_8_2` text COLLATE utf8_polish_ci NOT NULL,
      `p512_8_3` text COLLATE utf8_polish_ci NOT NULL,
      `p512_8_4` text COLLATE utf8_polish_ci NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
    This is mysql table. I want to make a script that checks each row of this table. If row is empty do nothing, else create a
    list of:
    Code:
    $p3_1_1_iid   	= $item1;
    		$p512_1_1_image 	= $test_1_1['image'];
    		$p512_1_1_type  	= $test_1_1['type'];
    		$p512_1_1_asize 	= $test_1_1['asize'];
    		$p512_1_1_bsize 	= $test_1_1['bsize'];
    		$p512_1_1_taccp 	= $test_1_1['taccp'];
    		$p512_1_1_prei  	= $test_1_1['praeis'];
    		$p512_1_1_prei2 	= $test_1_1['praeis2'];
    		$p512_1_1_prem  	= $test_1_1['premium'];
    		$p512_1_1_ques  	= $test_1_1['quest'];
    		$p512_1_1_encht 	= $test_1_1['enchtype'];
    		$p512_1_1_uniq  	= $test_1_1['unique'];
    		$p512_1_1_level 	= $test_1_1['level'];
    		$p512_1_1_qual  	= $test_1_1['quality'];
    these as you can see the names are the same as in mysql row only one thing changes there is _image,_iid,_type in the back of $word, so what do i need to make? A script that checks if rows is empty than do nothing else with the same name as row i need to set these $word. but as you can see when in row 512_1_1 is past 512_1_4 it goes back to 512_2_1 but then the two increases by one. Thats why i can't think any ideas. Maybe i writed it more clear this time.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This is a simple matter of using insertion and your primary key. If the primary key is already in use, it will simply reject the data.
    Things like this will never work: $p3_1_+$p512_slots_iid = $item+$p512_slots;. You can not assign to an expression as that is illogical. Instead, you are now assigning a variable to a result of another variable, and then adding it. So that above now becomes logically: $p3_1_ + ($p512_slots_iid = ($item+$p512_slots));. If this is your intent, then this is not a great way of doing it. That reassigns the value of $p512_slots_iid to the value of ($item + $p512_slots) and then for no reason it adds $p3_1_ which won't change anything.
    So as you can see, this syntax is legal in PHP, but it ultimately assigns a variable within the middle which will more likely than not completely destroy the script (and makes it an absolute debugging nightmare). So you'll be scrapping that entire first block and rewriting from scratch since there's nothing of value to use out of it.

    Structure wise, you have a single property primary key. This primary key according to your query is the user_id. So this means a single user can only have one record associated with it. To check if a record exists, you can simply use SELECT COUNT(*) AS cnt FROM items WHERE id=$user_id as your query. Fetch the first resultant and check if its 1 or 0. Or you can just query for regular data and use the mysql[i]_num_rows to count the results.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #7
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Hmm

    As 'Fou-Lu' suggested yes i can check the rows if they are empty or not, but what are you suggesting to do if i want to call a group of $names with diffrent =? As i said earlier if empty do nothing else call a group of $names with the same name as row, only the endings diffrent like _iid,_type?

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I don't understand your question. I can't compare it to the original block either since it doesn't make a lot of sense.
    But the word 'group' would tell me that you need to use a collection such as an array. Index the array with a primary key, and simply push data in it. There's no need to concern yourself with using prepended variable names.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #9
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts
    k, today will try your suggestion Fou-lu. If everything goes like planned it will be big thanks for idea.

  • #10
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by karolismf View Post
    k, today will try your suggestion Fou-lu. If everything goes like planned it will be big thanks for idea.
    WHAT I WANT TO DO:
    $user_id = 0;

    $connect = mysql_connect("localhost", "homework_s1", "864630299") or die("didin't connect");
    mysql_select_db("homework_s1", $connect) or die("didin't select database");

    $sql = mysql_query("SELECT * FROM inventory WHERE id = ".$user_id."");
    $fetch = mysql_fetch_array($sql);

    if($fetch['512_1_1'] == NULL)
    echo "do nothing";
    else
    echo "get the int from 512_1_1";
    echo "mysql_query('SELECT * FROM items where id = '.$fetch['512_1_1'].'');"; // i fully know that this code is written with mistakes i just wanted to give you the idea what i want to do.
    echo "want to get an array with this item data";

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Are you looking to do this for each? If so, you probably have a normalization issue.
    You can simply join your queries for the data you need.
    Code:
    SELECT items.*
    FROM inventory
    INNER JOIN items ON items.id = inventory.p512_1_1
    WHERE inventory.id = $user_id
    If I had to guess it, this should be a many to many between items and users. For that, you need a simpler flattening design. With what you have now, you'd need to either issue multiple queries, or you'd need to do a massive join. If it is a normalization issue, you should be using a table with only two fields in it, a composite key between the items.id and the user_id. I question the datatypes you have in use for this, but I'll keep them as is:
    Code:
    CREATE TABLE IF NOT EXISTS `useritem` (
      `userid` int(11) NOT NULL,
      `itemid` text COLLATE utf8_polish_ci NOT NULL,
      PRIMARY KEY(`id`, `itemid`)
    ) engine=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci
    Now you can easily query for any itemid associated with userid:
    PHP Code:
    $sQry "SELECT items.*
                    FROM useritems
                    INNER JOIN items ON items.id = useritems.itemid
                    WHERE useritems.userid = $user_id"
    ;
    if (
    $qry mysql_query($sQry))
    {
        while (
    $row mysql_fetch_assoc($qry))
        {
            
    printf("%s" PHP_EOL$row['itemDescription']); // or whatever
        
    }

    I can't be 100% sure this is a normalization issue, but so far it looks to be that way. Assuming that it is what I think it is, than with the existing tables it would be cleanest to query for each as much as I hate to suggest that since it would now be issuing up to 33 queries just for the data you have here.
    PHP Code:
    $aRecords = array();
    $sql mysql_query("SELECT * FROM inventory WHERE id = $user_id");
    $fetch mysql_fetch_assoc($sql);
    $keys array_keys($fetch);
    $filtered array_filter($keys);
    $id $filtered['id'];
    unset(
    $filtered['id']);
    // this is a terrible, terrible way to do this.
    foreach ($filtered AS $property)
    {
        
    $sPQry "SELECT * FROM items WHERE id = '$property'");
        if (
    $pqry mysql_query($sPQry))
        {
            
    $aRecords[$id][] = mysql_fetch_assoc($pqry);
        }

    That should give you a multidimensional array with offset x representing the userid, and each record sucked from the items table.
    If that is what you want, than I'd suggest normalizing is a better approach, but like I said I can't be sure that's the case. Not sure if all of those fields should be text type either, but I treated it as such.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #12
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Are you looking to do this for each? If so, you probably have a normalization issue.
    You can simply join your queries for the data you need.
    Code:
    SELECT items.*
    FROM inventory
    INNER JOIN items ON items.id = inventory.p512_1_1
    WHERE inventory.id = $user_id
    If I had to guess it, this should be a many to many between items and users. For that, you need a simpler flattening design. With what you have now, you'd need to either issue multiple queries, or you'd need to do a massive join. If it is a normalization issue, you should be using a table with only two fields in it, a composite key between the items.id and the user_id. I question the datatypes you have in use for this, but I'll keep them as is:
    Code:
    CREATE TABLE IF NOT EXISTS `useritem` (
      `userid` int(11) NOT NULL,
      `itemid` text COLLATE utf8_polish_ci NOT NULL,
      PRIMARY KEY(`id`, `itemid`)
    ) engine=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci
    Now you can easily query for any itemid associated with userid:
    PHP Code:
    $sQry "SELECT items.*
                    FROM useritems
                    INNER JOIN items ON items.id = useritems.itemid
                    WHERE useritems.userid = $user_id"
    ;
    if (
    $qry mysql_query($sQry))
    {
        while (
    $row mysql_fetch_assoc($qry))
        {
            
    printf("%s" PHP_EOL$row['itemDescription']); // or whatever
        
    }

    I can't be 100% sure this is a normalization issue, but so far it looks to be that way. Assuming that it is what I think it is, than with the existing tables it would be cleanest to query for each as much as I hate to suggest that since it would now be issuing up to 33 queries just for the data you have here.
    PHP Code:
    $aRecords = array();
    $sql mysql_query("SELECT * FROM inventory WHERE id = $user_id");
    $fetch mysql_fetch_assoc($sql);
    $keys array_keys($fetch);
    $filtered array_filter($keys);
    $id $filtered['id'];
    unset(
    $filtered['id']);
    // this is a terrible, terrible way to do this.
    foreach ($filtered AS $property)
    {
        
    $sPQry "SELECT * FROM items WHERE id = '$property'");
        if (
    $pqry mysql_query($sPQry))
        {
            
    $aRecords[$id][] = mysql_fetch_assoc($pqry);
        }

    That should give you a multidimensional array with offset x representing the userid, and each record sucked from the items table.
    If that is what you want, than I'd suggest normalizing is a better approach, but like I said I can't be sure that's the case. Not sure if all of those fields should be text type either, but I treated it as such.
    Hmm. I think you are starting to understand me.

    PHP
    Code:
    	$user_id = 0;
    
    $connect = mysql_connect("localhost", "homework_s1", "864630299") or die("didin't connect");
    mysql_select_db("homework_s1", $connect) or die("didin't select database");
    
    $aRecords = array();
    $sql = mysql_query("SELECT * FROM inventory WHERE id = $user_id");
    $fetch = mysql_fetch_assoc($sql);
    $keys = array_keys($fetch);
    $filtered = array_filter($keys);
    $p512_1_1_iid = $filtered[1];		//example, need to do this with all inventory rows!
    unset($filtered[1]);
    // this is a terrible, terrible way to do this.
    foreach ($filtered AS $property)
    {
        $sPQry = ("SELECT * FROM items WHERE id = '$property'");
        if ($pqry = mysql_query($sPQry))
        {
            $aRecords[$id][] = mysql_fetch_assoc($pqry);
        }
    }
    HTML
    Code:
    AddCharDiv("p512_4_4", <?echo $p512_4_4_x;?>, <?echo $p512_4_4_y;?>, <?echo $p512_4_4_type;?>, <?echo $p512_4_4_asize;?>, <?echo $p512_4_4_bsize;?>, <?echo $p512_4_4_taccp;?>, <?echo $p512_4_4_iid;?>, <?echo $p512_4_4_prei;?>, <?echo $p512_4_4_prei2;?>, <?echo $p512_4_4_prem;?>, <?echo $p512_4_4_ques;?>, <?echo $p512_4_4_encht;?>, <?echo $p512_4_4_uniq;?>, <?echo $p512_4_4_level;?>, <?echo $p512_4_4_qual;?>
    AddCharDiv("p512_5_1", <?echo $p512_5_1_x;?>, <?echo $p512_5_1_y;?>, <?echo $p512_5_1_type;?>, <?echo $p512_5_1_asize;?>, <?echo $p512_5_1_bsize;?>, <?echo $p512_5_1_taccp;?>, <?echo $p512_5_1_iid;?>, <?echo $p512_5_1_prei;?>, <?echo $p512_5_1_prei2;?>, <?echo $p512_5_1_prem;?>, <?echo $p512_5_1_ques;?>, <?echo $p512_5_1_encht;?>, <?echo $p512_5_1_uniq;?>, <?echo $p512_5_1_level;?>, <?echo $p512_5_1_qual;?>
    As you can see if i make it each individual with:
    Example
    $sql = mysql_query("SELECT * FROM inventory WHERE id = ".$user_id."");
    $test = fetch_mysql_assoc($sql);
    $item = mysql_query("SELECT * FROM items WHERE id = ".$test['id']."");
    $test2 = fetch_mysql_assoc($item);
    if($test['512_1_1'] == NULL)
    nothing
    else
    $p512_4_4_iid = $test2['id'];
    $p512_4_4_type = $test2['type'];
    ...
    i though about putting the mysql item array to array();
    but still i want a suggestion or example with a better way of checking all arrays and if not null set these
    /*
    $p512_4_4_iid = $test2['id'];
    ...
    if mysql row('p512_5_1' != NULL) //example
    $p512_5_1_iid = $test2['id'];
    ...
    */

    It's annoying if you do for each if, if, if, if and soo on, so i want something auto... for this.
    i was thinking about
    for($s = 1; $s < 9; $s++) {
    for($n = 1; $n < 5; $n++) {
    $string .= "512_".$s."_".$n."<br />";
    }
    }
    Last edited by karolismf; 03-12-2013 at 04:33 PM.

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Hence the need for normalizing data. If you don't, it becomes complicated and you have no alternative but to use a lot of branch control or tricky array construction.
    Based on the needs of the JS function and assuming each of these items comes from the 'items' table:
    PHP Code:
    $aRecords = array();
    $sql mysql_query("SELECT * FROM inventory WHERE id = $user_id");
    $fetch mysql_fetch_assoc($sql);
    $keys array_keys($fetch);
    $filtered array_filter($keys);
    $id $filtered['id'];
    unset(
    $filtered['id']);
    // this is a terrible, terrible way to do this.
    foreach ($filtered AS $k => $property)
    {
        
    $sPQry "SELECT x, y, type, asize, bsize, taccp, iid, prei, prei2, prem, ques, encht, uniq, qual
                    FROM items WHERE id = '$property'"
    );
        if (
    $pqry mysql_query($sPQry))
        {
            
    $row mysql_fetch_assoc($pqry);
            
    array_unshift($row$k);
            
    vprintf('AddCharDiv("%s", %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'$row);
        }

    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #14
    New Coder
    Join Date
    Feb 2011
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Hence the need for normalizing data. If you don't, it becomes complicated and you have no alternative but to use a lot of branch control or tricky array construction.
    Based on the needs of the JS function and assuming each of these items comes from the 'items' table:
    PHP Code:
    $aRecords = array();
    $sql mysql_query("SELECT * FROM inventory WHERE id = $user_id");
    $fetch mysql_fetch_assoc($sql);
    $keys array_keys($fetch);
    $filtered array_filter($keys);
    $id $filtered['id'];
    unset(
    $filtered['id']);
    // this is a terrible, terrible way to do this.
    foreach ($filtered AS $k => $property)
    {
        
    $sPQry "SELECT x, y, type, asize, bsize, taccp, iid, prei, prei2, prem, ques, encht, uniq, qual
                    FROM items WHERE id = '$property'"
    );
        if (
    $pqry mysql_query($sPQry))
        {
            
    $row mysql_fetch_assoc($pqry);
            
    array_unshift($row$k);
            
    vprintf('AddCharDiv("%s", %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);'$row);
        }

    k, i got what you want to say can you explain why are you using these three lines?
    $filtered = array_filter($keys);
    $id = $filtered['id'];
    unset($filtered['id']);

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    $filtered = array_filter($keys); - without a callback, it removes anything equating to false

    $id = $filtered['id']; - That's the userid

    unset($filtered['id']); - We don't want the userid to be a part of the iterative record.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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