Jump to content

tryingtolearn

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by tryingtolearn

  1. Hmm well I must not be doing something right with that I just keep getting a not a valid resource error (Ill be honest - Thats way over my head to even know where to start putting what!) Thanks though.
  2. I will try it out and get back to you. Thanks for responding!
  3. Maybe this will be less confusing. If the database table called temcat_associations is set up like this What would the WHERE clause be to just have tem_id 77 returned? I tried this - just coded in $query = "SELECT tem_id FROM temcat_associations WHERE (tcat_id=54) AND (tcat_id=47) AND (tcat_id=32)"; $result = mysql_query ($query); $num = mysql_num_rows($result); if ($num >=1) { while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { echo "{$row['tem_id']}<br>"; } }else{ echo "No Records Available At This Time.<br><br><br>"; } But still get the No Records Available At This Time If I can get a working where clause on this Im sure I can adapt the previous code...
  4. With And With OR The database its pulling from looks like this The OR returns 75, 76, 77 The AND should return 77 but I get the No Records Available At This Time instead. I also tried it with the where like this WHERE t.tem_approved='Y' AND tca.tem_id=t.tem_id AND tca.tcat_id = c.tcat_id AND ( tca.tcat_id = '32' ) AND ( tca.tcat_id = '54' ) AND ( tca.tcat_id = '47') but got the same result.
  5. What does it do for the users that cant upload? It could be that the file is over the 1MB max file size or the file is not a .jpg???
  6. Still working on my form with checkboxes I have a table full of records Then a table full of categories Then a table to associate the record ID with a Category ID So a record can have multiple categories. ---- Now I have a form that lists all the categories with checkboxes and I want the user to be able to select as many categories as they want and return ONLY the records that have all of the selected categories. This is the code that Im using if (isset($_POST['submitted'])) { if (!empty($_POST['cat_x'])) { $sc = $_POST['cat_x']; } else { $sc = FALSE; echo '<p><font color="red">Please select a Category!</font></p>'; include ('./includes/footer.html'); exit(); // Quit the script. } foreach($sc as $value){ $where_list[] = " tca.id = '".$value."'"; } if(!empty($where_list)) { $where = "AND ("; $where .= implode(" AND ",$where_list); $where .= ")"; } $query = "SELECT DISTINCT t.title FROM templates AS t, associations AS tca WHERE t.approved='Y' AND tca.id=t.id $where"; $result = mysql_query ($query); $num = mysql_num_rows($result); if ($num >=1) { while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { echo "{$row['title']}<br>"; } }else{ echo "No Records Available At This Time."; } }//end if post submitted else{//if post wasnt submitted echo '<div class="Error">We did not receive your search criteria.</div><br>Please <a href="index.php">Try Again</a>'; }//end if post wasnt submitted But if multiple checkboxes are selected It always returns If I change if(!empty($where_list)) { $where = "AND ("; $where .= implode(" AND ",$where_list); $where .= ")"; } to if(!empty($where_list)) { $where = "AND ("; $where .= implode(" OR ",$where_list); $where .= ")"; } The AND to OR It works as expected, It returns all the records that have the selected categories associated with them But I am looking for and exact match Any ideas??
  7. Barrand, Worked perfect as usual! Thanks again for your help.
  8. Hi again, I am trying to preselect all the checkboxes on an edit form if they are part of the record in the database I put this to get an array of categories that pertain to that record being edited. $res2 = mysql_query ("SELECT id FROM cat_associations WHERE tem_id=$tid"); while (list($cat) = mysql_fetch_row($res2)) { if ($cat) $cats=array($cat); } Then the checkboxes are added to the form with this $row1 = array(); $rows = array(); $res = mysql_query ("SELECT id, title, parent FROM categories ORDER BY title"); while (list($id, $title, $parent) = mysql_fetch_row($res)) { if ($parent) $rows[$parent][$id] = $title; else $row1[$id] = $title; } echo "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n"; echo '<tr><td><b>', implode('</b></td><td><b>', $row1), '</b></td></tr>'; echo "<tr valign=\"top\">\n"; foreach ($row1 as $k => $v) { echo"<td>\n"; if (isset($rows[$k])) { foreach ($rows[$k] as $id => $title){ if (in_array($id, $cats)){ echo"<input type=\"checkbox\" name=\"cat_x[]\" value=\"$id\" checked>$title<br>"; }else{ echo"<input type=\"checkbox\" name=\"cat_x[]\" value=\"$id\" >$title<br>"; } } } echo "</td>\n"; } echo "</tr>\n"; echo "</table>\n"; The part that is throwing me is this if (in_array($id, $cats)){ echo"<input type=\"checkbox\" name=\"cat_x[]\" value=\"$id\" checked>$title<br>"; }else{ echo"<input type=\"checkbox\" name=\"cat_x[]\" value=\"$id\" >$title<br>"; } } If the array from the top contains 10 11 12 51 I am only getting the last one (51) checked in the form. Is there a way to have it so it checks all of the boxes in the array? This sounds confusing - I hope I am explaining it OK.
  9. Thanks so much sasa! That first one worked great Thank you for taking the time for me.
  10. This has got me a little closer function navcats ($parent, $level=0) { $res = mysql_query ("SELECT id, title, parent FROM categories WHERE parent = $parent ORDER BY title"); while (list($id, $title) = mysql_fetch_row($res)) { $indent = str_repeat('»', $level); if($level==0){ $title ="<b>$title</b><br>"; $rw = "<td valign=\"top\"> \n"; }else{ $title ="<a href=\"result.php?cat_id=$id\">$title</a><br>"; $rw = " \n"; } echo " $rw $indent $title \n"; navcats2($id, $level+1); } } echo "<table cellspacing=\"0\" cellpadding=\"5\" border=\"5\"> \n"; navcats(0); echo "</table> \n"; I get the results the way I want but the table is not correct <table cellspacing="0" cellpadding="5" border="5"> <td valign="top"> <b></b><br> <td valign="top"> <b>main1</b><br> » <a href="result.php?cat_id=32">sub1</a><br> » <a href="result.php?cat_id=33">sub2</a><br> » <a href="result.php?cat_id=30">sub3</a><br> » <a href="result.php?cat_id=31">aub4</a><br> <td valign="top"> <b>main2</b><br> » <a href="result.php?cat_id=53">sub1</a><br> » <a href="result.php?cat_id=57">sub2</a><br> </table> Any ideas on outputting the correct table code?
  11. Well I read it again and I suppose that isnt what I was looking for anyway. I should have posted the code Im using already This is what I am using to generate the vertical list of Main cats and subcats. Is there a way to modify this to produce - I guess what would be a table. without knowing how many Main categories there will be going across the top. Here is the code Im using now. function navcats ($parent, $level=0) { $res = mysql_query ("SELECT id, title, parent FROM categories WHERE parent = $parent ORDER BY title"); while (list($id, $title) = mysql_fetch_row($res)) { $indent = str_repeat('»', $level); if($level==0){ $title ="<b>$title</b>"; } echo " <li>$indent <a href=\"result.php?cat_id=$id\">$title</a></li>\n"; navcats($id, $level+1); } }
  12. Thanks Mutly I tried it and it gives me this error Any ideas?
  13. Hopefully someone has an idea on how to accomplish this. I have a mysql table called categories 3 fields The ones with 0 as the parent are the main headings or if parent has the value of ID it is a subcat of that title. id title parent 1 A 0 2 B 0 3 C 0 4 zz 2 4 ww 3 I can get it to diplay in a list format but I need something like this A B C zz ww Does that make sense?? All the main headings up top with the subs below the proper main in a column. Can someone offer any advice?
  14. Thanks for checking back, I will have to look at it when I get a little more time, I just keep getting not a valid resource error from the database. But thanks for the info.
  15. Thanks zavaboy Tried it but get
  16. Not sure if this is the correct spot for this question. I am trying a keyword search example I found on the forum (Cant remember where though) It works great except that it picks up on single letters. If I type g I would get green go tough where I would want 0 returned Here is the code - is there something in there that would limit it to complete words instead of single letter or letter combo matches (I was reading about the \b - word boundries but thats in there so I dont think that does what Im thinking it means by the name, bound it to words!!) $query = "SELECT ... AND "; // clean up your search first $search = trim($_POST['keyword']); $search = strip_tags($search); $search = mysql_real_escape_string($search); preg_match_all('|(")([^"]+)\\1|', $search, $groups, PREG_PATTERN_ORDER); preg_match_all('|\b([a-z\d_-]+)\b|i', $search, $words, PREG_PATTERN_ORDER); $like = array(); if (count($groups) > 0) { foreach ($groups[2] as $x) { $like[] = "keywords LIKE \"%$x%\""; } } if (count($words) > 0) { foreach ($words[1] as $x) { $like[] = "keywords LIKE \"%$x%\""; } } $query .= "((" . implode(") OR (", $like) . ")) "."AND ...";
  17. Perfect, thanks for the fast response.
  18. Hi all Hope this is a simple one that I am overlooking. I have a set of pages that use a redirect if the user is not logged in. It will send them to the login page, once logged in it returns them to the page they were trying to access. $_SESSION['redirect] = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; I have a contact section set up - when they get a response to a message they posted they get an email In the email it has a link - click here to read the response http://www.site.com/view_response.php?id=6 When they click the link, it redirects them to the login page but returns them to http://www.site.com/view_response.php How can I pass the id portion so it returns them to the message view rather than the main view page?
  19. OK thanks Havent noticed a differentce yet.
  20. Seems the problem is with the memory_limit setting, It was set to 20M I added an .htaccess line php_value memory_limit 30M And it thumbnails the large images Any drawbacks to doing this?
  21. It is under the max filesize. The image gets uploaded - it just doesnt create the thumb, I just get the broken image. (Im assuming that if the file exceeds the max file size it wont upload - am I wrong in that assumption?) I started using thumbs up http://www.gerd-tentler.de/tools/ When I noticed it happening I thought maybe it was something with that - but it does the same thing with a basic resize script also. I dont get it
  22. Does anyone know if there is a size limit that would prevent a thumbnail from being created with GDlib? I am creating thumbnails on the fly If I load a 600 by 600 image it works but say I load a large image 2288x1712 I dont get the thumb - just a broken image. Just wondering if there would be setting that blocks this.
  23. Nevermind, I got it - I wasnt using the user id so I was getting all the users in the user table.
  24. Hope this is the right forum I have the following code to show a list of all support tickets by selected category. I get two of every result Can anyone shed some light on what I am doing wrong? I use pretty much the same code for the user area so they can see their own tickets (Sorted by their user ID and I only get 1 result for that - But in the admin area I am not using the user ID in the query and I get two of everything) <?php require_once ('../../mysql_connect.php'); // Connect to the database. echo '<p>Select a Category to view</p> <form method="get" action="view_open_support_tickets.php"> <select name="type"> <option value="NULL">Choose a Category:</option> '; $query = 'SELECT * FROM support_ticket_categories ORDER BY category ASC'; $result = mysql_query ($query); while ($row = mysql_fetch_array ($result, MYSQL_NUM)) { echo "<option value=\"$row[0]\">$row[1]</option> "; } echo '</select> <input type="submit" name="submit" value="Go!"> </form> '; if (isset($_GET['type'])) { $type = (int) $_GET['type']; } else { $type = 0; } if ($type > 0) { $query = "SELECT category FROM support_ticket_categories WHERE support_ticket_category_id=$type"; $result = mysql_query ($query); list ($category) = mysql_fetch_array ($result, MYSQL_NUM); echo "<hr /><b>$category Tickets</b><br /> <small>(Recently added tickets are listed first.)</small>\n"; $first = TRUE; // Initialize the variable. $query = "SELECT m.first_name, m.last_name, u.support_ticket_id, status, title FROM users AS m, support_ticket AS u, support_ticket_associations AS ua WHERE u.support_ticket_id = ua.support_ticket_id AND ua.support_ticket_category_id=$type AND ua.approved = 'Y' ORDER BY date_submitted DESC"; $result = mysql_query ($query); while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { // If this is the first record, create the table header. if ($first) { echo '<table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="50%"><b>Title</b></td> <td width="25%"><b>Status</b></td> <td width="25%"><b>Posted By</b></td> </tr> <tr> <td colspan="3"><hr size="1" width="100%"></td> </tr> '; $first = FALSE; // One record has been returned. } // End of $first IF. echo "<tr> <td><a href=\"respond_support_ticket.php?stid={$row['support_ticket_id']}\">{$row['title']}</a></td> <td>{$row['status']}</td> <td>{$row['first_name']} {$row['last_name']}</td> </tr>\n"; } // End of while loop. // If no records were displayed... if ($first) { echo '<div align="center">There are currently 0 Support Tickets in this category.</div>'; } else { echo '</table>'; // Close the table. } } // End of $_GET['type'] conditional. mysql_close(); // Close the database connection. ?>
  25. OK thanks I will try it out and see what I come up with I appreciate the time.
×
×
  • 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.