Version complète: sur le forum Webmaster Hub : reprendre une partie d'une page et mettre sur une autre !
Webmaster Hub > Création et exploitation de Sites Internet > Les langages du Net > PHP
mask
Bonjour a tous ,


Voila ,je voudrais reprendre une partie d'une page et la faire apparaitre sur l'index.php.
je suis novice ,j'aimerais qu'on m'aiguille un peu ..

merci de votre aide
mask
yuston
Ce que tu souhaites faire, je pense, que c'est inclure un fichier X, situé sur le même serveur que ton fichier index.php

Pour le faire, il faut utiliser la fonction include(); de PHP.

En résumé, la syntaxe c'est ça:
CODE
<?php
// à mettre dans index.php
include('un_dossier/le_fichier_x.php');
?>


Conséquence de ce code:
tout le contenu du fichier le_fichier_x.php sera inclus (repris, pour utiliser tes mots) dans le fichier index.php

Voilà.
mask
Merci de ta reponse trés rapide

En fait la sur le serveur j'ai include.php index.php models.php

Sur mon index les animatrices connectées apparaissent.
en dessousj'aimerais que mes modeles de la page models.php apparaissent ,ce qui permet d'avoir quelques chose d'afficher sur index.php meme quand aucune animatrice est en ligne.

merci a tous pour votre aide.
yuston
Avec include(); c'est l'intégralité du fichier models.php qui sera repris. Et ce n'est pas le but recherché, dans ce cas précis.

Là, à mon avis, le plus simple serait de copier la partie du code de models.php et de le coller dans index.php.

PS: tu aurais pu éditer le message pour inclure le lien wink.gif
PS2: sur le Hub, on ne doit pas faire la promotion d'un site adulte... :/
mask
Voila le code de la page models.php




CODE-BOX
<?
$iuajksdv = 9846598234;
include "include.php";
_AT_session_start();

$showtype = getconf('showmodel');
if ($showtype == 'new') {
$q1 = "`status` = 'new' OR `status` = 'active'";
}
if ($showtype == 'active') {
$q1 = "`status` = 'active'";
}

if (isset($_GET['page']) && (good_number($_GET['page']))) {
$pg = safe_string($_GET['page']);
} else {
$pg = 1;
}
$deunde = ($pg-1) * 30;
$query = mysql_query("SELECT `id`, `nickname` FROM `performers` WHERE ($q1) AND `S1` != '' LIMIT $deunde, 30");
$many = mysql_num_rows($query);
$query2 = mysql_query("SELECT `id`, `nickname` FROM `performers` WHERE ($q1) AND `S1` != ''");
$total = mysql_num_rows($query2);
$pagini = ceil($total / 30);

?>






<? include "haut.php";?>


</td>


</tr>



<tr>

<td>




<div align="center"><table cellpadding="0" cellspacing="0">

<tr>

<td background="habillage/haut.png" width="840" height="40"></td>

</tr>


</table> </div>



<table width="840" align="center" class="formulaire" cellpadding="0" cellspacing="0">

<tr>

<td background="habillage/millieu.png" width="840" height="100%"><div aign="center">



<?
$i = 0;
$t = 0;
while ($row = mysql_fetch_assoc($query)) {
$i++;
$t++;
if (file_exists("profileimages/main-$row[id].jpg")) {
$img = "profileimages/main-$row[id].jpg";
} else {
$img = "images/newp.jpg";
}
if ($i == 1) {
echo '<!-- pizda --><table cellpadding=\"0\" cellspacing=\"0\" align="center" background="habillage/millieu.png" width="840" height="160">
<tr >';
} // end i == 1
echo " <td width=\"177\"><div align=\"center\"><table width=\"160\" cellpadding=\"0\" cellspacing=\"0\">







<tr>

<td width=\"160\" height=\"145\" background=\"habillage/fond-image-petit.png\" ><div align=\"center\"><a href=\"profile.php?id=$row[id]\"><img src=\"$img\" width=\"136\" height=\"94\" border=\"0\"></a>


<br>

<div align=\"center\"><table valign=\"bottom\" width=\"136\" height=\"20\">

<tr>


<td><a href=\"livechat.php?id=$row[id]&amp;free\" class=\"pseudo\">$row[nickname]</a></td>

<td><a href=\"profile.php?id=$row[id]\"><img src=\"habillage/mafiche.png\" align=\"absmiddle\" border=\"0\"></a></td>


</tr>


</table></div>


</td>

</tr>











</table></td>";

if (($i == 5) || ($many == $t)) {
$i = 0;
echo " </tr>



</table>




<!-- pizda end -->\n";
} //end i == 6
}

