adam291086 Posted October 25, 2007 Share Posted October 25, 2007 hello, I have a website that displays some test results, these are generated from another website. All is working well. What i want to do though is modify the contents to display 10 of the rows of information rather than the 100. Can i do this with php? If so how? If not what should i look for? Quote Link to comment Share on other sites More sharing options...
stuffradio Posted October 25, 2007 Share Posted October 25, 2007 So this is a mysql query? mysql_query("SELECT * FROM `table_name` LIMIT 0,10"); That limits it to 10 results You can order it by Asc if you want to show first 10 rows or Desc if you want 10 last rows. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 25, 2007 Author Share Posted October 25, 2007 i cant use mysql because i am getting the contents from another website and not a database. Quote Link to comment Share on other sites More sharing options...
stuffradio Posted October 25, 2007 Share Posted October 25, 2007 Can you give us an example of what you're using to pull this information so we can better help? Thanks Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 25, 2007 Author Share Posted October 25, 2007 at the moment i am using a basic Iframe. The image is created by software that monitors my works web server. <iframe src="website address, cant give it to you as it contains ip addresses=True" id="indicative" name="indicative" frameborder= 1 height="100%" width="100%"> </iframe> Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted October 25, 2007 Share Posted October 25, 2007 you could file_get_contents, then explode it at certain points? Then have, like: <?php file_get_contents('siteaddress'); $line = explode('say, like, </td>, which would split every table part up', $line); $i = 0 foreach($line as $data){ if($i =< 10){ echo 'linedata'; } $i++ } ?> Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 25, 2007 Author Share Posted October 25, 2007 i am new to php and unsure of the explode function, can you help Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted October 25, 2007 Share Posted October 25, 2007 explode basically breaks up data into pieces. It's constructed like so: $new_variable = explode('the character to explode by', $old_variable); So, now, if you had this data: $old_variable = first|second and said $new_variable = explode('|', $old_variable); it breaks it up so you'd get this $new_variable[0] = 'first'; $new_variable[1] = 'second'; and, if you added more, it would go on like that. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 25, 2007 Author Share Posted October 25, 2007 ok thanks i now understand, the problem being that is it possible to file_get_contents() on a website address? I have a simple file working but its not getting the site contents. <html> <head> </head> <body> <?php // Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL $lines = file_get_contents('www.google.co.uk'); if ($lines) { echo $lines; } else { echo "No File Found"; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted October 25, 2007 Share Posted October 25, 2007 yes, it's possible, but you have to give a full path. http://www.google.co.uk Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted October 25, 2007 Share Posted October 25, 2007 also, if that's what's going to be on the page, get rid of the <html>, <head>, and <body> tags, because google will already have them. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 25, 2007 Author Share Posted October 25, 2007 thanks that is working now, Thanks. 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.