Προβλημα σε Query με UNION ALL (partial word)

Συζητήσεις για την βάση δεδομένων MySQL και το phpMyAdmin

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
Ianus
Δημοσιεύσεις: 1
Εγγραφή: 15 Ιούλ 2007 15:33

Προβλημα σε Query με UNION ALL (partial word)

Δημοσίευση από Ianus » 15 Ιούλ 2007 16:04

Ftiaxno ena online leksiko apo agglika se ellinika kai to antistrofo. Xrhsimopoio UNION ALL. To provliama einai oti enw gia paradeigma kano search gia "bi" mou vgazei apotelesmata simperilambanomenou kai tou "bilabial". Otan omos kanw search gia "bil" to "bilabial" den emfanizetai h otan kanw search gia oli ti leksi den epistrefei apotelesmata. Skeftika na xrisimopoiiso FULLTEXT INDEX anti gia UNION ALL alla ektos tou oti to provlima den diorthonetai, xreiazomai ti dinatotita gia "partial word search" pou to FULLTEXT den prosferei. Na simeioso oti ta queries leitourgoun kanonika se apeutheias SQL mesw phpmyadmin.

http://users.uoi.gr/gjxydo/lexicon/glossary.html

o kwdikas stin php einai o eksis, paroti ligo "protogonos" kathos eimai kainourios sto athlima:


Κώδικας: Επιλογή όλων

<html>
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
		<meta name="generator" content="Adobe GoLive">
		<title>Untitled Page</title>
	</head>

	<body background="http&#58;//users.uoi.gr/gjxydo/lexicon/mainback.gif" style="BACKGROUND-ATTACHMENT&#58; fixed; BACKGROUND-REPEAT&#58; repeat-no">

<style type="text/css">
<!--
.style1 &#123;font-family&#58; Arial, Helvetica, sans-serif&#125;
.style4 &#123;font-size&#58; 10px&#125;
.style7 &#123;font-size&#58; 12px; &#125;
.style10 &#123;font-size&#58; 14px; &#125;
.style13 &#123;font-size&#58; 16px; &#125;
.style17 &#123;font-family&#58; Arial, Helvetica, sans-serif; font-size&#58; 15px; &#125;
.style18 &#123;font-size&#58; 15px&#125;
.style19 &#123;
	font-family&#58; Arial, Helvetica, sans-serif;
	font-size&#58; 15px;
	color&#58; #0000FF;
	font-weight&#58; bold;
&#125;
.style20 &#123;
	font-family&#58; Arial, Helvetica, sans-serif;
	font-size&#58; 15px;
	font-weight&#58; bold;
	color&#58; #FF0000;
&#125;
-->
</style>


<?php
$hostname="127.0.0.1"; 
$mysql_login="*****"; 
$mysql_password="*****"; 
$database="*********"; 


// connect to the database server 
if &#40;!&#40;$db = mysql_pconnect&#40;$hostname, $mysql_login , $mysql_password&#41;&#41;&#41;
&#123; 
  die&#40;"Can't connect to database server."&#41;;     
&#125; else &#123; 
  // select a database 
    if &#40;!&#40;mysql_select_db&#40;"$database",$db&#41;&#41;&#41;&#123; 
      die&#40;"Can't connect to database."&#41;; 
    &#125; 

mysql_query&#40;"SET NAMES 'greek'", $db&#41;;

if &#40;isset&#40;$_POST&#91;'input'&#93;&#41; && $_POST&#91;'input'&#93; == NULL&#41;&#123; 
die &#40;"<font face='Arial' size='2'><br><B>Παρακαλώ εισάγετε έναν όρο προς αναζήτηση<br><br>Please insert your query</B></font>"&#41;;
&#125; else &#123;

$request = mysql_query&#40;"SELECT 'en' AS src, greek AS colA, english AS colB, reference FROM entries WHERE greek  LIKE '". mysql_real_escape_string&#40;$_POST&#91;'input'&#93;&#41; . "%' UNION ALL SELECT 'gr' AS src, english AS colA, greek AS colB, reference FROM entries WHERE english  LIKE '" . mysql_real_escape_string&#40;$_POST&#91;'input'&#93;&#41; . "%'"&#41;;

$count = 0;
$prncount=1;
$grsearch=false;
$ensearch=false;
$row = mysql_fetch_array&#40;$request&#41;;
if&#40;$row&#91;'src'&#93; == 'en'&#41; &#123; 
$ensearch=true;
$grsearch=false;

printf &#40; "<font face='Arial' size='2'><b><u>Results for</u>&#58;&nbsp;&nbsp<font face='Arial' size=+2<i>&#40;$_POST&#91;input&#93;&#41;</i></font></b><br><br></font>"&#41;;
&#125; 

elseif&#40;$row&#91;'src'&#93; == 'gr'&#41; 
&#123; 

$grsearch=true;
$ensearch=false;

printf &#40; "<font face='Arial' size='2'><b><u>Αποτελέσματα Αναζήτησης</u>&#58;&nbsp;&nbsp<font face='Arial' size=+2<i>&#40;$_POST&#91;input&#93;&#41;</i></font></b><br><br></font>"&#41;;
&#125; 