?>

<table width="820" height:35;">
<tr>
<td style="text-align:right; padding-right: 15;" class="yelb">
<?
$begin = $pg - 1;

if ($pg == 1) {
$begin = 1;
}
$end = $begin + 2;
if ($pg == $pagini) {
$end = $pagini;
$begin = $pg - 2;
}

if ($pagini < 3) {
$begin = 1;
$end = $pagini;
}

if (($pg != 1) && ($pagini > 2)) {
$temp = $pg-1;
echo "<a href=\"models.php?page=1\" class=\"yelb\"><<</a>\n&nbsp;<a href=\"models.php?page=$temp\" class=\"yelb\"><</a>\n&nbsp;";
}

for ($i = $begin; $i <= $end; $i++) {
if ($pagini == 1) {
break;
}
if ($i == $pg) {
$stil = "yelb";
} else {
$stil = "whiteb";
}
echo "<a href=\"models.php?page=$i\" class=\"$stil\">$i</a>&nbsp;\n";
}

if (($pg != $pagini) && ($pagini > 2)) {
$temp = $pg + 1;
echo "&nbsp;<a href=\"models.php?page=$temp\" class=\"yelb\">></a>\n&nbsp;<a href=\"models.php?page=$pagini\" class=\"yelb\">>></a>\n";
}

?>
</td>
</tr>
</table>


</td>
</tr>
</table>

<div align="center"><table cellpadding="0" cellspacing="0" >

<tr>

<td background="habillage/bas.png" width="840" height="40"></td>

</tr>


</table> </div>



<br>


</td>
</tr>


<? include "bas.php"; ?>



Voila le code de index.php

CODE-BOX
<?
$iuajksdv = 9846598234;
include "include.php";
_AT_session_start();



$affid = safe_string($_GET['affid']);
if (strlen($affid) > 0) {
$qerwfa = mysql_query("SELECT `first` FROM `affiliates` WHERE `id` = '$affid'");
if (mysql_num_rows($qerwfa) == 1) {
setcookie("affid", $affid, time() + 999999999, "/");

$year = date("Y");
$month = date("n");
$today = date("d");
$now = strtotime("$year-$month-$today");
$query = mysql_query("SELECT `id` FROM `affclicks` WHERE `affid` = '$affid' AND `date` = '$now'");
if (mysql_num_rows($query) == 0) {
mysql_query("INSERT INTO `affclicks` (`affid`, `date`, `clicks`) VALUES ('$affid', '$now', '1')");
} else {
mysql_query("UPDATE `affclicks` SET `clicks` = `clicks` + 1 WHERE `affid` = '$affid'");
}
}
}






$showtype = getconf('showmodel');
$public_type = getconf('public_type');
if ($public_type == 'public') {
$pimg2 = 'chattez.jpg';
} else {
$pimg2 = 'chattez.jpg';
}

if ($showtype == 'new') {
$q1 = "`status` = 'new' OR `status` = 'active'";
}
if ($showtype == 'active') {
$q1 = "`status` = 'active'";
}

if (isset($_GET['pvr'])) {
$_SESSION['imagevsflash'] = 'on';
}
if (isset($_GET['pvroff'])) {
$_SESSION['imagevsflash'] = '';
}

$now = date("U");
$his = $now - 21600;
mysql_query("UPDATE `performers` SET `onlinestatus` = 'offline' WHERE (`onlinestatus` = 'online' OR `onlinestatus` = 'private') AND `lastonline` < '$his'");
if (isset($_GET['page']) && (good_number($_GET['page']))) {
$pg = safe_string($_GET['page']);
} else {
$pg = 1;
}
$deunde = ($pg-1) * 30;

$tmp33 = getconf('allowprivate');
if (($tmp33 == 'yes') && (getconf('customcost') == 'yes')) {
$muuuccc = true;
}

