roldahayes Posted November 10, 2007 Share Posted November 10, 2007 Hi please have a look at the code here. I have a csv that has only 2 colums, image url and then a line of text. I'm trying to get the page to read that file but not having much luck!! <?php $quote = file('./files.csv'); foreach($quote as $i => $quote_info) { list($image) = explode(',', $product_info); list($w, $h) = getimagesize($image); } ?> Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 Hmm try this <?php $quote = file('./files.csv'); foreach($quote as $line_num => $line) { echo '('.$line_num.') '. htmlspecialchars($line) . "<br />\n"; } ?> Quote Link to comment Share on other sites More sharing options...
roldahayes Posted November 10, 2007 Author Share Posted November 10, 2007 That displays the CSV line but just prints the url of the image instead of loading it with a (0) at the start of the line... Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 You said you having trouble getting the page to read the file but it is reading the file according to you. Are you trying to load the image? Quote Link to comment Share on other sites More sharing options...
roldahayes Posted November 10, 2007 Author Share Posted November 10, 2007 yeah sorry, I the CSV contains a list of famous quotes, and i just want them listed on a page, but next to them at the start i want a "bullet" image to make the page look better so the first colum of the file has ./images/comment.gif then has the quote. heres the page http://www.gkmedia.co.uk/greatoneliners/test.php Hope this makes sense! Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 Just use an img tag for the bullet image foreach($quote as $line_num => $line) { echo '<img scr="bullet.png" /> '.htmlspecialchars($line) . "<br />\n"; } Quote Link to comment Share on other sites More sharing options...
roldahayes Posted November 10, 2007 Author Share Posted November 10, 2007 Ok, it nearly works now! image isn't loading though eben with the direct url as the img scr= http://www.gkmedia.co.uk/greatoneliners/test.php the code i was using earlier is <?PHP $file_handle = fopen("./files/sport.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('=', $line_of_text); print $parts[0] . $parts[1]. "<BR>"; } fclose($file_handle); ?> can the bullet be added to this as i would prefur using this?? Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 <?php $file_handle = fopen("./files/sport.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('=', $line_of_text); print '<img scr="images/bullet.png />' . $parts[0] . $parts[1]. "<BR>"; } fclose($file_handle); ?> Quote Link to comment Share on other sites More sharing options...
roldahayes Posted November 10, 2007 Author Share Posted November 10, 2007 Hmmm, still wont load the image... http://www.gkmedia.co.uk/greatoneliners/sport.php Quote Link to comment Share on other sites More sharing options...
roldahayes Posted November 10, 2007 Author Share Posted November 10, 2007 still can't get it to load the image... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.