Jump to content

involuntarydamage

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

involuntarydamage's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I now have the next record(even though it says previous) but I think I'm just missing a part of the process, never had to do this before, its somewhat new to me. $make = "SELECT * FROM category"; $makeresult = mysql_query($make); while($make1 = mysql_fetch_array($makeresult)){ $current_id = $make1['parent_id']; $previous = "SELECT parent_id FROM category WHERE parent_id > $current_id ORDER BY parent_id ASC LIMIT 1"; $previousresult = mysql_query($previous); while($previous1 = mysql_fetch_array($previousresult)){ $previous = $previous1['parent_id']; $i = 1; if($current_id == $current_id){ $i += 1; }if($previous != $current_id ){ $i = 1; } echo $i . ' ' . $previous . $current_id . '<br />'; } }
  2. is there just a huge part to this, that I'm missing here?
  3. Yeah after a few hours I guess I'm just not seeing it
  4. Hey guys I need some help, Im trying to generate a numbered list by using i++ and an if statement but I cant seem to get the values to start over to 0, here is a look at my code $make = "SELECT * FROM category_description ORDER BY category_id ASC LIMIT 1000"; $makeresult = mysql_query($make); while($make1 = mysql_fetch_array($makeresult)){ $parent = "SELECT * FROM category WHERE parent_id = {$make1['category_id']} LIMIT 1000"; $parentresult = mysql_query($parent); while($parent1 = mysql_fetch_array($parentresult)){ if(($make1['category_id'] == $parent1['parent_id']) AND ($make1['name'] == $make1['name'])){ $i += 1; $count = $i; echo "[". $count . "]" . " " . $parent1['category_id'] . " " . $make1['category_id'] . " " . $parent1['parent_id'] . " " . $make1['name'] . "<br />"; Basically the output comes out like this: [1] 100 10 10 Acura [2] 101 10 10 Acura [3] 102 10 10 Acura [4] 103 10 10 Acura [5] 104 10 10 Acura [6] 105 10 10 Acura [7] 106 10 10 Acura [8] 107 10 10 Acura [9] 108 10 10 Acura [10] 109 10 10 Acura [11] 110 10 10 Acura [12] 111 10 10 Acura [13] 112 10 10 Acura [14] 113 10 10 Acura [15] 114 10 10 Acura [16] 115 10 10 Acura [17] 116 10 10 Acura [18] 117 10 10 Acura [19] 118 10 10 Acura [20] 119 10 10 Acura [21] 120 10 10 Acura [22] 121 10 10 Acura [23] 122 10 10 Acura [24] 123 10 10 Acura [25] 124 10 10 Acura [26] 125 10 10 Acura [27] 126 11 11 Audi [28] 127 11 11 Audi [29] 128 11 11 Audi [30] 129 11 11 Audi [31] 130 11 11 Audi [32] 131 11 11 Audi [33] 132 11 11 Audi [34] 133 11 11 Audi [35] 134 11 11 Audi [36] 135 11 11 Audi [37] 136 11 11 Audi [38] 137 11 11 Audi But I need it to come out like this, so basically if Acura = Acura generate 1,2,3,4 etc and if Audi = Audi generate 1,2,3,4......Im still somewhat new to this would really appreciate the help if someone can point me in the right direction: [1] 100 10 10 Acura [2] 101 10 10 Acura [3] 102 10 10 Acura [4] 103 10 10 Acura [5] 104 10 10 Acura [6] 105 10 10 Acura [7] 106 10 10 Acura [8] 107 10 10 Acura [9] 108 10 10 Acura [10] 109 10 10 Acura [11] 110 10 10 Acura [12] 111 10 10 Acura [13] 112 10 10 Acura [14] 113 10 10 Acura [15] 114 10 10 Acura [16] 115 10 10 Acura [17] 116 10 10 Acura [18] 117 10 10 Acura [19] 118 10 10 Acura [20] 119 10 10 Acura [21] 120 10 10 Acura [22] 121 10 10 Acura [23] 122 10 10 Acura [24] 123 10 10 Acura [25] 124 10 10 Acura [26] 125 10 10 Acura [1] 126 11 11 Audi [2] 127 11 11 Audi [3] 128 11 11 Audi [4] 129 11 11 Audi [5] 130 11 11 Audi [6] 131 11 11 Audi [7] 132 11 11 Audi [8] 133 11 11 Audi [9] 134 11 11 Audi [10] 135 11 11 Audi [11] 136 11 11 Audi [12] 137 11 11 Audi
  5. Hey guys Im using this php script to try and help me build easy javascript lines for my site that is in asp and we do not have microsoft sql db access so it all basically has to be entered manually. Everything right now works, script demo is http://www.intimegraphics.com/phptest/script2.html and basically what I need to is to change options[1789]=new Option("L SERIES","http://www.intimegraphics.com/category_s/14104.htm"); options[1789]=new Option("S SERIES","http://www.intimegraphics.com/category_s/14105.htm"); options[1789]=new Option("SC","http://www.intimegraphics.com/category_s/14106.htm"); options[1789]=new Option("VUE","http://www.intimegraphics.com/category_s/14107.htm") To read more like this instead of 1789 1789 1789 1789 to more like 1 2 3 4 but only when its equal to 1789 1789 1789 1789 options[1]=new Option("L SERIES","http://www.intimegraphics.com/category_s/14104.htm"); options[2]=new Option("S SERIES","http://www.intimegraphics.com/category_s/14105.htm"); options[3]=new Option("SC","http://www.intimegraphics.com/category_s/14106.htm"); options[4]=new Option("VUE","http://www.intimegraphics.com/category_s/14107.htm") I also need to change function Year2002(aMenu){ to read from the root list of vehicles, so instead it would be function SaturnYear2002(aMenu){ this isnt as important but would defintely like to get the first one fixed Here is the full php script right here, if anyone can help I would really really appreciate it as Im pushing my php to the max lol thanks <?php $nav_query = mysql_query("SELECT * FROM `cm2year` ORDER BY `catid`"); $tree = ""; // Clear the directory tree $depth = 1; // Child level depth. $top_level_on = 1; // What top-level category are we on? $exclude = array(); // Define the exclusion array array_push($exclude, 0); // Put a starting value in it while ( $nav_row = mysql_fetch_array($nav_query) ) { $goOn = 1; // Resets variable to allow us to continue building out the tree. for($x = 0; $x < count($exclude); $x++ ) // Check to see if the new item has been used { if ( $exclude[$x] == $nav_row['catid'] ) { $goOn = 0; break; // Stop looking b/c we already found that it's in the exclusion list and we can't continue to process this node } } if ( $goOn == 1 ) { $tree .= "Year". $nav_row['catname'] . "<br>"; // Process the main tree node array_push($exclude, $nav_row['catid']); // Add to the exclusion list if ( $nav_row['category_id'] < 6 ) { $top_level_on = $nav_row['catid']; } $tree .= build_child($nav_row['catid']); // Start the recursive function of building the child tree } } function build_child($oldID) // Recursive function to get all of the children...unlimited depth { global $exclude, $depth; // Refer to the global array defined at the top of this script $child_query = mysql_query("SELECT * FROM `cm3model` WHERE parentid=" . $oldID); while ( $child = mysql_fetch_array($child_query) ) { if ( $child['catid'] != $child['parentid'] ) { for ( $c=0;$c<$depth;$c++ ) // Indent over so that there is distinction between levels { $tempTree .= " "; } $tempTree .= "options[" . $child['parentid'] ."]". "=new Option" . "(\"" . $child['catname'] ."\"" . "," . "\"http://www.intimegraphics.com/category_s/" . $child['catid']. ".htm\")<br>"; $depth++; // Incriment depth b/c we're building this child's child tree (complicated yet???) $tempTree .= build_child($child['catid']); // Add to the temporary local tree $depth--; // Decrement depth b/c we're done building the child's child tree. array_push($exclude, $child['catid']); // Add the item to the exclusion list } } return $tempTree; // Return the entire child tree } echo $tree; ?>
×
×
  • 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.