Jump to content

jandrews

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by jandrews

  1. A letter cannot be a number. Lol Ok character U know what I mean. Thanks tho, that works. Only thing that needed changing was " to '
  2. Hi all, I need to know how to pull all fields from a database where the first letter is any number. How would i do this?
  3. There is only 1 query and it does have or die(mysql_error()); after it. hmmmm.... I can't figure this one out
  4. tried to rearrange that like you said, but it doesnt seem to be that
  5. Hey, Does anyone know why this query would only return one row in a table? <?php require_once('Connections/top50.php'); ?> <?php $maxRows_top50 = 10; $pageNum_top50 = 0; if (isset($_GET['pageNum_top50'])) { $pageNum_top50 = $_GET['pageNum_top50']; } $startRow_top50 = $pageNum_top50 * $maxRows_top50; mysql_select_db($database_top50, $top50); $query_top50 = "SELECT hits, title_music, playlist_music FROM flamplayer_musics ORDER BY hits DESC"; $query_limit_top50 = sprintf("%s LIMIT %d, %d", $query_top50, $startRow_top50, $maxRows_top50); $top50 = mysql_query($query_limit_top50, $top50) or die(mysql_error()); $row_top50 = mysql_fetch_assoc($top50); if (isset($_GET['totalRows_top50'])) { $totalRows_top50 = $_GET['totalRows_top50']; } else { $all_top50 = mysql_query($query_top50); $totalRows_top50 = mysql_num_rows($all_top50); } $totalPages_top50 = ceil($totalRows_top50/$maxRows_top50)-1; mysql_free_result($top50); ?> </p> <table width="100%" cellpadding="3" cellspacing="2"> <tr> <td align="center" bgcolor="#121212"><div align="center">Song</div></td> <td align="center" bgcolor="#121212"><div align="center">Band</div></td> <td align="center" bgcolor="#121212">Plays</td> </tr> <?php do { ?> <tr> <td bgcolor="#666666"><a href="../band.php?music=<?php echo urlencode($row_top50['playlist_music']); ?>" class="style2"><a href="backing_track.php?track=<?php echo urlencode($row_top50['title_music']); ?>"> <?php echo ucfirst($row_top50['title_music']); ?></a></td> <td bgcolor="#666666"><a href="../band.php?music=<?php echo urlencode($row_top50['playlist_music']); ?>" class="style2"><?php echo ucfirst($row_top50['playlist_music']); ?></a></td> <td align="center" bgcolor="#666666"><?php echo $row_top50['hits']; ?></td> </tr> <?php } while ($row_top50 = mysql_fetch_assoc($top50)); ?> </table> Any help would be great.
  6. Thank you very much that works, Here is the code i used: <?php $select = mysql_query("UPDATE`example_table` SET `hits` = `hits`+1 WHERE title_music='{$_GET['track']}'") or die(mysql_error()); ?> :) :)
  7. Hey guys, this can easily sound more complicated than it is, so I'l try to keep it simple. Im building a site that uses dynamic data from a Mysql database and I want the 'hit' column in my existing database table to increment by 1 when a row is queried. Here is my code ( I know all the connections stuff isn't there because they are in a different file which is being included on the same page) <?php $select = mysql_query("UPDATE `example_table` `SET `hits` = `hits`+1 WHERE title_music='['track']'"); ?> As you might expect, it doesnt work. The '['track']' in the code is the url variable. Am I barking up the wrong tree? or is there a better way of doing this?
  8. Wow! We got there in the end. ... and you are right, the trim() isn't needed, actually, it stops the code from working. Thanks Premiso for your time and help best wishes
  9. All I simply want the page to do is echo the error message if the 'Tab' field (which is a text field in my database) is empty ie doesn't contain any data. If however the 'Tab' field does contain text, it is echoed out. simples...
  10. woops, wrong code. here it is... <?php require_once('Connections/artists.php'); require_once('Connections/Tabs.php'); $colname_filename = "-1"; if (isset($_GET['track'])) { $colname_filename = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } $colname_artists = "-1"; if (isset($_GET['track'])) { $colname_artists = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } $colname_Tab = "-1"; if (isset($_GET['track'])) { $colname_Tab = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } mysql_select_db($database_Tabs, $Tabs); $query_Tab = sprintf("SELECT Tab FROM flamplayer_musics WHERE title_music LIKE '%%%s%%'", $colname_Tab); $Tab = mysql_query($query_Tab, $Tabs) or die(mysql_error()); $row_Tab = mysql_fetch_assoc($Tab); $totalRows_Tab = mysql_num_rows($Tab); if (mysql_num_rows($Tab) > 0) { echo $row_Tab['Tab']; } else { echo 'no tabs!'; } ?>
  11. Yes sorry, here is the full code... <?php require_once('Connections/artists.php'); require_once('Connections/Tabs.php'); $colname_filename = "-1"; if (isset($_GET['track'])) { $colname_filename = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } $colname_artists = "-1"; if (isset($_GET['track'])) { $colname_artists = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } $colname_Tab = "-1"; if (isset($_GET['track'])) { $colname_Tab = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } mysql_select_db($database_Tabs, $Tabs); $query_Tab = sprintf("SELECT Tab FROM flamplayer_musics WHERE title_music LIKE '%%%s%%'", $colname_Tab); $Tab = mysql_query($query_Tab, $Tabs) or die(mysql_error()); $row_Tab = mysql_fetch_assoc($Tab); $totalRows_Tab = mysql_num_rows($Tab); if (mysql_num_rows($Tab) > 0) { <?php if (mysql_num_rows($Tab) > 0) { echo $row_Tab['Tab']; } else { echo 'no tabs!'; } ?> } else { echo 'no tabs!'; } ?>
  12. Thanks for the help so far guys. So now i am using this code: <?php require_once('Connections/artists.php'); require_once('Connections/Tabs.php'); $colname_filename = "-1"; if (isset($_GET['track'])) { $colname_filename = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } $colname_artists = "-1"; if (isset($_GET['track'])) { $colname_artists = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } $colname_Tab = "-1"; if (isset($_GET['track'])) { $colname_Tab = (get_magic_quotes_gpc()) ? $_GET['track'] : addslashes($_GET['track']); } mysql_select_db($database_Tabs, $Tabs); $query_Tab = sprintf("SELECT Tab FROM flamplayer_musics WHERE title_music LIKE '%%%s%%'", $colname_Tab); $Tab = mysql_query($query_Tab, $Tabs) or die(mysql_error()); $row_Tab = mysql_fetch_assoc($Tab); $totalRows_Tab = mysql_num_rows($Tab); if (mysql_num_rows($Tab) > 0) { include_once('tab.php'); } else { echo 'no tabs!'; } ?> ... and it displays the tabs for the rows that have tabs in their text field but for the ones without, the error message is not displaying.
  13. A 'tab' is a text field in the database. A tab is basically guitar music notation which is why it is in text. The tab shows on the page on the url variable '?track=example_song_title' This works fine for rows which have a tab in their tab field but for those that don't, I want to include the message, 'no tabs!'.
  14. Just this for now but i will later use this file for other more complex things. <?php { echo ($row_Tab['Tab']); } ?>
  15. Hello all, I am using php to query data from a mysql database and need to know how to code php to say 'if there are no results in this field, include this page' The results that are being queried is a text field the following code just echos the error message 'no tabs!' even though without the if statement, it shows the text in 'tab.php' just fine. <?php if ($results){ include 'tab.php' ; } else { echo 'no tabs!'; } ?> As you can probably guess, I am new to php. What am I doing wrong?
  16. Hi, Its easy enough to display a query with all results beginning with a letter: $query_artists = sprintf("SELECT playlist_music FROM flamplayer_musics WHERE playlist_music LIKE '%s%%' GROUP BY playlist_music ORDER BY playlist_music ASC", ...but what if some of your database entries begin with a number? how do you ask for all results beginning with a number?
  17. You are a legend. Thanks for you're help Just as you said: <tr> <td> <a href="bands.php?=<?php echo $row_artists['playlist_music']; ?>"><?php echo $row_artists['playlist_music']; ?></a></td> </tr> <?php } while ($row_artists = mysql_fetch_assoc($artists)); ?> </table></td> </tr>
  18. OK, I'll try to make as much sense as i can... I have a query which returns the names of various music bands in alphabetical order and it works. With you're help, I have managed to create a link for each result: <a href=<?php echo $row_artists['playlist_music']; ?>"><?php echo $row_artists['playlist_music']; ?></a> This is great because before I couldn't figure out how to do this. Now this gives me the same results hyperlinked with no problem. What I need to know now is how I use these same links but stay on the same page and just have the results link to a url variable of the same name when clicked on. For example, one of the results is Bryan Adams, so when I click on Bryan Adams, I want to see ?artist=Bryan Adams in my url
  19. Yeah exactly, except the php code in the link doesn't seem to working. In other words, I am getting... "http://localhost:8888/bands.php?band=" instead of "http://localhost:8888/bands.php?band=example" in my url.
  20. Brilliant! Thank You. But I don't want the hyperlinks to take the user to a different page, I just want the links to appear as variables in the url so that it will trigger other queries with url variables set. Do you know how to do this?
  21. Hello all, I am quite new to php and I can't seem to figure this one out although i have a feeling the answer is blindingly obvious. Once a query has been made to a database and the results displayed in a table, how would I hyperlink each result to display a different url variable when clicked on? I am sure that the $_Get comes into it somewhere but I'm not sure how to implement this code properly. Any help would be greatly appreciated James
  22. Hello all, I am currently in the process of making a new web site for musicians. The basis of the site is an archive/folder of mp3 files containing the file names: "artist-track.mp3" I have been making static html web-sites for some time and I am fairly new to PHP but I do have some understanding of PHP code. So far, I have made a web-site template which includes a working PHP forum talking to a mysql database. But I struggling to find a way to make my several thousand mp3 tracks easily navigable by artist name and then by track. I need some kind of way (instead of manually integrating thousands of mp3 files) of being able to do the following: 1. An alphabetical navigation bar for querying and displaying all artists by that letter. 2. This artists page will display query results as hyperlinks to take the user to a page for that artist. 3. A page for each artist with a list of their tracks (these query results will be hyperlinked to take the user to a page for that particular track. 4. Once a user has navigated to the page containing a particular track, a flash player will appear on the page to play the mp3 file. 5. A link on the track page to download the mp3 file. I know this is a big ask but I have been trying to figure out a way to do this for some time and any help to point me in the right direction will be greatly appreciated. Thanks James
×
×
  • 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.