X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4ECBCD1DD3B for ; Mon, 16 Feb 2004 16:07:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 79141-09 for ; Mon, 16 Feb 2004 12:07:36 -0400 (AST) Received: from digpala.axelero.hu (fe02.axelero.hu [195.228.240.90]) by svr1.postgresql.org (Postfix) with ESMTP id C745ED1DC6F for ; Mon, 16 Feb 2004 12:07:33 -0400 (AST) Received: from digpala (localhost-02 [127.0.2.1]) by digpala.axelero.hu (8.12.11/8.12.11) with SMTP id i1GG7QNf041579 for ; Mon, 16 Feb 2004 17:07:27 +0100 (CET) Received: from fe02.axelero.hu [127.0.2.1] via SMTP gateway by digpala [195.228.240.90]; id A0A2476441F at Mon, 16 Feb 2004 17:07:26 +0100 Received: from rodrigez (122.73-182-adsl-pool.axelero.hu [81.182.73.122]) by fe02.axelero.hu (8.12.11/8.12.11) with SMTP id i1GG7OKA041380 for ; Mon, 16 Feb 2004 17:07:24 +0100 (CET) Message-ID: <004001c3f4a6$fb7ede50$1ec3fea9@rodrigez> From: "lowdog" To: Subject: SQL query seach + rearranging results Date: Mon, 16 Feb 2004 17:07:30 +0100 MIME-Version: 1.0 Content-Type: multipart/related; type="multipart/alternative"; boundary="----=_NextPart_000_003C_01C3F4AF.5C955310" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/222 X-Sequence-Number: 16912 This is a multi-part message in MIME format. ------=_NextPart_000_003C_01C3F4AF.5C955310 Content-Type: multipart/alternative; boundary="----=_NextPart_001_003D_01C3F4AF.5C955310" ------=_NextPart_001_003D_01C3F4AF.5C955310 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hey guys!=20 I need your help in writing a php name-day searcher script.=20 here's what ive done:=20 i have the hostname, login and pw defined in a file, this one calls it:=20 =20 then i made the query, where (sorry for not translating the variable names,= would be easier for you to understand )=20 the "nevek" table contains the names, the honapok table has the month names= and the "nevnapok.nap" tells which day of the month has the name (nevek.ne= v).=20 hope you understand me, i'm a bit confused=20=20 =20 so here comes the important code, which i need help in...:=20 ";=20 echo $row_nevnapok_lekerdezes['honap'];=20 echo " ";=20 echo $row_nevnapok_lekerdezes['nap'];=20 echo ".
";=20 } while ($row_nevnapok_lekerdezes =3D mysql_fetch_assoc($nevnapok_lekerdeze= s)); } ?>=20 here if the totalrows is 0 then the name ($p_name entered in a html form bt= w) was not found in the database and prints an error message (which is btw = $hibauzenet). from now comes the problem:=20 one day (one date) CAN have more names, and=20 one name CAN be on more days...=20 now what happens is that if theres a name that has more days, the name is w= ritten once and the corresponding dates ('honap' is the month, 'nap' is the= day) are printed (if there are more dates of the specific name, if there i= s only one, that one is printed).=20 BUT the mysql query as you can see, querys using WHERE nevek.nev LIKE "%$p_= name%"... this has a reason: there should be matches if the user enters onl= y a part of the name, and=20 therefore if they enter only one letter (say "a") there will be a lot of na= mes, the ones containing that letter... and in this case, only the first ma= tch of the name is printed,and all the other dates...=20 So how can i make the script write the "nev" if there are different names, = but i want it to write the name only once if the specific name has two or m= ore dates according to the database?=20 i know should've expressed my problem simplier but i couldn't for that, i = apologise! but i hope you have my point and can help me!=20 unfortunately i'm not a php expert, i tried some things but they didn't wor= k for me... i tried to do the printing with a for, where the $i keeps chang= ing while it checks if the consecutive result rows (mysql_result($nevnapok_= lekerdezes,$i) and $eredmeny2 =3D mysql_result($nevnapok_lekerdezes,$i+1)) = are the same, and if they are, writes the name only once, but i might have = screwed it up because it did not do what i meant it to do=20=20 there's another problem: my language has characters that the regular code t= ables do not contain, in html they are shown by: "o" "u". some names contai= n some of these, and they are not found by the above script, although i hav= e added them to the mysql database... for example if there's a name like "D= ezs=F5" (hope you will see this correctly, the last letter is the 337), it'= s not found if i enter=20 exactly this into the search field, but is found if i do a query with "Dezs= o"=20 written in the field (now it's the same letter, but has no commas on its to= p), it is found, and the printed name is not Dezso but Dezs=F5, so the data= base keeps the special letter, just can't find it!=20 what do you suggest?=20 regards,=20 lowdog=20 lowdog@axelero.hu ps: i attach here the create tables, just to make the above more understand= able: CREATE TABLE honapok ( honap_kod tinyint(2) NOT NULL default '0', honap text NOT NULL, PRIMARY KEY (honap_kod) ) TYPE=3DMyISAM COMMENT=3D'honapok'; CREATE TABLE nevek ( nev_kod smallint(6) NOT NULL default '0', nev text NOT NULL, PRIMARY KEY (nev_kod) ) TYPE=3DMyISAM COMMENT=3D'nevek listaja'; CREATE TABLE nevnapok ( entry_kod smallint(6) NOT NULL default '0', nev_kod smallint(6) NOT NULL default '0', honap_kod tinyint(2) NOT NULL default '0', nap tinyint(2) NOT NULL default '0', PRIMARY KEY (entry_kod) ) TYPE=3DMyISAM COMMENT=3D'a nevnapok...'; ------=_NextPart_001_003D_01C3F4AF.5C955310 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

