Jump to content
php.lv forumi

MySQL query atkarībā no $keyword


Jako

Recommended Posts

Šiet ir aptuvenais izskats tam ko mēģinu uzcept. Problēma ir tajā, ka man izdodas meklēt pēc klienta nosaukuma, bet ja meklēju pēc pasūtījuma apjoma "qty", man atgriež tieši neko.

 

Liekas, ka esmu iestrēdzis, jo izmēģināju visādus variantus, bet bez panākumiem.

Uzmetiet, čaļi, aci kodam, varbūt kāds pamanīs problēmu.

 

Pieļauju domu, ka kods izskatīsies briesmīgi amatierisks:

 

<?php // --- snip ---
if (isset($_POST['submit'])) {
$keyword=$_POST['keyword'];
$keyword1 = mb_convert_case($keyword, MB_CASE_UPPER, "UTF-8");

--- snip ---

$clq="SELECT * FROM klienti WHERE cl_name LIKE '%$keyword1%'";
$clres=mysql_query($clq) or die(mysql_error());
while($row = mysql_fetch_array($clres))
{
if (!empty($row)) {
$clid=$row['cl_id'];
$clname=$row['cl_name'];
$seq="SELECT * FROM data WHERE clientid=$clid";
$sres=mysql_query($seq) or die(mysql_error());

$row2 = mysql_fetch_array($sres);
}
elseif (empty($row)){
$seq="SELECT * FROM data WHERE data.qty LIKE '%$keyword%'";
$sres=mysql_query($seq) or die(mysql_error());
$row2 = mysql_fetch_array($sres);
}
--- snip --- ?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...