AlexOleynik
Новичок
- Регистрация
- 19.02.2009
- Сообщения
- 4
Всем привет. Есть две таблицы ( в одной таблицы перечисленны все книги "medien", а в другой какие книги в данный момент на руках "ausleih") .Какай запрос нужно написать ,чтобы в калонке на веб-стронице вывадилось "на руках"-если она есть в таблице "ausleih" и "можете заказать" -если её в таблице "ausleih" нету.
Код:
<?php require_once('Connections/daabiblio.php'); ?>
<?php require_once('Connections/daabiblio.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_Recordset1 = 30;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$colname_Recordset1 = "word";
if (isset($_GET['word'])) {
$colname_Recordset1 = $_GET['word'];
}
mysql_select_db($database_daabiblio, $daabiblio);
$query_Recordset1 = sprintf("SELECT row_id, mnummer, autor, titel, utitel FROM medien WHERE titel LIKE (%s) OR utitel LIKE (%s) ORDER BY row_id ASC", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"),GetSQLValueString("%" . $colname_Recordset1 . "%", "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $daabiblio) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
mysql_select_db($database_daabiblio, $daabiblio);
$query_Recordset2 =.............. "SELECT row_id, mnum FROM ausleih ORDER BY row_id ASC";.........
$Recordset2 = mysql_query($query_Recordset2, $daabiblio) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="1080" border="1">
<tr>
<td width="43"> </td>
<td width="135"> </td>
<td width="141"> </td>
<td width="498"> </td>
<td width="119"> </td>
<td width="104"> </td>
</tr>
</table>
<?php do { ?>
<table width="1079" border="1">
<tr>
<td width="133"><?php echo $row_Recordset1['row_id']; ?></td>
<td width="136"><?php echo $row_Recordset1['titel']; ?></td>
<td width="142"><?php echo $row_Recordset1['autor']; ?></td>
<td width="348"><?php echo $row_Recordset1['utitel']; ?></td>
<td width="148"><?php .............echo $row_Recordset1['mnummer'];............. ?></td>
</td>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
Вложения
-
4,8 КБ Просмотры: 37