Jump to content

Sleeper

Members
  • Posts

    107
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Sleeper's Achievements

Member

Member (2/5)

1

Reputation

  1. After spending some time reading up I was able to use.. echo "<select class='form' name='addlcategory[]' multiple size='5'>\n"; foreach($category as $cat){ if ($cat == $pcategory){ echo "<option value='$cat'>$cat</option>\n"; }else{ $sel = in_array($cat,$categoryname) ? 'selected' : ''; echo "<option value='$cat' $sel>$cat</option>\n"; }} echo "</select>"; Seems to work. Thanks for the help.
  2. Did I say something to scare everyone away or upset them? Post went dead after I asked that last part.
  3. mac_gyver TYVM! that simplified things. I've self tought my self in all I know so I'm a bit short on knowlage in arrays. Still expanding my knowlage on that topic (and many others..lol) One thing I did continue on to notice last night is that I needed to make sure the sub category didn't match the main catagory or it caused a glitched. So I ened up putting in an extra if to make sure if category == pgategory. You asked for some more info on what the variable are so in one example //Existing Categories $category=array(Remote-Start,Remote-Start-Alarm,Accessories); //Preselected additional categories $categoryname=array(Remote-Start-Alarm,Accessories); //Parent Category $pcategory="Remote-Start-Alarm"; echo "<select class='form' name='addlcategory[]' multiple='multiple' size='5'>\n"; $i = 0; while ($i <= ($count-1)) { if ($category[$i]==$pcategory) echo "<option value='$category[$i]'>$category[$i]</option>\n"; elseif ($category[$i]==$categoryname[0] || $category[$i]==$categoryname[1] || $category[$i]==$categoryname[2] || $category[$i]==$categoryname[3]){ echo "<option value='$category[$i]' selected>$category[$i]</option>\n"; }else{ echo "<option value='$category[$i]'>$category[$i]</option>\n"; } $i++; } echo "</select>"; So in this case I would only want the option of Accessories to be preselected as the other is already the parent category. As I will need to read up more on why your coding works, I'm not sure how I would add that into it. Sorry to ask for more help after you allready answered the orginal question, but I hope you don't mind. Thank You in advance. Jim
  4. Ok, I think I'm way over thinking this, and I've been sitting here for hours trying to figure out what I'm missing. Using pdo and php to pull from a data base I want to generate a drop down list and already have any of the items that were alllready selected set as selected. Now I was able to do something like echo "<select class='form' name='subcategory' multiple='multiple' size='5'>\n"; $i = 0; while ($i <= ($count-1)) { if ($category[$i]==$categoryname[0] || $category[$i]==$categoryname[1] || $category[$i]==$categoryname[2] || $category[$i]==$categoryname[3]){ echo "<option value='$category[$i]' selected>$category[$i]</option>\n"; }else{ echo "<option value='$category[$i]'>$category[$i]</option>\n"; } $i++; } echo "</select>"; This works just fine, however the categoryname value is manualy set. I need this to change as well based on how many categoryname options their are. I was able to do ... $A = 0; while ($A <= ($addcount-1)){ $arraytest[]='$category[$i]=='.$categoryname[$A]; $A++; } $arraytest=implode('||', $arraytest); and that generates the "if" list, but I have no idea how to get that into the if statment without breaking it. Any ideas? I'm sure I'm overthinking it here. Thanks in advance.
  5. I see someone else wants to get there post count up and chime in now. Can an admin just remove this post? Cause this is just getting pointless now.
  6. As the person who spent hours fixing the site and the sql I wouldn't say it was the simplest way. Also kicken did give a simple answer. And it wasn't complicated. If requinix wants to ask questions and get the post count up that's fine. However I'm not going to sit here and keep discussing back and forth the questions legitimacy or lack there of. So thank you for your after the fact comments on a topic marked resolved. No reason for anyone else to continue posting at this time. You all have a wonderful Holiday Season.
  7. I love how quick everyone is to judge and call something others are doing as "stupid" or "questionable". The question was very simply put and easy to understand. I wanted to avoid hours of work rebuilding a site that was poorly set up in the first place. They had around 100 tables each table had the same 3 columns, and rather then adding a 4th to show what each one was they wanted each separate as they thought having one table with 70k rows would be slower then 100 separate tables. The entire site was coded to work with this set up. So rather then cleaning up the sql and rebuilding the entire site all cause they wanted to show the total of all the tables I figured there would have to be an easier way of doing it. However seeing as the answers I got were not answers at all, I spent the time to do it the right way and rebuild the sql and the site. So next time when someone ask for help rather then having attitude and stating how "stupid" their coding is how about just answering the question? Some of us may not be "PROS" but where not nubes and sometimes we ask questions because we want help avoiding hours of work that were not getting paid for. After all this is a help site is it not? Thank you to those who helped, and if I offend anyone, well sorry for too. However I know a lot of "nubes" who avoid sites like this because of people who would rather post smart a$$ remarks (to get there post count up) rather then answer the question.
  8. How many I have or what they are for or why so many doesn't have anything to do with answering the question I asked.
  9. I have $sql=mysql_query("SELECT COUNT(*) FROM table1"); echo mysql_result($sql,0); And this works fine. However I want to be able to get the count for multiple tables added together to get the total for all. What I was hoping for was something as easy as $sql=mysql_query("SELECT COUNT(*) FROM table1,table2,table3"); echo mysql_result($sql,0); So that if each table had 10 rows the echo out would show "30". However its not that easy (nothing ever is). So can anyone tell me how to do this in a simple way? I already have a set up that dose $var=mysql_query("SELECT * FROM table1") or die(mysql_error());$varrows=mysql_num_rows($var); However this becomes very cumbersome after counting up the 40th-50th table and not all that easy to edit out if I drop a table. So I'm hoping for a easier way and a less taxing to the server way of adding up the tables. Any Ideas?
  10. Well now I feel rather stupid..lol. I had that coding but I missed the image just went from images->sizes. Guess I'm just blind today. Makes since as to why it didn't work now when I expected it to..lol Thank You.
  11. I guess I don't see your coding working so I'm not doing something right or I'm not explaining correctly. I just want the value for size name="largesquare" You can copy and paist the url to see the actual xml file so you can see how there are many different size option and I want the one that is named largesquare and I don't know how to pull just that info.
  12. I meant to post this in the "php coding help" section. I have re-posted this in that area. We can close or delete this one. Thank You
  13. Hello. I'm trying to pull information out of an xml file. However I'm a bit lost in getting the actual value. $url="http://ws.audioscrobbler.com/2.0/?method=artist.getimages&artist=Dr%20Feelgood&limit=1&autocorrect=1&api_key=c107c9b5c09cb5693b6c19409dd984c1"; $xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA); $largesquare=$xml->images->sizes->size[2]; Is what I have but its not pulling the information. The above url will give you the link to a set xml file for this example. And I want to get the info for the <size name="largesquare" width="126" height="126">http://userserve-ak.last.fm/serve/126s/43173899.jpg</size> I'm sure I'm doing something wrong that's a simple fix but I am lost here. In the sizes there are 6 different size options each with different names and I have no idea how to pull the one with the correct name that I need. Thank you to who ever can help me sort this out.
  14. Hello. I'm trying to pull information out of an xml file. However I'm a bit lost in getting the actual value. $url="http://ws.audioscrobbler.com/2.0/?method=artist.getimages&artist=Dr%20Feelgood&limit=1&autocorrect=1&api_key=c107c9b5c09cb5693b6c19409dd984c1"; $xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA); $largesquare=$xml->images->sizes->size[2]; Is what I have but its not pulling the information. The above url will give you the link to a set xml file for this example. And I want to get the info for the <size name="largesquare" width="126" height="126">http://userserve-ak.last.fm/serve/126s/43173899.jpg</size> I'm sure I'm doing something wrong that's a simple fix but I am lost here. In the sizes there are 6 different size options each with different names and I have no idea how to pull the one with the correct name that I need. Thank you to who ever can help me sort this out.
  15. I am not sure what you mean by either answer. I am still pretty new to most of the php sql things as I teach my self as I go on what I need. So could you be a bit more specific and show an example of what you mean please.
×
×
  • 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.