hey guys!

I ne= ed your=20 help in writing a php name-day searcher script.

here's what ive don= e:=20

i have the hostname, login and pw defined in a file, this one calls= it:=20
<?php require_once('rubin_nevnapok.php'); ?>

then i made = the=20 query, where (sorry for not translating the variable names, would be easier= for=20 you to understand 3D""=20)=20
the "nevek" table contains the names, the honapok table has the month n= ames=20 and the "nevnapok.nap" tells which day of the month has the name (nevek.nev= ).=20
hope you understand me, i'm a bit confused 3D""=20=20


<?php
mysql_select_db($database_rubin_nevnapok,=20 $rubin_nevnapok);
$honap_szama =3D Date("m");
$nap_szama =3D Date("= d");=20
$query_mainevnap_lekerdezes =3D "SELECT nevek.nev, honapok.honap_kod,= =20 nevnapok.nap FROM nevek INNER JOIN (honapok INNER JOIN nevnapok ON=20 honapok.honap_kod =3D nevnapok.honap_kod) ON nevek.nev_kod =3D nevnapok.nev= _kod=20 WHERE honapok.honap_kod =3D '$honap_szama' AND nevnapok.nap =3D '$nap_szama= '";=20
$mainevnap_lekerdezes =3D mysql_query($query_mainevnap_lekerdezes,=20 $rubin_nevnapok) or die("MySQL hiba! webmaster@rubinfleur.hu " . mysql_erro= r());=20
$row_mainevnap_lekerdezes =3D mysql_fetch_assoc($mainevnap_lekerdezes);= =20
$totalRows_mainevnap_lekerdezes =3D mysql_num_rows($mainevnap_lekerdeze= s);=20
?>

so here comes the important code, which i need help in...= :=20


<?php
if ($totalRows_nevnapok_lekerdezes <=3D 0) {=20
$hibauzenet =3D "Ilyen n=E9v nincs az adatb=E1zisban: ";
print $hib= auzenet;=20
print $p_name;}
else
{echo $row_nevnapok_lekerdezes['nev']; do {=20
echo " napja:";
echo "<br>";
echo=20 $row_nevnapok_lekerdezes['honap'];
echo " ";
echo=20 $row_nevnapok_lekerdezes['nap'];
echo ".<br>";
} while=20 ($row_nevnapok_lekerdezes =3D mysql_fetch_assoc($nevnapok_lekerdezes)); } ?= >=20
here if the totalrows is 0 then the name ($p_name entered in a html for= m=20 btw) was not found in the database and prints an error message (which is bt= w=20 $hibauzenet). from now comes the problem:
one day (one date) CAN have m= ore=20 names, and
one name CAN be on more days...

