By: Elino
Date: 2004-09-08
Time: 17:01
|
Problem with search (empty line for results) ... Problème de ligne à blanc dans mon tableau de résultats
Hi,
I'm a newbie in php, i recover a work of my colleague who used tbs for a part of his work (for a search method) ... so excuse me if you find that my question is stupid ... :/
I've seen a problem with my code ... when i start a search with an unknown keyword ... tbs gives me in the table of results a one line blank, with the message "one item found" instead of no line of results ... but and for example, when i enter no keyword, tbs said "0 item found" ... the problem appears only when i search for an unknown keyword ...
Bonjour =) ... je vais traduire mon problème, afin de mieux me faire comprendre ...
Donc voilà, nous utilisons tbs pour effectuer une recherche ... cependant, j'ai un problème lors de l'affichage des résultats quand tbs ne trouve aucune occurence ... il m'affiche une ligne à blanc dans le tableau de résultat au lieu de ne pas en afficher ... cependant, quand je ne fait aucune recherche(aucun motclé), il m'indique bien zéro résultat et ne m'affiche aucune ligne à blanc ...
Here is my code ...
Voici mon code ...
RECHERCHE.PHP
<?
session_start();
include_once('../class/tbs_class.php') ;
require('../class/cnx_mysql.php');
require('../class/language.php');
require('../class/panier.php');
require("../verifsession.php");
require("../class/catalog.php");
require("../class/global.php");
$filelistfam = "listefamille.php";
// if basket not exist, create it !
if (!isset($_SESSION['idpanier']))
{
$panier = new panier();
$panier->create($_SESSION['idclient'], $_SESSION["iduser"]);
}
// Ajout de l'article dans le panier
if (isset($_GET['action']) && $_GET['action']=='add')
{
$panier = new panier();
$panier->AddArticle($_SESSION['idpanier'], $_GET["idarticle"]);
}
//Connexion à la base de donnée
if (!isset($_SERVER)) $_SERVER=&$HTTP_SERVER_VARS ; //PHP<4.1.0
//Valeur par défaut
if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['PageNum'])) {
$PageNum = $_GET['PageNum'] ;
} else {
$PageNum = 1 ;
}
//Valeur par défaut
if (isset($_GET['RecCnt'])) {
$RecCnt = intval($_GET['RecCnt']) ;
} else {
$RecCnt = -1 ;
}
$PageSize = 10 ;
//Fusion du block par page
//print $_GET['idcategorie'];
$designation = "";
$reference = "";
$entete= "";
$param =""; // passage des critères pour la navigation
$catMultivac = (!isset($_GET['optCat']) || ($_GET['optCat'] == 'multi'));
$ref = "";
$des = "";
if ($catMultivac)
{
// IHM
$optmulti = "checked";
$optperso = "";
$lstfamille = "";
}
else
{
// IHM
$optmulti = "";
$optperso = "checked";
$lstfamille = "disabled";
// Le fichier à fusionner
$filerecherche = "rechercheperso.htm";
}
// Référence
if (isset($_GET['reference']) && trim($_GET['reference']) != '')
{
$entete .= " | <b>Référence</b> = " . $_GET['reference'];
$reference = $_GET['reference'];
$param .= "&reference=".$_GET['reference'];
$ref = trim($_GET['reference']);
}
// Designation
if (isset($_GET['designation']) && trim($_GET['designation']) != '')
{
$entete .= " | <b>Désignation</b> = " . $_GET['designation'];
$designation = $_GET['designation'];
$param .= "&designation=".$_GET['designation'];
$des = trim($_GET['designation']);
}
//
if (isset($_GET['optCat']))
$param .= "&optCat=" .$_GET['optCat'];
// Recherche des articles répondant aux critères
$catalog =new catalog();
$res = $catalog->found($ref, $des, $catMultivac, $_SESSION["idclient"]);
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('recherche.htm') ;
//IHM
$TBS->MergeField('trans','trans',true);
//---
$RecCnt = $TBS->MergeBlock('blk',$res,'',$PageSize,$PageNum,$RecCnt) ;
// si le tableau est ide on affiche 0 comme nb article !!
//echo $RecCnt;
//if (array_sum($res)==0 || $res[0]==null)
//$RecCnt = 0;
//$RecCnt = $TBS->MergeBlock('blk',$cnx_id,$query,$PageSize,$PageNum,$RecCnt) ;
$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred','get1'=>$param),$PageNum,$RecCnt,$PageSize) ;
$TBS->Show() ;
function m_event_blk($NomBloc,&$CurrRec,&$DetailSrc,$RecNum)
{
$msg ="";
// Veille référence donc non commandable
$CurrRec['alert'] = "";
$CurrRec['img']="";
$CurrRec['disabledcaddy'] = "visible";
$CurrRec['nocaddy']=0;
// nouvelle référence
if (isset($CurrRec['artnr']))
{
$lastref = LastReferenceArticle($CurrRec['artnr']);
if ($CurrRec['artnr'] != $lastref)
{
$msg .="<li>". trans("recherche_newreference") . " " .$lastref."</li>";
}
}
// Conditionnement
if (isset($CurrRec['cndmuf']) && $CurrRec['cndmuf']> 0)
{
$msg .="<li>". trans("recherche_conditioning") . " " .$CurrRec['cndmuf']."</li>";
}
// Quantité minimale
if (isset($CurrRec['qtemin']) and $CurrRec['qtemin']> 0)
{
$msg .="<li>". trans("recherche_minimal_quantity") . " ". $CurrRec['qtemin']."</li>";
}
// Affichage de l'alerte
if ($msg != "")
{
$CurrRec['alert'] = "<img src=\"../pictures/alert.gif\" border=\"0\" name=\"alert" . $RecNum ."\" onMouseOut=\"switchImage2('alert" . $RecNum."','alert',0)\" onMouseOver = \"switchImage2('alert". $RecNum. "','alert',1)\" onMouseDown = \"switchImage2('alert".$RecNum."','alert',0)\"";
$CurrRec['alert'] .=" onClick=\"javascript:window.open('alertarticle.php?msg=". htmlspecialchars($msg) ."','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=400, height=200');return(false)\">";
}
}
?>
|
RECHERCHE.HTM
<html>
<head>
<title>Multivac - [trans.searchpiece_title]</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../shared/multivac_ie.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript">
// Définition de la fonction
function cacheOff()
{
if (ver >= 4)
{
cache.visibility = HIDDEN;
}
}
</script>
<body background="../pictures/fond.gif" onLoad="javascript:top.frames['main2'].frames['topcmd'].location.reload();top.frames['main2'].frames['menu'].location.reload();cacheOff();">
<script language="JavaScript">
function switchImage(whichImage,imageNumber)
{
if (imageNumber == 0)
document.images[whichImage].src = '../pictures/' + whichImage + '.gif';
else
document.images[whichImage].src = '../pictures/' + whichImage + '_a.gif';
}
function switchImage2(whichImage,namepict, imageNumber)
{
if (imageNumber == 0)
document.images[whichImage].src = '../pictures/' + namepict + '.gif';
else
document.images[whichImage].src = '../pictures/' + namepict + '_a.gif';
}
ver = navigator.appVersion.substring(0,1)
if (ver >= 4)
{
// On crée ici une couche qui contient le message d'attente
// On peut agit sur la couleur de fond, la police de caractère, le grosseur et la couleurs de caractères :
// Couleur de fond ici : BGCOLOR=#000000
// Police du message ici : FONT FACE="Verdana"
// Taille des caractères ici : SIZE=4
// Couleurs des caractères ici : COLOR=#8CFFD3
document.write('<DIV ID="cache" style="position:absolute;left:170px; top:200px"><TABLE WIDTH=400 BGCOLOR=#FFCC66 BORDER=0 CELLPADDING=2 CELLSPACING=0><TR><TD ALIGN=center VALIGN=top><FONT FACE="Verdana" SIZE=4 COLOR=#000000><BR>Merci de patienter pendant la recherche...<BR><BR></FONT></TD> </TR></TABLE></DIV>');
var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
var HIDDEN = (navi) ? 'hide' : 'hidden';
var VISIBLE = (navi) ? 'show' : 'visible';
var cache = (navi) ? document.cache : document.all.cache.style;
// Vous pouvez agir sur cette valeur pour changer la position horizontale du message
cache.left = 80;
cache.visibility = VISIBLE;
}
</script>
<img src="img/recherche.gif">
<form action="[sys.script_name]" method="get" name="frmRecherche" id="frmRecherche">
<table border="0" cellpadding="0" cellspacing="0" width="400" align="center" >
<tr>
<td colspan="2" align="left">
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="400">
<tr>
<td>
<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr>
<td bgcolor="#eeeeee">
<input name="optCat" type="radio" value="multi" [var.optmulti] > [trans.searchpiece_catalogmultivac]
</td>
<td bgcolor="#eeeeee">
<input name="optCat" type="radio" value="perso" [var.optperso] > [trans.searchpiece_catalogcustom]
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" height="5"></td>
</tr>
<tr>
<td colspan="2" align="left">
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="400">
<tr>
<td>
<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr>
<td bgcolor="#ffffee">
[trans.global_referency] :
</td>
<td bgcolor="#ffffee">
<input type="text" name="reference" value="[var.reference]">
</td>
</tr>
<tr>
<td bgcolor="#ffffee">
[trans.global_designation] :
</td>
<td bgcolor="#ffffee">
<input type="text" name="designation" value="[var.designation]">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" bgcolor="#ffffff">
<input type="submit" name="btRecherche" value="[trans.button_search]" onClick="cache.visibility = VISIBLE">
</td>
</tr>
</table>
</form>
<b><big>[trans.global_result] : </big> </b>[var.entete;htmlconv=look]<hr>
<table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr><td>
<table border="0" align="center" cellpadding="1" cellspacing="1">
<tr bgcolor="#0099cc">
<td width="100"><strong>[trans.global_reference_short]</strong></td>
<td align="left" ><strong>[trans.global_designation]</strong></td>
<td align="center"><strong>[trans.recherche_info_short]</strong></td>
<td colspan="2" align="center"><strong>[trans.global_action]</strong></td>
</tr>
<tr bgcolor="#DDDDFF">
<td class="item"> [blk.ref;block=tr;onsection=m_event_blk;noerr] [tbs_check.reference;block=tr;if [blk.#] != 0]</td>
<td class="item"> [blk.designation;block=tr;noerr]</td>
<td class="item" align="center"> [blk.alert;htmlconv=no;noerr]</td>
<td align="center"><img src="../pictures/glass.gif" border="0" alt="[trans.searchpiece_msg_showcard]" name="glass[blk.artnr;noerr]" onMouseOut = "switchImage2('glass[blk.artnr;noerr]', 'glass',0)" onMouseOver = "switchImage2('glass[blk.artnr;noerr]','glass',1)" onMouseDown = "switchImage2('glass[blk.artnr;noerr]','glass',0)" onClick="javascript:window.location.href='fiche.php?idarticle=[blk.artnr;htmlconv=yes;noerr]&showcaddy=[blk.nocaddy]'" ></td>
<td align="center">
<div style="visibility=[blk.disabledcaddy]">
<img src="../pictures/cart.gif" border="0" alt="[trans.global_putcaddy]" name="cart[blk.artnr;noerr]" onMouseOut="switchImage2('cart[blk.artnr;noerr]','cart',0)" onMouseOver = "switchImage2('cart[blk.artnr;noerr]','cart',1)" onMouseDown = "switchImage2('cart[blk.artnr;noerr]','cart',0)" onClick="javascript:window.location.href='[sys.script_name]?action=add&idarticle=[blk.artnr;htmlconv=yes;noerr]&PageNum=[var.PageNum]&[var.param]'">
</div>
</td>
</tr>
<tr bgcolor="#F0F0FF">
<td class="item"> [blk.ref;block=tr;noerr]</td>
<td class="item"> [blk.designation;block=tr;noerr]</td>
<td class="item" align="center"> [blk.alert;htmlconv=no;noerr]</td>
<td align="center"><img src="../pictures/glass.gif" border="0" alt="[trans.searchpiece_msg_showcard]" name="glass[blk.artnr;noerr]" onMouseOut = "switchImage2('glass[blk.artnr;noerr]', 'glass',0)" onMouseOver = "switchImage2('glass[blk.artnr;noerr]','glass',1)" onMouseDown = "switchImage2('glass[blk.artnr;noerr]','glass',0)" onClick="javascript:window.location.href='fiche.php?idarticle=[blk.artnr;htmlconv=yes;noerr]&showcaddy=[blk.nocaddy;noerr]'"></td>
<td align="center">
<div style="visibility=[blk.disabledcaddy]">
<img src="../pictures/cart.gif" border="0" alt="[trans.global_putcaddy]" name="cart[blk.artnr]" onMouseOut="switchImage2('cart[blk.artnr]','cart',0)" onMouseOver = "switchImage2('cart[blk.artnr]','cart',1)" onMouseDown = "switchImage2('cart[blk.artnr]','cart',0)" onClick="javascript:window.location.href='[sys.script_name]?action=add&idarticle=[blk.artnr;htmlconv=yes]&PageNum=[var.PageNum]&[var.param]'">
</div>
</td>
</tr>
</table>
</td></tr>
</table>
<div align="center"><br>
[trans.global_number_article_found] : [var.reccnt] <br>
<br>
</div>
<table border="0" align="center" cellpadding="1" cellspacing="0">
<tr align="center">
<td width="16"><a href="[sys.script_name]?PageNum=[nv.first;endpoint;friend2=a]&[nv.get1]"><img src="../pictures/first.gif" border="0" name="first" onMouseOut = "switchImage('first',0)" onMouseOver = "switchImage('first',1)" onMouseDown = "switchImage('first',0)"></a></td>
<td width="16"><a href="[sys.script_name]?PageNum=[nv.prev;endpoint;friend2=a]&[nv.get1]"><img src="../pictures/back.gif" border="0" name="back" onMouseOut = "switchImage('back',0)" onMouseOver = "switchImage('back',1)" onMouseDown = "switchImage('back',0)"></a></td>
<td width="16" bgcolor="#EEEEFF"><a href="[sys.script_name]?PageNum=[nv.page;block=td]&[nv.get1]">[nv.page]</a></td>
<td width="16" bgcolor="#FFFFFF"><strong>[nv.page;block=td;currpage]</strong></td>
<td width="16"><a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend2=a]&[nv.get1]"><img src="../pictures/next.gif" border="0" name="next" onMouseOut = "switchImage('next',0)" onMouseOver = "switchImage('next',1)" onMouseDown = "switchImage('next',0)"></a></td>
<td width="16"><a href="[sys.script_name]?PageNum=[nv.last;endpoint;friend2=a]&[nv.get1]"><img src="../pictures/last.gif" border="0" name="last" onMouseOut = "switchImage('last',0)" onMouseOver = "switchImage('last',1)" onMouseDown = "switchImage('last',0)"></a></td>
</tr>
</table>
</body>
</html>
|
Thanks for your help ...
|