ㅠㅠ 아무리해도 안되네요. 정보
ㅠㅠ 아무리해도 안되네요.본문
여러날을 밤세워가며 이렇게도 해보고 저렇게도 해봤으나...
안되네요... 도데체 어떻게 해야 적용이 될까요?
============================================================================
출발지=종로1가 도착지=종로3가 검색했더니 이런오류가 나오며
되지않네요.
select count(*) as cnt from g4_cost where (1) and ( ( like '%종로3가%') ) order by location1, location2 asc
1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%종로3가%') ) order by location1, location2
error file : /gnu/adm/cost_list.php
============================================================================
<?
$sub_menu = "300900";
include_once("./_common.php");
auth_check($auth[$sub_menu], "r");
$g4[title] = "배송비관리";
include_once("./admin.head.php");
$sql_common = " from g4_cost ";
$sql_search = " where (1) ";
if ($stx) {
$sql_search .= " and ( ";
$sql_search .= " ($sfl like '%$stx%') ";
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "location1, location2";
$sod = "asc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows = 100;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
$listall = "<a href='$_SERVER[PHP_SELF]' class=tt>처음</a>";
$colspan = 15;
?>
<script language="javascript" src="<?=$g4[path]?>/js/sideview.js"></script>
<table width=100%>
<tr>
<td width="7%"><?=$listall?></td>
<form name=fsearch method=get><td width="73%" align="right">
<p align="left"><b><font color="black">출발지=</font></b>
<input type=text name=stx required itemname='검색어' value='<? echo $stx ?>' size="20">
<font color="black"><b>도착지=</b></font> <input type=text name=stx required itemname='검색어' value='<? echo $stx ?>' size="20">
<input type=image src='<?=$g4[admin_path]?>/img/btn_search.gif' align=absmiddle></td></form><form name=fsearch method=post action="./cost_list_update.php">
<input type="hidden" name="sfl" value="<?=$sfl?>" />
<input type="hidden" name="stx" value="<?=$stx?>" />
<input type="hidden" name="page" value="<?=$page?>" /><td width="19%"> <input type=image src='img/save_all.jpg' border=0 title='수정' align=absmiddle></td>
</tr>
</table>
<table width="100%" cellpadding=0 cellspacing=0>
<tr><td width="50%" valign="top">
<table width="350" cellpadding=0 cellspacing=0>
<colgroup width=100>
<colgroup width=100>
<colgroup width=''>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='bgcol1 bold col1 ht center'>
<td><?=subject_sort_link('location1')?>출발지</a></td>
<td><?=subject_sort_link('location2')?>도착지</a></td>
<td><?=subject_sort_link('cost')?>금액</a></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<?
for ($i=0; $row=sql_fetch_array($result); $i++) {
$list = $i%2;
echo "
<tr class='list$list col1 ht center'><input type=hidden name=chk[] value='$i'><input type=hidden name=id[$i] value='$row[id]'>
<td><nobr style='display:block; overflow:hidden; width:350px;'><a href='cost_list.php?sfl=location1&stx=$row[location1]' class=tt>$row[location1]</a></nobr></td>
<td><nobr style='display:block; overflow:hidden; width:350px;'><a href='cost_list.php?sfl=location2&stx=$row[location2]' class=tt>$row[location2]</a></nobr></td>
<td><input name ='cost[$i]' value='$row[cost]' style='width:80;text-align:right'>원</td>
</tr>";
if($i==49) break;
}
if ($i == 0)
echo "<tr><td colspan='$colspan' align=center height=100 class=contentbg>자료가 없습니다.</td></tr>";
echo "<tr><td colspan='$colspan' class='line2'></td></tr>";
echo "</table>";
$pagelist = get_paging($config[cf_write_pages], $page, $total_page, "?$qstr&page=");
if ($stx)
echo "<script language='javascript'>document.fsearch.sfl.value = '$sfl';</script>\n";
?>
</td></tr>
</form>
</table>
<table width=100% cellpadding=0 cellspacing=0>
<tr><td align="center" height="30"><?=$pagelist?></td></tr>
</table>
<table width=100% cellpadding=0 cellspacing=0>
<tr>
<form name="new" action="./add_location.php"><td height="50" width="50%">새지역추가 : <input name="new_location" size="40">
<input type="image" src='<?=$g4[admin_path]?>/img/icon_insert.gif' border=0 title='추가' align="absmiddle"></td></form>
<form name="del" action="./del_location.php"><td align="right" height="50" width="50%">지역삭제 :
<select name="del_location">
<?
$result = sql_query("select distinct location1 from g4_cost");
while($row = sql_fetch_array($result)) {
echo "<option value='$row[location1]'>$row[location1]</option>";
}
?></select>
<input type="image" src='<?=$g4[admin_path]?>/img/icon_delete.gif' border=0 title='추가' align="absmiddle"></td></form>
</tr>
</table>
<?
include_once ("./admin.tail.php");
?>
</td>
</tr>
</table>
댓글 전체
예를 들면 `arrive` like '%종로3가%'
그런데 $sfl은 검색필드(search field)인데 검색필드가 지금 출발지와 도착지로 2개입니다.
일반적으로 $sfl에 검색필드를 여러개 놓으려면 ||로 연결해서 하면되지만(예: wr_5 || wr_6) 여기서는 출발지와 도착지는 절대 같을 수 없으므로 $sfl을 이용해서 하는 건 원하는 데이터를 얻지 못합니다. 따로 지정을 해주시는 게 나을 겁니다.
또 검색어인 $stx역시 출발지와 도착지 둘 다 지정되어 있으므로 지금 소스상으로는 출발지를 아무리 지정해도 도착지로만 검색됩니다. 이것도 따로 지정해 주시는 편이 나을 겁니다.
그런데 그렇게 하면 원 소스의 대폭적인 수정이 필요합니다.cost_list_update.php를 action값으로 갖는 form역시 수정을 해주어야 겠죠. 그럼 cost_list_update.php 역시 수정이 불가피하게 됩니다. 그 아래 for 구문 안에도 마찬가지구요. 이해가 됬는지 모르겠네요.
여러곳을 수정을 해야한다니... 그동안의 삽질을 끝내게 해주시네요
감사합니다.
결론은 하실줄아는분에게 의뢰를 부탁드려야 겠네요.