Jump to content

thepip3r

Members
  • Posts

    289
  • Joined

  • Last visited

    Never

Everything posted by thepip3r

  1. even after you filled out the form and submitted information? did you make the change to your submit button?? if not, you need to change: <input type=submit value='Create'></form>"; to <input type=submit name='create' value='Create'></form>"; then try it out and see what iterateArray shows u.
  2. @axeia: so you're advocating only using print_r() for brevity?? ...over simply having an "array iteration" function that gives you the best answer? i simply always include my functions list that has my "iterateArray()" and then it's nothing more than a few xtra chars to write. and if it's those couple xtra chars, just go: ia($_POST); function ia($arr) { echo "<pre>"; print_r($arr); echo "</pre>"; } viola, shorter than print_r(); =P
  3. i was once in your shoes my friend. i come back often myself to post and while i'm waiting for assistance with my problems, i answer others to kind of, "give back to the community." hopefully you'll do the same someday. =P
  4. 1. might want to take out the password info to start... 2. <input type=submit value='Create'></form>"; u have a VALUE for your submit button but no NAME so your if $_POST['create'] code is probably never firing. use: iterateArray($_POST); function iterateArray($arr) { echo "<pre>"; print_r($arr); echo "</pre>"; } at the top of your page to see what your POST array looks like after a submit is checked to ensure all of your data is being passed correctly.
  5. while ($a_row = sqlFetchArray($res)) { $records[$c]["id"] = $a_row["id"]; $records[$c]["articleid"] = $a_row["articleid"]; $records[$c]["filename"][] = $a_row["filename"]; } viola! now your $records[$c]["filename"] is an array. it may hold ONE entry or it may hold 1million!! (/pinky-to-lip) regardless, just use a foreach loop on $records[$c]["filename"] and it will always display the correct number of file names despite how many articles there are for it.
  6. well the logic is simple, i don't know what to tell you except change ur code to see what your problem is when the conditional is firing when it's not supposed to be: if($row['blogcount'] >= 3) { echo "rowcount: $row[blogcount] <br>"; echo "You are only allowed to Have 3 entries to your blog at any one time. If you would like to update your blog please delete one of the older entries."; } else{ echo "rowcount: $row[blogcount] <br>"; echo"
  7. if ($i % 8 == 0) { #insert tab, line-feed, whatever }
  8. trim $pt_name to ensure that there's no " " -- or blank space entry which is causing the var to have data, it's just a blank character.
  9. instead of tabbing to a new line why not use the new line, character feed??? \n\r Edit: remember that tabs have nothing to do with new lines. the fact that some text editors WRAP lines after a certain amount of characters has nothing to do with line termination, has to do with visible line space. =D
  10. did u echo $row['blogcount'] to see if ur getting the results u expect? if you're not, you can either TS that or just run a SELECT SQL query and use mysql_num_rows() to count the number of results... i'd also use if($row['blogcount'] >= 3) { your failure echo statement executes EVERY time unelss the user has submitted 3 entries for that day.
  11. yes...trim $value before the conditional and that will protect u from the issue u just presented.
  12. your loops are fine.. i use 3-5 nested loops regularly but as jake pointed out above, you need to control your resultset. only limit your results to 20-50 and make a (next,previous) button to provide a method to the user to get the next set of results.
  13. ... foreach($catagories as $value) { if ($value !== "") { $q = "INSERT INTO " . CAT_TABLE . "(cat_name) VALUES ('$value')"; $result = mysql_query($q); } }
  14. explode on pipe (|), trim() all whitespace, implode with the desired whitespace -- although, your data resulting like that points to something else not trimming white-space initially - might want to start there. =P
  15. so if this is part of my multi-array: [submitters] => Array ( [14] => Array ( [first_name] => Don [last_name] => Cheadle [company] => Hotel Rwanda [timestamp] => 1238803296 [satisfaction_level] => 0% ) [13] => Array ( [first_name] => Jack [last_name] => Black [company] => Horribad Inc. [timestamp] => 1238803244 [satisfaction_level] => 12.5% ) [12] => Array ( [first_name] => Mark [last_name] => Wahlberg [company] => Shooters R Us [timestamp] => 1238803181 [satisfaction_level] => 50% ) [11] => Array ( [first_name] => Keanu [last_name] => Reeves [company] => Matrix Unlimited [timestamp] => 1238802082 [satisfaction_level] => 62.5% ) [10] => Array ( [first_name] => Rhona [last_name] => Mitra [company] => Hawtness [timestamp] => 1238802020 [satisfaction_level] => 100% ) [9] => Array ( [first_name] => Cameron [last_name] => Wilson [company] => NewGeo [timestamp] => 1238801573 [satisfaction_level] => 25% ) [8] => Array ( [first_name] => John [last_name] => Candy [company] => Big Guys R Us [timestamp] => 1238777161 [satisfaction_level] => 81.25% ) [7] => Array ( [first_name] => Christina [last_name] => Aguillera [company] => Hawtness [timestamp] => 1238777105 [satisfaction_level] => 100% ) [6] => Array ( [first_name] => Jessica [last_name] => Beall [company] => Hawtness Inc. [timestamp] => 1238777064 [satisfaction_level] => 100% ) [5] => Array ( [first_name] => BillyBob [last_name] => Thornton [company] => Crazy Co. [timestamp] => 1238777034 [satisfaction_level] => 50% ) [4] => Array ( [first_name] => Morgan [last_name] => Freeman [company] => Seven Co. [timestamp] => 1238776980 [satisfaction_level] => 100% ) [3] => Array ( [first_name] => Emin [last_name] => Em [company] => 8 Miles of Horribad [timestamp] => 1238776932 [satisfaction_level] => 0% ) [2] => Array ( [first_name] => Gwen [last_name] => Stephanie [company] => Lots of Doubt [timestamp] => 1238776901 [satisfaction_level] => 50% ) [1] => Array ( [first_name] => Tom [last_name] => Sellek [company] => Three Men Inc. [timestamp] => 1238776878 [satisfaction_level] => 100% ) ) can i sort the "submitters" dimension by, say the last_name of the numbered dimension? i've played around with array_multisort() but am having problems with the results.
  16. as fenway was pointing out, those references are to table aliases, they have no correlation in PHP. to explain aliases, look at this example: SELECT p.pid, p.number, p.blah, p.own, p.own2, u1.id, u1.name, u1.test, u1.blah FROM pages p inner join users u1 on (p.own=u1.id) inner join users u2 on (p.own2=u2.id) really how SQL reads that is: SELECT pages.pid, pages.number, pages.blah, pages.own, pages.own2, users.id, users.name, users.test, users.blah FROM pages p inner join users u1 on (pages.own=users.id) inner join users u2 on (pages.own2=users.id) ...and as you can see, the former is MUCH shorter (and this is a small example). with large joins and large table names, abbreviated aliases can immensely cut down on your SQL query string length. aliases do nothing but make it easier and less complicated to construct SQL statements. i'll give you another hint on troubleshooting. WHENEVER I'M DEALING WITH ARRAYS, I use the following function: iterateArray($row); function iterateArray($arr) { echo "<pre>"; print_r($arr); echo "</pre>"; } this will graphically display the array you're trying to parse to the screen so you can see what data is being returned to PHP -- VERY useful. and to include this in your example, try: mysql_connect("localhost","user","pass"); mysql_select_db("database"); $result = mysql_query("SELECT * FROM pages as p inner join users as u1 on (p.own=u1.id) inner join users as u2 on (p.own2=u2.id) "); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { iterateArray($row); } function iterateArray($arr) { echo "<pre>"; print_r($arr); echo "</pre>"; }
  17. @fenway -- i'm sorry for wasting ur time. with help, i was pointed to the fact that i have no relation to the submitter and their answers. o.O i'm sorry for such a basic mistake, i don't know why i didn't see it before. i'm going to have to add a field to the answers section so i'll know how submitted them and redo some of my other queries -- sorry again for the waste of time and ty greatly for the attempt to help.
  18. well reading your query error you're using mysqli_query() and the error for mysqli_fetch_assoc is telling you that it's expecting mysqli_result() instead. soz but that's about as far as i can go as i'm not familiar with the mysqli family functions.
  19. ok... last ditch effort to try to explain this -- here is the basic relational hierarchy I'm trying to achieve in a single query: smid = survey ids ssid = survey submitter ids sqid = survey questions ids sqaid = survey question answers ids smid / \ ssid sqid \ sqaid so the basic logic behind it is that when a user submits a query for a particular survey, they will get all of the survey name, the survey submitter name, the survey questions, and the answers for each question. my problem is that once i add that third join (no matter how i structure it), my resultset is always incorrect information in a full-mesh type scenario: users informations is being shown next to data that they did not submit -- and not only that, each user is shown as answering the same answers everyone else did as well as their own; and again, this is ONLY when I include that last join. <scratching head> -- is there a way to achieve the diagram above with the resultset below in a single query? [surveyname, surveysubmissionid, submittername, surveyquestion, surveyquestionanswer] basicsurvey, 1, tim, how old are u, 12 basicsurvey, 1, tim, where do u live, cali basicsurvey, 1, tim, how many sibs?, 3 basicsurvey, 2, nancy, how old are u, 80 basicsurvey, 2, nancy, where do u live, tex basicsurvey, 2, nancy, how many sibs?, 0 basicsurvey, 3, steve, how old are u, 55 basicsurvey, 3, steve, where do u live, ga basicsurvey, 3, steve, how many sibs?, 2 have i made my case clear enough? do i have to break this up into two queries? pls help!
  20. try: SELECT * FROM pages, users WHERE pages.own=users.id OR pages.own2=users.id edit: the problem with your logic is that your going to have to pull multiple records in this query because of how you have your columns configured (specifically own and own2). Trying to use the same query with an ANDing operator will never apply except when you have a single entry where Bob Smith and George Washington are listed.
  21. Ultimately, forget what you think you're trying to do, what data are you actually trying to join? Using this: ...and this is assuming that from your query, pages.own is a field in the pages table that holds the corresponding id of the user from the users table! SELECT * FROM pages, users WHERE pages.own=users.id that query will pull all records from both tables where the two id fields (own and id) correspond.
  22. if your query is working and all other data besides the IP is being added into the database, then mysql doesn't see a problem with your query -- are u sure there's actual data in the $_POST, $_GET or $_SERVER variable you're passing to the section of mysql that is attempting to add the IP to your DB? echo out your sql statement and see if the var is showing a blank entry.
  23. to select all data from all tables that you listed in your initial post, this is what I would do because i'm much more familiar with joins than i am subqueries. Well i have to modify your table structure since table2 doesn't have any association to anything. Also you data sets are confusing w/o descriptions so i'm going to make some relational data fields so you can see how associations work: table -> columns people (pid, first_name, last_name, mid_name) locale (lid, pid, address, city, state) contact (cid, pid, email, phone) SELECT * FROM people JOIN locale ON (locale.pid=people.pid) WHERE people.first_name='Larry' this would pull (pid, first_name, last_name, mid_name, lid, pid, address, city, state) from both tables where the first_name is Larry. If you want data from all three tables: SELECT * FROM people JOIN locale ON (locale.pid=people.pid) JOIN contact ON (contact.pid=people.pid) WHERE people.first_name='Larry' AND locale.state='FL' this would pull back EVERY column from all three tables for all Larrys who live in Florida. does that make more sense with how to build relationships between the tables? we've put a "pid" or "peopleid" field into the other two tables because that is how the data is associated. the locales and contact information is SPECIFIC to those people so we must have a way to differentiate that in a clear and concise manner.
  24. close... but this is not a join. if 'table2sub' really exists in table one, then you're never really correlating data from table 2 in any way. SELECT * FROM table1 WHERE table2sub='$table2id' ORDER BY tabname
×
×
  • 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.