Jump to content

invatphp

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by invatphp

  1. $skip = array( 'http://adresa1.ro' => 'Adresa 1', 'http://adresa2.ro' => 'Adresa 2', 'http://adresa3.ro' => 'Adresa 3', 'http://adresa4.ro' => 'Adresa 4', 'http://adresa5.ro' => 'Adresa 5', 'http://adresa6.ro' => 'Adresa 6', 'http://adresa7.ro' => 'Adresa 7', 'http://adresa8.ro' => 'Adresa 8', 'http://adresa9.ro' => 'Adresa 9' ) ; $totl = count( $skip ) ; $pags = ceil( $totl / 3 ) ; $page = intval( $_GET["page"] ) ? $_GET["page"] : 1 ; $page = ( int )$page ; if ( $page > $pags ) { $page = $pags ; } if ( $page < 1 ) { $page = 1 ; } if ( $page && $pags ) { $start = ( $page - 1 ) * 3 ; $finis = ( $page * 3 ) - 1 ; if ( $finis > $totl - 1 ) { $finis = ( $totl - 1 ) ; } foreach ( $skip as $id => $value ) { for ( $i = $start; $i <= $finis; $i++ ) { echo "<p>\n" ; echo "<b><a href=\"" . $id . "\">" . $value . "</a></b>\n" ; echo "</p>\n" ; } } } if ( $page > 2 ) { echo "<a href=\"" . htmlentities( $_SERVER["PHP_SELF"] ) . "?page=1\">1</a>\n" ; } if ( $page > 1 ) { echo "<a href=\"" . htmlentities( $_SERVER["PHP_SELF"] ) . "?page=" . ( $page - 1 ) . "\">" . ( $page - 1 ) . "</a>\n" ; } if ( $pags > 1 ) { echo $page . "\n" ; } if ( $page < $pags ) { echo "<a href=\"" . htmlentities( $_SERVER["PHP_SELF"] ) . "?page=" . ( $page + 1 ) . "\">" . ( $page + 1 ) . "</a>\n" ; } if ( $page < $pags - 1 ) { echo "<a href=\"" . htmlentities( $_SERVER["PHP_SELF"] ) . "?page=" . $pags . "\">" . $pags . "</a>\n" ; } Eroarea pe care o intampin este ca nu-mi afiseaza cate 3 linkuri per pagina ci un sir lung de linii. Cine imi spune unde am gresit in cod si ma poate ajuta cu solutie?
  2. $curl = file_get_contents( "http://la-psiholog.ro/teste-psihologice/afla-ce-cred-ceilalti-despre-tine" ) ; preg_match_all( '#<div\sclass=\"test-qnr\"\s>(?P<digit>\d+)<\/div>.+?<div\sclass=\"test-q\">(?P<Question>.+?)<\/div>.+?onclick=\"clk(([^\"]*))\".+?<div\sclass=\"test-atxt\">(?P<Answer>.+?)<\/div>#sim', $curl, $test ) ; print_r( $test[1] ) ; // Numarul intrebarii echo "<br/>" ; echo "<br/>" ; print_r( $test['Question'] ) ; // Intrebarea echo "<br/>" ; echo "<br/>" ; print_r( $test[3] ) ; // Numarul optiunii de raspuns din intrebare echo "<br/>" ; echo "<br/>" ; print_r( $test['Answer'] ) ; // Raspunsul din intrebare Eroarea pe care o intampin este ca pentru fiecare intrebare in parte ar trebuii sa-mi afiseze numerele si raspunsurile atatea cate sunt, numai ca mie imi afiseaza doar primele linii de optiune si raspuns de la fiecare intrebare. Unde am gresit in cod si cine ma poate ajuta cu solutie?
×
×
  • Create New...