while&#40;$row = mysql_fetch_array&#40;$request&#41;&#41;&#123; 

 if&#40;$row&#91;'src'&#93; == 'en'&#41; &#123; 

printf&#40;"<table border='1' cellpadding='3' cellspacing='0' bordercolor='#333333' bgcolor='#0066FF'>
  <tr>
    <th width='34' nowrap='nowrap' bgcolor='#CCCCCC' scope='row'><span class='style17'>$prncount</span></th>
    <th width='241' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>English Term </div></th>
    <td width='769' bgcolor='#CCCCCC'><div align='left' class='style19'>%s</div></td>
  </tr>
  <tr>
    <th colspan='2' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Source</div></th>
    <td bgcolor='#CCCCCC'><div align='left'><span class='style1'><span class='style4'><span class='style7'><span class='style10'><span class='style13'><span class='style1'><span class='style18'><span class='style1'></span></span></span></span></span></span></span></span>$row&#91;reference&#93;SOURCE</div></td>
  </tr>
  <tr>
    <th colspan='2' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Area</div></th>
    <td bgcolor='#CCCCCC'><div align='left'><span class='style1'><span class='style4'><span class='style7'><span class='style10'><span class='style13'><span class='style1'><span class='style18'><span class='style1'></span></span></span></span></span></span></span></span>$row&#91;area&#93;AREA</div></td>
  </tr>
  <tr>
    <th colspan='2' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Greek Term</div></th>
    <td bgcolor='#CCCCCC'><div align='left' class='style20'>$row&#91;colA&#93;</div></td>
  </tr>
</table><br>",$row&#91;colB&#93;&#41;;
&#125;  

elseif&#40;$row&#91;'src'&#93; == 'gr'&#41; 
&#123; 

printf&#40;"<table border='1' cellpadding='3' cellspacing='1' bordercolor='#333333' bgcolor='#0066FF'>
  <tr>
    <th width='34' nowrap='nowrap' bgcolor='#CCCCCC' scope='row'><span class='style17'>$prncount</span></th>
    <th width='241' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Προτεινόμενος Ελληνικός Όρος </div></th>
    <td width='769' bgcolor='#CCCCCC'><div align='left' class='style19'>%s</div></td>
  </tr>
  <tr>
    <th colspan='2' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Πηγή</div></th>
    <td bgcolor='#CCCCCC'><div align='left'><span class='style1'><span class='style4'><span class='style7'><span class='style10'><span class='style13'><span class='style1'><span class='style18'><span class='style1'></span></span></span></span></span></span></span></span>$row&#91;reference&#93;ΠΗΓΗ</div></td>
  </tr>
  <tr>
    <th colspan='2' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Κλάδος Γλωσσολογίας </div></th>
    <td bgcolor='#CCCCCC'><div align='left'><span class='style1'><span class='style4'><span class='style7'><span class='style10'><span class='style13'><span class='style1'><span class='style18'><span class='style1'></span></span></span></span></span></span></span></span>$row&#91;area&#93;ΚΛΑΔΟΣ</div></td>
  </tr>
  <tr>
    <th colspan='2' nowrap='nowrap' bgcolor='#999999' scope='row'><div align='left' class='style17'>Αγγλικός Όρος</div></th>
    <td bgcolor='#CCCCCC'><div align='left' class='style20'>$row&#91;colA&#93;</div></td>
  </tr>
</table><br>",$row&#91;colB&#93;&#41;;
&#125;

$count++;
$prncount++;
$requestAll=mysql_query&#40;"select * from entries"&#41;;
$all=mysql_num_rows&#40;$requestAll&#41;;
$total=$prncount-1;
&#125;
&#125;
&#125;

if &#40;!$count>0&#41;
&#123;

echo "<br><font face='Arial' size='2'><b>Δεν βρέθηκαν αποτελέσματα<br><br>No Results Found</font></b>"; 
&#125; else &#123;
	if &#40;$grsearch==true&#41;&#123;
	echo "<b><font face='Arial' size='2'>Βρέθηκαν $total αποτελέσματα</font></b>";
	&#125;
elseif&#40;$ensearch=true&#41;&#123;

echo "<b><font face='Arial' size='2'>Found $total results</font></b>";
&#125;
&#125;
mysql_close&#40;$db&#41;;
?> 
	</body>
</html>

Άβαταρ μέλους
cordis
Administrator, [F|H]ounder, [C|S]EO
Δημοσιεύσεις: 27620
Εγγραφή: 09 Οκτ 1999 03:00
Τοποθεσία: Greece
Επικοινωνία:

Προβλημα σε Query με UNION ALL (partial word)

Δημοσίευση από cordis » 26 Ιούλ 2007 17:16

μην εκτελέσεις το SQL σου, αλλά κάνε το echo και τρέξτο από το phpMySQLAdmin να δεις τι σου βγάζει.
Δεν απαντάω σε προσωπικά μηνύματα με ερωτήσεις που καλύπτονται από τις ενότητες του forum. Για ο,τι άλλο είμαι εδώ για εσάς.
- follow me @twitter

Απάντηση

Επιστροφή στο “MySQL”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες