Взема на точна стойност от инпут

C++ JAVA
Knoppix_
Турист
Турист
Posts: 322
Joined: Mon Aug 24, 2009 11:55 am

Post by Knoppix_ » Thu Jun 13, 2013 8:38 am

Tова е кода с който извършвам търсенето, да не би в него някъде да е крешката

Code: Select all

function doSearch(){
			$('#dg').datagrid('load',{
			vlekach_number: $('#vlekach_number').val(),
				data_zarejdane: $('#data_zarejdane').val()
			});
		}

Това е хтмл кода на формата в която вадя резултатите:

Code: Select all

<body>
	<div class="demo-info" style="margin-bottom&#58;10px">
	</div>
	
	<table id="dg" title="Списъци" class="easyui-datagrid" style="width&#58;860px;height&#58;400px"
			url="pages/get_zarejdane.php"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true">
		<thead>
			<tr>
				<th field="vlekach" width="50" align="center">Влекач</th>
				<th field="data" width="50">Дата</th>
                <th field="strana" width="150">Държава</th>
                <th field="bezinostancia" width="150">Бензиностанция</th>
                <th field="kolichestvo" width="70">Количество</th>
                <th field="kilometraj" width="70">Километраж</th>
                <th field="tonaj" width="90">Тонаж</th>
                <th field="full" width="50">Фулиран</th>
			</tr>
		</thead>
	</table>
	<div id="toolbar">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onClick="newZarejdane&#40;&#41;">Нов запис</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onClick="editZarejdane&#40;&#41;">Редакция</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onClick="removeZarejdane&#40;&#41;">Изтриване</a>
		<span>Влекач номер&#58;</span>
		<input id="vlekach_number" style="line-height&#58;26px;border&#58;1px solid #ccc">
		<span>Дата на зареждане&#58;</span>
		<input id="data_zarejdane" style="line-height&#58;26px;border&#58;1px solid #ccc">
		<a href="#" class="easyui-linkbutton" plain="true" onClick="doSearch&#40;&#41;">Търсене</a>
</div>
	
	<div id="dlg" class="easyui-dialog" style="width&#58;400px;padding&#58;10px 20px"
			closed="true" buttons="#dlg-buttons">
		<div class="ftitle">Нов запис</div>
		<form id="fm" method="post" novalidate>
			<div class="fitem">
				<label>Влекач&#58;</label>
				<input name="kamion" class="easyui-validatebox" required="true">
			</div>
			<div class="fitem">
				<label>Дата&#58;</label>
				<input name="data" class="easyui-validatebox">
			</div>
			<div class="fitem">
				<label>Страна&#58;</label>
				<input name="strana">
			</div>
			<div class="fitem">
				<label>Бензиностанция&#58;</label>
				<input name="bezinostancia" class="easyui-validatebox">
			</div>
            <div class="fitem">
				<label>Количество&#58;</label>
				<input name="kolichestvo" class="easyui-validatebox">
			</div>
            <div class="fitem">
				<label>Километраж&#58;</label>
				<input name="kilometraj" class="easyui-validatebox">
			</div>
            <div class="fitem">
				<label>Тонаж&#58;</label>
				<input name="tonaj" class="easyui-validatebox">
			</div>
            <div class="fitem">
				<label>Фулиран&#58;</label>
				<input name="full" class="easyui-validatebox">
			</div>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onClick="saveZarejdane&#40;&#41;">Запис</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onClick="javascript&#58;$&#40;'#dlg'&#41;.dialog&#40;'close'&#41;">Отказ</a>
	</div>
</body>
А това е самият php-код който уж извършва търсенето обаче ми се стува че скрипта не работи :(

Code: Select all

<?php
	include 'conn.php';
	
	$page = isset&#40;$_POST&#91;'page'&#93;&#41; ? intval&#40;$_POST&#91;'page'&#93;&#41; &#58; 1;
	$rows = isset&#40;$_POST&#91;'rows'&#93;&#41; ? intval&#40;$_POST&#91;'rows'&#93;&#41; &#58; 10;
	$vlekach_number = isset&#40;$_POST&#91;'vlekach_number'&#93;&#41; ? mysql_real_escape_string&#40;$_POST&#91;'vlekach_number'&#93;&#41; &#58; '';
	$data_zarejdane = isset&#40;$_POST&#91;'data_zarejdane'&#93;&#41; ? mysql_real_escape_string&#40;$_POST&#91;'data_zarejdane'&#93;&#41; &#58; '';
	
	$offset = &#40;$page-1&#41;*$rows;
	
	$result = array&#40;&#41;;
	mysql_query&#40;"SET CHARACTER SET utf8"&#41;; 
	$where = "vlekach = '$vlekach_number%' and data like '$data_zarejdane%'";
	$rs = mysql_query&#40;"select count&#40;*&#41; from zarejdania where `vlekach` LIKE '%$vlekach_number' "&#41;;
	$row = mysql_fetch_row&#40;$rs&#41;;
	$result&#91;"total"&#93; = $row&#91;0&#93;;
	
	$rs = mysql_query&#40;"select * from zarejdania where vlekach LIKE '%$vlekach_number' limit $offset,$rows"&#41;;
	
	$items = array&#40;&#41;;
	while&#40;$row = mysql_fetch_object&#40;$rs&#41;&#41;&#123;
		array_push&#40;$items, $row&#41;;
	&#125;
	$result&#91;"rows"&#93; = $items;
	
	echo json_encode&#40;$result&#41;;
?>

User avatar
djman
Гуру
Гуру
Posts: 2801
Joined: Sat Sep 12, 2009 8:07 am
Answers: 107

Post by djman » Thu Jun 13, 2013 9:29 am

@Hous и @eLite ти дадоха 2-3 варианта, които да пробваш. Какви са резултатите???

Knoppix_
Турист
Турист
Posts: 322
Joined: Mon Aug 24, 2009 11:55 am

Post by Knoppix_ » Thu Jun 13, 2013 12:23 pm

Оправих се не беше от вариантите които ми дадоха просто си промених цялата хтмл форма, след което и смених и гласа променливата е оградена в %% и нещата се получиха ...

Post Reply