Jump to content

bradholland

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bradholland's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hhhm, i dont really know, or understand. can you pooint me to something i should be reading to get a grasp pf how to fix this? thanks..
  2. Hey Guys, In this portion of my code I have tried to implement pagination, as the results try to display a page with over 100 mp3's with flash players on teh page, and of course the page just dies. However my attempt at pagination isnt actually working. can anyone help this noob? <? // how many rows to show per page $rowsPerPage = 20; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = " SELECT val FROM ax_music " . " LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); // print the random numbers while($row = mysql_fetch_array($result)) { echo $row['val'] . '<br>'; } $row2 = mysql_query("SELECT * FROM ax_music ORDER BY 'sort' ASC"); while($row = mysql_fetch_array($row2)){ ?> <tr> <td><?=$row[title];?></td> <td> <embed src= "musicplayer2.swf" quality="high" width="300" height="52" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" flashvars= "valid_sample_rate=true&external_url=./music/<?=$row[mp3];?>" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed> </td> <td> <? if($row[visible] == 0){ echo "<strong>Not Playlisted</strong><br /> <a href=\"index.php?page=musicplayer&showid=$row[id]\">Add To Playlist</a>"; }else{ echo "<strong>Playlisted</strong><br /> <a href=\"index.php?page=musicplayer&hideid=$row[id]\">Remove From Playlist</a>"; } ?> </td> <td><a href="index.php?page=musicplayer&deleteid=<?=$row[id];?>"><strong>Delete</strong></a></td> <td><a href="./music/<?=$row[mp3];?>"><strong>Download</strong></a></td> </tr> <? } ?> </table>
  3. Thankyou very very much for the help and explanation. i love the NOW() thing too that works a treat. I didnt know about that. Something I have just thought is that I might need to run the script more than once, in which case it would add all the tracks to the db again with new id's etc. If i upload a couple of more files to the folder and want the script to add those, should I just change the "insert into" to "update" or would that not work? I guess the other way is to somehow check to see if the same filename already exists in the table? Thanks for your help and sorry for being such a noob. Brad
  4. Hey Guys, I want to be able to upload a large amount of mp3's to a private area on our website and have a script that will scan the folder for all the filenames and then create a record in the db of all the filenames. It is to help with creating the playlist for my friends radio show. To manually insert all the filenames each month woudl be a nightmare! I have been messing with a partial script I found on the web, and it kind of does something but not what I want it to. heres the db id int(4) title varchar(250) mp3 varchar(250) sort int(4) visible int(1) added datetime heres the script i am trying to use: <? $listDir = array(); $dir = "./music"; if($handler = opendir($dir)) { while (($sub = readdir($handler)) !== FALSE) { if ($sub != "." && $sub != ".." && $sub != "Thumb.db") { if(is_file($dir."/".$sub)) { $listDir[] = $sub; }elseif(is_dir($dir."/".$sub)){ $listDir[$sub] = $this->ReadFolderDirectory($dir."/".$sub); } } } closedir($handler); } $db = mysql_connect("localhost","gfab_ml","xxxxxxx"); mysql_select_db("gfab_ml",$db); $colors=serialize($listDir); //takes the data from a post $sql="INSERT INTO ml_music (ID, title, added) VALUES('','$colors','')"; $result = mysql_query($sql) or die (mysql_error()); ?> it does insert the values into the db but what it does is creates 1 record and spits all the results in a really weird way like this. into the title field. a:18:{i:0;s:23:"14 Mr Magic Premier.mp3";i:1;s:23:"track1.mp3";i:2;s:15:"track2.jpg";i:3;s:15:"track3.fxp";i:4;s:12:"track4.mp3";i:5;s:7:"track5.mp3";i:6;s:7:"track6.jpg";i:7;s:7:"track7.mp3";i:8;s:12:"track8.mp3" Could anyone please help me to make it work? im a bit of a noob. but i do like to tinker!
  5. Jabop, Your a total legend mate, thank you so much!
  6. thanks for the reply mate. is it too much to ask you (if your feeling charitable) to talk me through whats happening there? I know its easy for me to copy and paste something like that, but i dont learn unless i understand what im doing. I dont want someone to just "give me code" (well it helps, but as i say....) thanks b
  7. OK First off, Hi everyone, it's my first post, had a read of the rules etc hello and all that and had a good search on google and this seems to be the definative place to get answers and learn stuff! I am pretty much a total beginner, been watching a few course etc and working along although i wouldn't call myself a "total" noob, i can kinda read code and follow what it means to an extent. Which leads me to make this statement before i ask my question: at risk of offending the rules with my first post im not sure whether i should have posted this in the mysql help or the php help forums, so its not intentional if its in the wrong place, and i apologise in advance! ok. I'm playing about with a little db ive created. Im using a flash file to get the data outpuuted from this php file. I want to format the way the results are given to me in a different way. Heres just a little bit of the code and you can see basically what its doing. All pretty basic stuff I guess. while ( $i <= $numTracksToGet){ $row = mysql_fetch_array($result); extract($row); $echoString .= "&tracks_id=".$row['tracks_id']."&track_name="$row['track_name']";"; in that snippet of code before it loops round again it will display my results as &tracks_id=1;&track_name=test1;&tracks_id=2;&track_name=test2; something like that anyway. but what i want to do is display it like this: &tracks_id=1;2;3;&tracks_name=test1;test2;test3 so it returns all the track id's then all the track names etc etc Im not sure if i could have done this simply by changing the sql statement or if i should do this in the php code?? can anyone shed any light as to how i make the code to display the results like this. Thanks for reading my post Brad
×
×
  • 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.