Jump to content

Michan

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

Everything posted by Michan

  1. Hi, I've created some code to display the first entry entry in a chart of 10 videogames. Now, this code will stay exactly the same for the second entry, but instead of the row being 's1', it will be 's2', and so on for the rest of the chart. But I can't find a way to produce the second entry (s2) without reproducing the entire code due to the value in the query... Reproducing this ten times would be incredibly clunky so I was wondering if there would be an easier way? (Also, is my code for producing the dates okay? It's hand-made.) [code] $chart = mysql_query('SELECT * FROM vg_charts LEFT JOIN vg_games ON vg_charts.s1=vg_games.id WHERE type=1 ORDER BY date DESC limit 0, 1'); while ($ukchart = mysql_fetch_array($chart)) { $release=$ukchart['release_date']; $rday = substr($release, 8, 2); $rmon = substr($release, 5, 2); $ryea = substr($release, 0, 4); if ($rmon == "01") $rmon = "Jan"; elseif ($rmon == "02") $rmon = "Feb"; elseif ($rom == "03") $rmon = "Mar"; elseif ($rmon == "04") $rmon = "Apr"; elseif ($rom == "05") $rmon = "May"; elseif ($rmon == "06") $rmon = "Jun"; elseif ($rom == "07") $rmon = "Jul"; elseif ($rmon == "08") $rmon = "Aug"; elseif ($rom == "09") $rmon = "Sep"; elseif ($rmon == "10") $rmon = "Oct"; elseif ($rom == "11") $rmon = "Nov"; elseif ($rmon == "12") $rmon = "Dec"; if (!$release) $rdate = "Release date N/A"; elseif ($release=="0000-00-00 00:00:00") $rdate = "Release date N/A"; else $rdate = $rday."&nbsp;".$rmon."&nbsp;".$ryea; echo (' <div id="home-chart-item1"> <div id="home-chart-item1rank" style="color: #5C5C5C">1<BR><img src="gfx/chart_new.gif"></div> <div id="home-chart-item1box"><a href="gamepage/'.$ukchart['id'].'"> <img src="'.$ukchart['image'].'" border="0" width="36" height="50"> </a> </div> <div id="home-chart-item1text"><a href="gamepage/'.$ukchart['id'].'">'.$ukchart['name'].'</a><BR>'.$ukchart['publisher'].'<BR><span style="color: #949494">'.$rdate.'</span> </div> </div> '); } [/code] Many thanks in advance :) -Mi
  2. Thanks for your help Roopurt. I'm not sure I understand your question, however. Each topic is a row in that table, and it's just selecting everything but 53 (with the != not equal to), so it just returns every other topic (including 33). Sorry if I haven't got your question, but I'm still very new to PHP (and also it's 3:30 AM XD), but your help is exactly what I was looking for. Thank you very much :)
  3. Well right now, I'm just using the WHERE function to !hide any result which has a forum_id of '53', but I'm hoping to be able to hide a result with a different forum_id, as well as that.
  4. forum_id defines the forum (for example, "Mods Lounge" or "Senior Lounge"). 85, 86, 88, 90, and 93 are the forums I'd like to hide in addition to 53. Thanks! ;D
  5. Hi, I'm trying to display recent forum topics on a homepage. But what if I want to hide topics from more than one forum? [code] $forum = mysql_query('SELECT title, tid FROM ibf_topics WHERE forum_id!= 53 ORDER BY last_post DESC LIMIT 0, 1'); [/code] The above code hides any posts from one of the moderator-only forums, but there are more than one, and I need to hide them all. The other forums I need to hide are: 85, 86, 88, 90, 93 How can I hide all of these? I've been looking around for a solution for ages, but can't find anything. My guess is that it's pretty straightforward, and I'm just missing something. XD Many thanks~!
  6. Sorry Chris, it doesn't work :( Here is the error: [quote]Fatal error: Call to a member function get_all() on a non-object in index.php on line 242[/quote] Line 242: [code]$media = $turbo->get_all("SELECT files.file AS file,[/code]
  7. Chris, it's so that files can be linked to multiple albums, like |XXXX|XXXX| etc. However, we never had a use for it... But now there are 15,000+ rows in the database, and the current site is relying on seeing the "|" symbol. So I've been forced into finding other ways of doing it >_>;; I can't figure out how to strip the | symbols, however. I guess it would be something similar to this..? [code]$bars = "\|"; $removebars = ""; $media = $turbo->get_all("SELECT files.file AS file, files.album = ereg_replace($bars, $removebars, files.album) AS album, files.timestamp AS timestamp, albums.id AS id, albums.directory AS directory, FROM files LEFT JOIN albums ON files.album=albums.id GROUP BY files.album ORDER BY files.timestamp DESC"); while($latestmedia = mysql_fetch_array($media)) { echo ('...[/code] I know I'm wrong however, as it brings me an error. I'm really new to PHP, so if someone could lend me a hand here, I'd appreciate it :-[
  8. Ah, thanks Chris, I understand what do do now, but how would I get about putting that into PHP? (Sorry, I'm really just a beginner, and I'm still not entirely sure of what I can and can't do.)
  9. Sure, here is the latest record: [quote]id        name    file            album      type      timestamp                  size        description 15311    000      000.JPG      |1763|    image    2006-10-24 15:05:32    34775[/quote] Which should match with: [quote]id      name                          directory 1763  Guilty Gear Judgement    Guilty Gear Judgement[/quote] The HTML I get is: [code]<a href="downloads//000.JPG" target="image"><img src="downloads//000.JPG" border="0" width="114" height="84"></a> </div> <a href="?view=image_gallery&album=1763"><div id="home-media-select"> <div id="home-media-l"></div> <div id="home-media-text">More for this game</div> <div id="home-media-r"></div> </div></a>[/code]
  10. Chris, It's now displaying the same result as earlier; the latest row, but without the 'directory'! I've also just tried using my n00bish PHP skills to write things like '.$latestmedia['files.file'].' but that just destroyed everything, so I've reverted back to what I had initially...
  11. Chis, That delivers the first row in the database, and still no 'directory', unfortunately! :(
  12. [quote author=cmgmyr link=topic=113361.msg460597#msg460597 date=1162311052] If you are matching up the album names wouldn't it be: $media = mysql_query('SELECT * FROM files LEFT JOIN albums ON (files.album=albums.name) ORDER BY timestamp DESC LIMIT 0, 1'); [/quote] Basically I'm trying to get the file 'album' value to match the albums 'id' value, then return the albums 'directory'; the 'name' column is irrelevant as that's to do with what will be displayed on the actual page for the album (this data is just for the homepage itself). [quote author=cmgmyr link=topic=113361.msg460597#msg460597 date=1162311052] ...what you should do is make another key in files (a_id) for album id then it can be (files.a_id=albums.id) which would make it a lot easier [/quote] I'm doing that for all of my tables, but what I have to work with is this, and I can't really change it (as much as I'd like to) as the site is already running off these databases and don't even want to begin touching any of the existing code, as it's a total mess (hence the new code XD). There are over 12,000 rows in files, and over 1,500 in albums. :( There surely must be a way to be able to do this with the existing tables though?
  13. [quote author=Destruction link=topic=113361.msg460588#msg460588 date=1162310322] You're only selecting all fields from files, you need to do something like SELECT * FROM files, albums LEFT JOIN albums ON[/quote] I have tried this, but I get shouted at by my server: [quote]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in index.php on line 241[/quote] FYI, line 241 is: [code]while($latestmedia = mysql_fetch_array($media))[/code] My database structure is below: [b]files[/b] id (primary) name file album type timestamp size description [b]albums[/b] id (primary) name directory The ones I need are, from files, 'file', 'album', (and 'timestamp' to order) and from albums, 'directory' (as well as 'id' to define the row). Many thanks!
  14. Thanks Chris, I tried doing as you said by using the brackets (and removing the WHERE), but it still isn't returning the 'directory'. It displays the 'file' and 'album', however. I can provide you with the table structures, if you like? Thanks in advance :)
  15. Hi there, I'm having problems joining two databases together; I can't seem to pluck data from the second one. I'm new to PHP and if you could highlight what I'm doing wrong and what I'd need to do to correct myself, I'd be very appreciative. [code]$media = mysql_query('SELECT * FROM files LEFT JOIN albums ON files.album=albums.id WHERE ORDER BY timestamp DESC LIMIT 0, 1'); while($latestmedia = mysql_fetch_array($media)) { $displaymedia=(' <div id="home-media-image"> <a href="/'.$latestmedia['directory'].'/'.$latestmedia['file'].'" target="image"><img src="/'.$latestmedia['directory'].'/'.$latestmedia['file'].'" border="0" width="114" height="84"></a> </div> <a href="?view=image_gallery&album='.$latestmedia['album'].'"><div id="home-media-select"> <div id="home-media-l"></div> <div id="home-media-text">More for this game</div> <div id="home-media-r"></div> </div></a> '); $bars = "\|"; $removebars = ""; echo ereg_replace($bars, $removebars, $displaymedia); }[/code] (The ereg_replace is to remove the "|" symbol from items in that row. The albums come up as "|XXXX|" for example.) Many thanks!
×
×
  • 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.