$query = mysql_query("SELECT `id`, `nickname`, `views`, `languages`, `ptype`$eeexxxtttraaa FROM `performers` WHERE `onlinestatus` = 'online' AND ($q1) ORDER BY `lastonline` DESC LIMIT $deunde, 30");
$many = mysql_num_rows($query);
$query2 = mysql_query("SELECT `id`, `nickname` FROM `performers` WHERE `onlinestatus` = 'online' AND ($q1)");
$total = mysql_num_rows($query2);
$pagini = ceil($total / 30);


$sdfsadfasdf = mysql_query("SELECT `id`, `nickname` FROM `performers` WHERE ($q1) AND `S1` != '' AND `onlinestatus` = 'offline' AND `bans` NOT LIKE '%$tri%' ORDER BY `lastonline` DESC LIMIT 0, 18");
$rfdgersagdfg = mysql_query("SELECT `id`, `length`, `views`, `date`, `name`, `ownerid` FROM `videos` WHERE `length` > '1' AND `paid` = '1' ORDER BY RAND() LIMIT 4");
$rfdgersagdfg2 = mysql_query("SELECT `id`, `length`, `views`, `date`, `name`, `ownerid` FROM `videos` WHERE `length` > '1' AND `paid` != '1' ORDER BY RAND() LIMIT 4");

?>









<? include "haut.php";?>


</td>


</tr>



<tr>

<td>




<div align="center"><table cellpadding="0" cellspacing="0">

<tr>

<td background="habillage/haut.png" width="840" height="40"></td>

</tr>


</table> </div>



<table width="840" align="center" class="formulaire" cellpadding="0" cellspacing="0">

<tr>

<td background="habillage/millieu.png" width="840" height="100%"><div aign="center">




<?
if (mysql_num_rows($query) == 0) {
echo "<div class=\"yelb\" align= \"center\">" . $lang["Notice: there are no performers at this time, please try again later!"] . "<br><br><br></div>";
}
$i = 0;
$t = 0;
while ($row = mysql_fetch_assoc($query)) {
$pricing = privatecosts($row['id']);
unset($tutz);
$reafds = mysql_query("SELECT `sexpref`, `sex`, `age` FROM `profiles` WHERE `pid` = '$row[id]'");
$ersdfa = mysql_fetch_row($reafds);
if (mysql_num_rows($reafds) == 0) {
$ersdfa[0] = 'n/a';
$ersdfa[1] = 'n/a';
$ersdfa[2] = 'n/a';
}
$langs = explode('-', $row['languages']);
foreach ($langs as $k) {
if (file_exists("images/$k.gif")) $tutz .= "<img src=\"images/$k.gif\" alt=\"$k\" border=\"0\">" . " ";
}

if (strlen($row['ptype']) > 0) {
$awq45eag = $row['ptype'];
$categorii = "<strong>" . $lang["Performer category"] . " :</strong> $type[$awq45eag]<br />";
} else {
$categorii = "";
}

if (!((!$muuuccc) && ($tmp33 != 'yes'))) {
$span = "<div style=\" border:solid; background-color:#A5BED2; border-color:#A5BED2; border-width:2px;\">
<strong>" . $lang["Private chat cost"] . " :</strong> $pricing jetons/m<br />
$categorii
<strong>" . $lang["Sex"] . " :</strong> $ersdfa[1]<br />
<strong>" . $lang["Sexual orientation"] . " :</strong> $ersdfa[0]<br />
<strong>" . $lang["Age"] . " :</strong> $ersdfa[2]<br />

$tutz
</div>";
} else {
$span = "<div style=\" border:solid; background-color:#A5BED2; border-color:#A5BED2; border-width:2px;\">
$categorii
<strong>" . $lang["Sex"] . " :</strong> $ersdfa[1]<br />
<strong>" . $lang["Sexual orientation"] . " :</strong> $ersdfa[0]<br />
<strong>" . $lang["Age"] . " :</strong> $ersdfa[2]<br />

$tutz
</div>";
}

$i++;
$t++;
if (file_exists("profileimages/main-$row[id].jpg")) {
$img = "profileimages/main-$row[id].jpg";
} else {
$img = "images/newp.jpg";
}
if ($i == 1) {
echo '<!-- pizda --><div align=center><table cellpadding=\"0\" cellspacing=\"0\" align="center" width="820" height="160">
<tr>';
} // end i == 1
if ($_SESSION['imagevsflash'] != 'on')
echo "


<td width=\"177\"><div align=\"center\"><table width=\"160\" cellpadding=\"0\" cellspacing=\"0\">







<tr>

<td width=\"160\" height=\"145\" background=\"habillage/fond-image-petit.png\" ><div align=\"center\"><a href=\"profile.php?id=$row[id]\"><img src=\"$img\" width=\"136\" height=\"94\" border=\"0\"></a>


<br>

<div align=\"center\"><table valign=\"bottom\" width=\"136\" height=\"20\" bgcolor=\"#AD2300\">

<tr>


<td style=\"padding-left: 3px\"><img src=\"habillage/rond-petit.png\" align=\"absmiddle\"> <a href=\"livechat.php?id=$row[id]&amp;free\" class=\"pseudo\">$row[nickname]</a></td>

<td><a href=\"profile.php?id=$row[id]\"><img src=\"habillage/mafiche.png\" align=\"absmiddle\" border=\"0\"></a></td>


</tr>


</table></div>


</td>

</tr>


<tr>
<td colspan=\"3\"><a href=\"livechat.php?id=$row[id]\"><div align=\"center\"><img src=\"images/prive.jpg\" border=\"0\"></div></a></td>
</tr>

<tr height=\"35\">


<td><div align=\"center\"><a href=\"livechat.php?id=$row[id]&amp;free\"><img src=\"images/$pimg2\" border=\"0\"></a></div></td>





</tr>








</table></div></td>


<!-- $i muci -->";
echo "<!-- muci $i $t $many $total -->";
if (($i == 5) || ($many == $t)) {
$i = 0;
echo " </tr>
</table>





<br><br><!-- pizda end -->\n";
} //end i == 4
}

