I own www.layoutsmart.com However I did the whole site in html. I know laugh it up I wasted a whole lot of time. What would be the easiest way to put the tables on the following all on their own pages. http://www.layoutsmart.com/musicandbands.htm Any help is appreciated. Thanks.
How much time it take to complete this website. Why you are not using wiki. Use PMWIKI it is easy to use and there is password protection option for every page.
Not sure how long i spent total. Probably 60+ hours. Alot of the content is custom made by me(contact tables). I'll look into the pmwiki that u mentioned. Thanks.
You can use wordpress. Instead of having posts on the main page you can have all the categories. Each time you add a contact table just make it in the sports category etc.
<?php function page_name_exists( $name ) { global $pages ; $ret = false ; $name = str_replace( "-", " ", urldecode( $name ) ); foreach( $pages as $k => $v ) { if( $v['name'] == trim( $name ) ) $ret = true ; } return $ret ; } function id_by_name( $name ) { global $pages ; $name = str_replace( "-", " ", urldecode( $name ) ); foreach( $pages as $k => $v ) { if( $v['name'] == $name ) { return $k; } } } $started = microtime( ); if( !( $data = @file_get_contents( 'http://www.layoutsmart.com/musicandbands.php' ) ) ) { die("Error 001 : Please try later"); } elseif( !preg_match_all('/<table width="527" border="0" cellpadding="0" cellspacing="0">(.*?)<\/table>/si', $data, $tables ) ) { die("Error 002 : Please try later" ); } elseif( !$tables[1] ) { die("Error 003 : Please try later" ); } else { foreach( $tables[1] as $count => $table ) { if( $table != "" ) { preg_match( '~(<img src="(.*?)" alt="(.*?)" width="300" height="150" />)~', $table, $img ); preg_match( '/<textarea(.*?)<\/textarea>/si', $table, $tarea ); $pages[$count + 1]["name"] = trim( $img[3] ); $pages[$count + 1]["img"] = trim( $img[2] ); $pages[$count + 1]["tarea"] = trim( $tarea[0] ) ; } } } if( @$_GET['page'] and !$_GET['name'] ) { $selectby = 'page'; } elseif( $_GET['name'] and !$_GET['page'] ) { $selectby = 'name'; } else { $selectby = 'page'; } if( $selectby == 'page' and !array_key_exists( $_GET['page'], $pages ) ) { die("Error 004 : Page out of range"); } elseif( $selectby == 'name' and !page_name_exists( $_GET['name'] ) ) { die("Error 005 : Page not found"); } else { switch( $selectby ) { case 'name': $page = $pages[ id_by_name( $_GET['name'] ) ]; break; case 'page': $page = $pages[ $_GET['page'] ]; break; } } ?> <h2>This is where I stop, html is boring</h2> Parsed <?=count( $pages ) ?> pages in <?=round( microtime( ) - $start, 5 ) ?> seconds <br /> Page name : <?=$page['name']; ?><br /> Page image : <?=$page['img']; ?><br /> Page textarea : <?=$page['tarea']; ?><br /> PHP: Example : page.php?name=Zao Example : page.php?page=1 Example : page.php?name=As-I-Lay-Dying ( for seo friendly links ) where name is the name of the band ( I assume ) OR page is the number of the page, currently 122 pages, parsed in about 2 seconds, if you use it post a link and I'll do the rewrite for it too .... I don't really know if this is a good idea, just bored I suppose ......
I just changed it a lil bit, I forgot to urldecode the names ( dunno if you'll need to, is good practice though ), and made it so names with spaces in can have -'s in thier place and still work ..... and thanks
Hey I'm helping him make this. Can you please make that whole code in to a loop which on each loop inserts all of that data into a mysql DB? The back bend for the script is going to be SQl. The code to display it from the DB is already done. Was just looking for a quick way to scrape the data and add it to a DB. You don't need to type the SQL statement, just put the variables there and a comment so I know where to put it. Thanks, and if you can't do it I'll try and mod your code a bit
<?php if( !( $data = @file_get_contents( 'http://www.layoutsmart.com/musicandbands.php' ) ) ) { die("Error 001 : Please try later"); } elseif( !preg_match_all('/<table width="527" border="0" cellpadding="0" cellspacing="0">(.*?)<\/table>/si', $data, $tables ) ) { die("Error 002 : Please try later" ); } elseif( !$tables[1] ) { die("Error 003 : Please try later" ); } else { foreach( $tables[1] as $count => $table ) { if( $table != "" ) { preg_match( '~(<img src="(.*?)" alt="(.*?)" width="300" height="150" />)~', $table, $img ); preg_match( '/<textarea(.*?)<\/textarea>/si', $table, $tarea ); $pages[$count + 1]["name"] = trim( $img[3] ); $pages[$count + 1]["img"] = trim( $img[2] ); $pages[$count + 1]["tarea"] = trim( $tarea[0] ) ; } } } if( !mysql_connect( 'localhost', 'username', 'password' ) ) die(mysql_error( )); elseif(!mysql_select_db( 'database' )) die(mysql_error( )); else { foreach( $pages as $num => $data ) { @extract( $data ); if( !mysql_query( "INSERT INTO `table` VALUES('$num', '$name', '$img', '$tarea')" ) ) die( mysql_error( ) ); } } ?> PHP: something like that, you might wanna addslashes before you insert the data
Worked flawlessly, can you add me to MSN? th3rub3x [ @ ] Gmail.com, that is if you'd like to do a project for money.
At the moment I can't work, my mum is real ill and I'm staying in the hospital with her, just using internet cafes every few days to take my mind off, I should be home sometime this week hopefully, my msn is I will certainly need the cash when I get home though, thanks
Hmm for some reason that code is only parsing the music area. Any other section it just gets all the wrong data.
I only parsed the page posted, post the others, or send me them in an email and next time I get to a pc I'll have a go, gotta go, back in a few hours probably....
its coz the alt attribute of img tags in 1st example posted held the title and the others dont, on mobile phone right now, I'll do it later, it's dooable still, maybe someone else will have a go before I get back to a pc