Jump to content

adzie

Members
  • Posts

    173
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    United Kingdom

adzie's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Sorry for dragging this up, never saw the response Muddy_Funster Yes that in essence is it.
  2. I don't think I was very clear before hand with the table structures Table one - member_awards member_id then a column for each award_id(in table 2) - this will be 1 if they have the award 0 if they don't Table two - awards award_id award_desc
  3. Ok ignore my code then. Those two tables, how would I get the result to show which ones the member has and limit it to a maximum of 5
  4. Hello all, I've inherited a rather awkward table that cannot be changed and so I need some help to limit the results. Table one - member_awards member_id then a column for each award code Table two - awards award_id award_desc $awardCodes = mysql_query("SELECT * FROM `member_awards` WHERE `member_id` = 1"); $awardsres = mysql_fetch_assoc($awardCodes); $awards = mysql_query("SELECT * FROM `awards` ORDER BY 'award_id' ASC"); while ($ac2 = mysql_fetch_assoc($awards)) { $ac22 = db_entry_check($awardsres[$ac2[award_id]])? 1 : 0; if ($ac22 != $actual && $ac22 == 1) { // DO something } } Table 1 has 20 columns, 0 if they don't have the award 1 if they do. I need to pick out 5 where they do have the award ie the column result is 1. This is where i'm getting stuck. Any points would be appreciated
  5. Hello all, Appreciate your advice as i've hit a wall now Table 1 - user_awards award_id award_title Table 2 - awards user_id (a column for each award_id) 0 = no, 1 = yes I'd like to ideally create a result where it then displays all the records where the column in table 2 is 1 but I want to limit it to say 5 where the user_awards table = 1, however at present it counts five including entries where its 0. This is where i'm getting unstuck so appreciate any advice. Code snippet below. $awardCodes = mysql_query("SELECT * FROM `user_awards` WHERE `user_id` = 1"); $awardsres = mysql_fetch_assoc($awardCodes); $awards = mysql_query("SELECT * FROM `awards` ORDER BY 'award_id' ASC LIMIT 4"); // Loop through award codes while ($ac2 = mysql_fetch_assoc($awards)) { $ac22 = db_entry_check($awardsres[$ac2[award_id]])? 1 : 0; if ($ac22 != $actual && $ac22 == 1) { echo "$ac22[award_title]"; } }
  6. Sorry I should have maybe said I need a result id or count for the user_awards table and not the award table if that helps. Best regards
  7. Hello all, I'm struggling adding a count result to this script. I want each result to be an id so I can place x amountof images in one position and the remaining in another position. Each user might have different awards so just using the award_id is no good as there will be empty space so I need the actual result to display a id number. $res = mysql_query("SELECT award, image FROM awards WHERE active = '1'"); $codes = array(); while ($row = mysql_fetch_assoc($res)){ $codes[$row['award']] = $row['image']; } $userid = '1'; $res = mysql_query("SELECT * FROM user_awards WHERE user_id = '$userid'"); $row = mysql_fetch_assoc($res); foreach ($codes as $award => $image){ if ($row[$award] == 1){ echo "<img src=../$image><br/>"; } }
  8. Sorry for bringing this back to top again, does anyone have an example or suitable tutorial that would work with the examples HuggieBear gave a few posts back? Many thanks
  9. Thanks Don't have a link to an example that would work with the above, keen to learn this and not just take your work although the examples are a bonus
  10. Excellent, thats certainly giving me the result I want, and I assume I can put more fields into the result should I need to? foreach ($codes as $code => $award) I've now got the award code showing which is what I need for the image to display. As I said before ideally each result will have an id, not a html one but a result if you like, my previous code was something like below. $a being horizontal position and $b being vertical position. Like I said before I want to display the first 4 results on one row and the next 5 on the second row and then next 5 on the third row etc. Potentially upto 20+ awards. Hope that makes sense. So the code below achieved that but with the new code i'm not sure how to implement a potential count as suggested. Before even if the award wasn't in the log table it still created an empty space the new code you have given me stops that but obviously I need a way of counting each result so that I can then space it correctly. Thanks // now to the results if ($number > 0) { // for each award result for ($i=0; $i<$number; $i++) { // Set the layout of the awards if ($i <=3 ) { $as = $i + 1; $as2 = $as * 50; $a = $as2 + 20; $b = 40; } elseif ($i >= 4 and $i <= { $as = $i -4; $as2 = $as * 50; $a = $as2 + 20; $b = 55; }
  11. Brilliant!! Definetly moving towards the right Direction, Thank you HuggieBear. Rather simple compared to the 100 + lines I had for a similar result. What I had done previously was to search for each award where it was active and the for each row check against the table which is rubbish and very messy. Would it be possible though using the example supplied above to give each result an ID or number, not the id in the database, but an id so result 1,2,3 etc so if I have two awards only id 1 and id 2 but if I have 4 id1, id2, id3, id4. The reason is I want to place images next to each other but after image5 I want to place it on another row, so need the id number to work with the spacing code I have. Then the next problem is rather than printing the title I would need to print the award from the top table ie orange to select the correct image. Once again thanks for your help
  12. Thats similar to how I had the original. but I really wanted to keep the user ids awards on one row rather than multiple rows.
  13. Hi guys Long time no post. Firstly is this possible, and can anyone point me in the right direction. I have two tables as below and I want to display only the results that are active against the master table. Table1 - Awards awardid award code active 1 Apple AFC 1 2 Orange OOC 1 3 Lemon LSO 1 Table 2 - Log userid AFC OOC LSO 1 1 0 0 2 1 1 1 The problem i'm facing is I can get the results from table 1 where active = 1 which is great and then return each row. however I only want to return the row where the user has that award for example user 1 only has the AFC. Any guidance as always appreciated. Many thanks
  14. Hello all, Building a dynamic signature for my forums, fairly simple... or so I thought! Sorry for posting this here but thought it was probably the most applicable forum. I get the image displayed, the db results show exactly how and where I want them, great. Now to complicate things I want to put images on the image dependant on what groups the user belongs to. To further complicate things the DB inherited shows the groups in one field as 1:2:3:4 where each number is a group. Below is the code so far, if I set $groups to equal the field results of 1:2:3:4 how can I get that to show them as individual images so 1 = group1.gif 2 = group2.gif etc and then overlay those images over the main image. code below, any suggestions to improve the script or the way to hold multiple group values in once field appreciated! <? error_reporting(E_ALL); ini_set('display_errors', 1); $query = "SELECT * FROM users WHERE name='adzie'"; $result = mysql_query($query); $user22 = mysql_fetch_row($result); $group = "Forum User"; $name = "$user22[2]"; $title = "$user22[1]"; header("Content-type: image/gif"); $calc = $groups; $im = imagecreatefromgif("signature.gif"); $color = imagecolorallocate($im, 0,12,47); $txt = (imagesx($im) - 46 * strlen($calc)) / 2; $txt1 = (imagesx($im) - 46 * strlen($calc)) / 2; imagestring($im, 3, $txt, 15, $name, $color); imagestring($im, 3, $txt1, 25, $title, $color); imagegif($im); imagedestroy($im); ?>
×
×
  • 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.