I
I
Igor Bykov2016-05-16 12:05:51
PHP
Igor Bykov, 2016-05-16 12:05:51

Why doesn't the search form run the script?

A newbie in this business ....... there is a widget on the site, the same search works. I try to do the same in the menu, it does not work.

<!--Search-->
 <div id="msearch" class="msearch">
  <form action="javascript: TDMArtSearchmove()" method="post">
  <input type="text" id="artnumg" name="" maxlength="40" placeholder="ПОИСК ПО АРТИКУЛУ" class="input" />
  <input type="submit" name="" value="" class="submit" />
    <script type="text/javascript">
  function TDMArtSearchmove(){
  var art = $('#artnumg').val();
  if(art!==''){
    art = art.replace(/[^a-zA-Z0-9.-]+/g, '');
    location = '/autoparts/search/'+art+'/';
  }
}
$('#artnumg').keypress(function (e){
  if(e.which === 13){ TDMArtSearchmove(); return false;}
});
</script>
  </form>					
          
</div>
<!--end search-->

Answer the question

In order to leave comments, you need to log in

5 answer(s)
W
web-mechanic, 2016-05-20
@amfetamine

Look in firebug for errors and then ask a question. And from what you cited above, nothing is clear to anyone.

R
Rsa97, 2015-07-17
@TroL929

Issue this query in the console, prefixing it with the EXPLAIN command . Get a query plan, see where and what indexes are used, where they need to be added.

N
nozzy, 2015-07-17
@nozzy

I don’t understand what’s wrong with users, I
can remove two joins:
LEFT JOIN users us1 ON us1.id = a.userCreated
LEFT JOIN users us2 ON us2.id = a.userDogovor
LEFT JOIN users us3 ON us3.id = a.userComplete
=>
LEFT JOIN users us1 ON us1.id IN (a.userCreated, a.userDogovor, a.userComplete)

W
wol_fi, 2015-07-17
@wol_fi

MYSQL joins tables through inner loops. Such a number of joins is deadly. Maybe you should consider denormalizing the data?

G
German Zvonchuk, 2015-07-23
@inside22

Vyacheslav Belyaev , if you work in PHP, create one Questionary class with the getQuestionary() method
and then use it like this, pass the criteria and get the answer:

$questionaryObj= Questionary->getQuestionary(array(
    'status' => 1,
    'delete' => 0,
));

This is instead of the first query against the ankets table.
Next, we twist the received data and get the remaining data:
foreach($questionaryObj as $questionary) {

    $clientObj= Client->getClient(array('cliendId' => $questionary->cliendId));
    $serviceObj= Service->getService(array('serviceId' => $questionary->serviceId));
    $meetObj= Meet->getMeet(array('meetId' => $questionary->meetId));
    $userCreatedName = User->getUser(array('userCreated' => $questionary->userId));
    $userDogovorName  = User->getUser(array('userDogovor' => $questionary->userDogovor));
    $userCompleteName  = User->getUser(array('userComplete' => $questionary->userComplete));

    $responceArr = array(
        'name' => $clientObj->name,
        'lastname' => $clientObj->lastname,
        'patronymic' => $clientObj->patronymic,
        'phone' => $clientObj->phone,
        'serviceName' => $serviceObj->name,
        'meet' => $meetObj->meet,
        'wasMeet' => $meetObj->wasMeet,
        'dateMeet' => $meetObj->dateMeet,
        'serviceName' => $serviceObj->name
    );
}

And as a result, you collect an array with the data you need.
The advantage of this method is that small and simple SQL queries are executed.
Large and complex queries are difficult to maintain.
Keep this in mind, if you have to change some table or tables tomorrow, you won't have to rewrite all your huge queries, you will only have to rewrite one query in one method...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question