?>
<!-- end -->
<table width="820" height:35;">
<tr>
<td style="text-align:right; padding-right: 15;" class="yelb"><?
$begin = $pg - 1;

if ($pg == 1) {
$begin = 1;
}
$end = $begin + 2;
if ($pg == $pagini) {
$end = $pagini;
$begin = $pg - 2;
}

if ($pagini < 3) {
$begin = 1;
$end = $pagini;
}

if (($pg != 1) && ($pagini > 2)) {
$temp = $pg-1;
echo "<a href=\"index.php?page=1\" class=\"formulaire\"><<</a>\n&nbsp;<a href=\"index.php?page=$temp\" class=\"formulaire\"><</a>\n&nbsp;";
}

for ($i = $begin; $i <= $end; $i++) {
if ($pagini == 1) {
break;
}
if ($i == $pg) {
$stil = "yelb";
} else {
$stil = "whiteb";
}
echo "<a href=\"index.php?page=$i\" class=\"$stil\">$i</a>&nbsp;\n";
}

if (($pg != $pagini) && ($pagini > 2)) {
$temp = $pg + 1;
echo "&nbsp;<a href=\"index.php?page=$temp\" class=\"formulaire\">></a>\n&nbsp;<a href=\"index.php?page=$pagini\" class=\"formulaire\">>></a>\n";
}

?>






</td>
</tr>
</table>


</td>
</tr>
</table>

<div align="center"><table cellpadding="0" cellspacing="0" >

<tr>

<td background="habillage/bas.png" width="840" height="40"></td>

</tr>


</table> </div>



<br>


</td>
</tr>


<? include "bas.php"; ?>



</body>
</html>

<script type="text/javascript" language="javascript" src="Scripts/domLib.js"></script>
<script type="text/javascript" language="javascript" src="Scripts/domTT.js"></script>
<script type="text/javascript" language="javascript">
var domTT_styleClass = 'domTTClassic';
</script>
</body>
</html>




Voila les deux pages si tu pouvais me dire quoi prendre et ou mettre se serais vraiment vraiment cool de ta part.
ce site est vraiment top

merci a tous
Ceci est une version "bas débit" de notre forum. Pour voir la version complète avec plus d'information, la mise en page et les images, veuillez cliquer ici.