
le 20/03/2005 à 15:54
probleme avec like
Personne ne peux m aider??
<?php
if (isset($_GET['recherche'])) {
if (isset($_GET['n'])) {
$n= $_GET['n'];
$m= ($_GET['n']+20);
$ps=$m;
$pp=$n-20;
$g=$_GET['recherche'];
} }
else {
$n= 0;
$m= 20;
}
if (isset($_GET['recherche'])) {
if (isset($_GET['n'])) {
include ('connexion.php');
$sql = 'SELECT * FROM javascript WHERE description LIKE "%'.addslashes($_POST['recherche']).'%" ORDER BY id DESC LIMIT '.$n.',20';
$req = mysql_query($sql) or die('Erreur SQL !'.$sql.''.mysql_error());
while ($data = mysql_fetch_array($req)) {
echo ' <table width="400" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<td height="30" class="titres">
<a href="php.php?id='.$data['id'].'"target="_blank"><font color="#FF6600">'.stripslashes($data['titre']).'</font></a> : '.stripslashes($data['description']).'<br>________________________<br>
</td>
</tr>
</table>';
}
echo'<br><br><br><div style="text-align: center"><a href="javascript.php?n='.$pp.'&recherche='.$g.'"><font color="#FF9900">Page précédente</font></a> | <a href="javascript.php?n='.$ps.'&recherche='.$g.'"><font color="#FF9900">Page suivante</font></a><br><br></div>';
mysql_close ();
}}
//------------------------------------------------------
if (isset($_POST['Ok']) && $_POST['Ok'] == 'Ok') {
if ((isset($_POST['recherche']) && !empty($_POST['recherche']))) {
$g=$_POST['recherche'];
include ('connexion.php');
$sql = 'SELECT * FROM javascript WHERE description LIKE "%'.addslashes($_POST['recherche']).'%" ORDER BY id DESC LIMIT '.$n.',20';
$req = mysql_query($sql) or die('Erreur SQL !'.$sql.''.mysql_error());
$data = mysql_fetch_array($req);
if ($data[0] == 1) {
while ($data = mysql_fetch_array($req)) {
echo ' <table width="400" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<td height="30" class="titres">
<a href="php.php?id='.$data['id'].'"target="_blank"><font color="#FF6600">'.stripslashes($data['titre']).'</font></a> : '.stripslashes($data['description']).'<br>________________________<br>
</td>
</tr>
</table>';
}
echo'<br><br><br><div style="text-align: center"><a href="javascript.php?n='.$ps.'&recherche='.$g.'"><font color="#FF9900">Page suivante</font></a><br><br></div>';
}
elseif ($data[0] == 0) {
echo'Aucune réponse trouvée';}
mysql_close ();
$ps=20;
}}
if (isset($_GET['n'])) {
echo'<br><br><br><div style="text-align: center"><a href="javascript.php?n='.$pp.'&recherche='.$g.'"><font color="#FF9900">Page précédente</font></a> | <a href="php.php?n='.$ps.'&recherche='.$g.'"><font color="#FF9900">Page suivante</font></a><br><br></div>';
}
//----------------------------------------------------------------
if (isset($_GET['id'])) {
include ('connexion.php');
$sql2 = 'SELECT * FROM php WHERE id="'.$_GET['id'].'"';
$req2 = mysql_query($sql2) or die('Erreur SQL !'.$sql2.''.mysql_error());
$data2 = mysql_fetch_array($req2);
echo' <table width="400" border="1" cellpadding="0" cellspacing="1" bordercolor="#666666">
<tr>
<td height="27">
</td>
<td>
<b>'.stripslashes($data2['titre']).'</b>
</td>
</tr>
<tr>
<td valign="top" height="119" colspan="2">
'.stripslashes($data2['description']).'
</td>
</tr>
<tr>
<td height="34" colspan="2">
'.stripslashes($data2['script']).'
</td>
</tr>
</table>';
mysql_close ();}
?>
<?php
$sql = 'INSERT INTO '.$_POST['type'].' VALUES("", "'.addslashes($_POST['titre']).'", "'.addslashes($_POST['description']).'", "'addslashes($_POST['script']).'","'.addslashes($_SESSION['login']).'","1")';
?>