now what happens is = that=20 if theres a name that has more days, the name is written once and the=20 corresponding dates ('honap' is the month, 'nap' is the day) are printed (i= f=20 there are more dates of the specific name, if there is only one, that one i= s=20 printed).
BUT the mysql query as you can see, querys using WHERE nevek.= nev=20 LIKE "%$p_name%"... this has a reason: there should be matches if the user= =20 enters only a part of the name, and
therefore if they enter only one le= tter=20 (say "a") there will be a lot of names, the ones containing that letter... = and=20 in this case, only the first match of the name is printed,and all the other= =20 dates...
So how can i make the script write the "nev" if there are diff= erent=20 names, but i want it to write the name only once if the specific name has t= wo or=20 more dates according to the database?

i know should've expressed my= =20 problem simplier but i couldn't 3D""=20 for=20 that, i apologise! but i hope you have my point and can help me!=20

unfortunately i'm not a php expert, i tried some things but they di= dn't=20 work for me... i tried to do the printing with a for, where the $i keeps=20 changing while it checks if the consecutive result rows=20 (mysql_result($nevnapok_lekerdezes,$i) and $eredmeny2 =3D=20 mysql_result($nevnapok_lekerdezes,$i+1)) are the same, and if they are, wri= tes=20 the name only once, but i might have screwed it up because it did not do wh= at i=20 meant it to do 3D""=20=20

there's another problem: my language has characters that the regula= r=20 code tables do not contain, in html they are shown by: "ő" "ű". s= ome names=20 contain some of these, and they are not found by the above script, although= i=20 have added them to the mysql database... for example if there's a name like= =20 "Dezs=F5" (hope you will see this correctly, the last letter is the 337), i= t's not=20 found if i enter
exactly this into the search field, but is found if i = do a=20 query with "Dezso"
written in the field (now it's the same letter, but = has=20 no commas on its top), it is found, and the printed name is not Dezso but D= ezs=F5,=20 so the database keeps the special letter, just can't find it!
what do y= ou=20 suggest?


regards,
lowdog
lowdog@axelero.hu

 

ps: i attach here the create tables, just to make t= he=20 above more understandable:

CREATE TABLE honapok (
  honap_kod tinyint(2) NOT NULL default= =20 '0',
  honap text NOT NULL,
  PRIMARY KEY  (honap_kod)=
)=20 TYPE=3DMyISAM COMMENT=3D'honapok';

CREATE TABLE nevek (
  nev_kod smallint(6) NOT NULL default=20 '0',
  nev text NOT NULL,
  PRIMARY KEY  (nev_kod)
= )=20 TYPE=3DMyISAM COMMENT=3D'nevek listaja';

CREATE TABLE nevnapok (
=  =20 entry_kod smallint(6) NOT NULL default '0',
  nev_kod smallint(6) N= OT=20 NULL default '0',
  honap_kod tinyint(2) NOT NULL default '0',
&= nbsp;=20 nap tinyint(2) NOT NULL default '0',
  PRIMARY KEY =20 (entry_kod)
) TYPE=3DMyISAM COMMENT=3D'a=20 nevnapok...';

------=_NextPart_001_003D_01C3F4AF.5C955310-- ------=_NextPart_000_003C_01C3F4AF.5C955310 Content-Type: image/gif; name="smile.gif" Content-Transfer-Encoding: base64 Content-Location: http://www.phpbuilder.com/board/images/smilies/smile.gif R0lGODlhDwAPANU/AP/4q//4ovDokP/4oNLLft/Yhv/3m/HqkdXPgP/81c7I fOrjjP/70v/82f/5sf/5sP/4p+7nj93WhP/7zv31mP/5tf/3nfrylv/7yv/8 3P/7x//6vcfBd+bfiv/6u+jhi/bulPvzlv/4pfTtk/buk//6wsK8dcrDecvF ev72mPvzl//82P/5tP/7xv/6vP/6wP/5r+nijP/7yf/80//3meHah//6v9nS gvz0l/nxlePciP/82//4qMG7dAAAAKSkpCH5BAEAAD8ALAAAAAAPAA8AAAaR wJ9Q6CsWh8hfMbNiYF5HpC+T2SUmLc8D4hv6Vo3GVWNj8SyXrpIxK5Y8lWLo 0PVpMLLiA8D1HT41RRsbLhUAARYGKgcdEghFDg4whwY0FCQxEgQoRSIBAQMG FDg5EQUEHCZFKWkgIwcCCwUKPj09dRELPjoFjie1t0QdBTdGRbbBRAgKHMjI al7Az9BJxtQ/QQA7 ------=_NextPart_000_003C_01C3F4AF.5C955310--