Fixed the bug #424278: Display xx records on the select page

This commit is contained in:
Loïc Chapeaux
2001-05-18 21:34:58 +00:00
parent dbbbe7757f
commit 49d504fe82

View File

@@ -5,17 +5,14 @@
require("grab_globals.inc.php3"); require("grab_globals.inc.php3");
if(!isset($param) || $param[0] == "") if(!isset($param) || $param[0] == "") {
{ include("header.inc.php3");
require("header.inc.php3"); $result = mysql_list_fields($db, $table);
$result = mysql_list_fields($db, $table); if (!$result) {
if (!$result) mysql_die();
{ }
mysql_die(); else {
} ?>
else
{
?>
<form method="POST" ACTION="tbl_select.php3"> <form method="POST" ACTION="tbl_select.php3">
<input type="hidden" name="server" value="<?php echo $server;?>"> <input type="hidden" name="server" value="<?php echo $server;?>">
<input type="hidden" name="lang" value="<?php echo $lang;?>"> <input type="hidden" name="lang" value="<?php echo $lang;?>">
@@ -25,19 +22,18 @@ if(!isset($param) || $param[0] == "")
<select multiple NAME="param[]" size="10"> <select multiple NAME="param[]" size="10">
<?php <?php
for ($i=0 ; $i<mysql_num_fields($result); $i++) for ($i=0 ; $i<mysql_num_fields($result); $i++) {
{ $field = mysql_field_name($result,$i);
$field = mysql_field_name($result,$i); if($i >= 0)
if($i >= 0) echo "<option value=$field selected>$field</option>\n";
echo "<option value=$field selected>$field</option>\n"; else
else echo "<option value=$field>$field</option>\n";
echo "<option value=$field>$field</option>\n"; }
}
?> ?>
</select><br> </select><br>
<div align="left"> <div align="left">
<ul><li><?php echo $strDisplay; ?> <input type="text" size=4 name = "sessionMaxRows" value=<?php echo $cfgMaxRows; ?>> <ul><li><?php echo $strDisplay; ?> <input type="text" size=4 name="sessionMaxRows" value=<?php echo $cfgMaxRows; ?>>
<?php echo $strLimitNumRows; ?> <?php echo $strLimitNumRows; ?>
<li><?php echo $strAddSearchConditions; ?><br> <li><?php echo $strAddSearchConditions; ?><br>
<input type="text" name="where"> <?php print show_docu("manual_Reference.html#Functions");?><br> <input type="text" name="where"> <?php print show_docu("manual_Reference.html#Functions");?><br>
@@ -52,67 +48,70 @@ if(!isset($param) || $param[0] == "")
</tr> </tr>
<?php <?php
$result = mysql_list_fields($db, $table); $result = mysql_list_fields($db, $table);
for ($i=0;$i<mysql_num_fields($result);$i++) for ($i=0;$i<mysql_num_fields($result);$i++) {
{ $field = mysql_field_name($result,$i);;
$field = mysql_field_name($result,$i);; $type = mysql_field_type($result,$i);
$type = mysql_field_type($result,$i); $len = mysql_field_len($result,$i);
$len = mysql_field_len($result,$i); $bgcolor = $cfgBgcolorOne;
$bgcolor = $cfgBgcolorOne; ($i % 2) ? 0: $bgcolor = $cfgBgcolorTwo;
$i % 2 ? 0: $bgcolor = $cfgBgcolorTwo;
echo "<tr bgcolor=".$bgcolor.">"; echo "<tr bgcolor=".$bgcolor.">";
echo "<td>$field</td>"; echo "<td>$field</td>";
echo "<td>$type</td>"; echo "<td>$type</td>";
echo "<td><input type=text name=fields[] style=\"width: ".$cfgMaxInputsize."\" maxlength=".$len."></td>\n"; echo "<td><input type=text name=fields[] style=\"width: ".$cfgMaxInputsize."\" maxlength=".$len."></td>\n";
echo "<input type=hidden name=names[] value=\"$field\">\n"; echo "<input type=hidden name=names[] value=\"$field\">\n";
echo "<input type=hidden name=types[] value=\"$type\">\n"; echo "<input type=hidden name=types[] value=\"$type\">\n";
echo "</tr>"; echo "</tr>";
} }
echo "</table><br>"; echo "</table><br>";
?> ?>
<input name="SUBMIT" value="<?php echo $strGo; ?>" type="SUBMIT"> <input name="SUBMIT" value="<?php echo $strGo; ?>" type="SUBMIT">
</form></ul> </form></ul>
<?php <?php
}
require ("footer.inc.php3");
}
else
{
$sql_query="SELECT $param[0]";
$i=0;
$c=count($param);
while($i < $c)
{
if($i>0) $sql_query .= ",$param[$i]";
$i++;
}
$sql_query .= " from $table";
if ($where != "") {
$sql_query .= " where $where";
} else {
$sql_query .= " where 1";
for ($i=0;$i<count($fields);$i++)
{
if (!empty($fields) && $fields[$i] != "") {
$quot="";
if ($types[$i]=="string"||$types[$i]=="blob") {
$quot="\"";
$cmp="like";
} elseif($types[$i]=="date"||$types[$i]=="time") {
$quot="\"";
$cmp="=";
} else {
$cmp="=";
$quot="";
if (substr($fields[$i],0,1)=="<" || substr($fields[$i],0,1)==">") $cmp="";
}
$sql_query .= " and $names[$i] $cmp $quot$fields[$i]$quot";
}
}
}
Header("Location:sql.php3?sql_query=".urlencode($sql_query)."&goto=db_details.php3&server=$server&lang=$lang&db=$db&table=$table&pos=0&sessionMaxRows=$sessionMaxRows");
} }
include("footer.inc.php3");
}
else {
$sql_query="SELECT $param[0]";
$i=0;
$c=count($param);
while($i < $c) {
if($i>0) $sql_query .= ",$param[$i]";
$i++;
}
$sql_query .= " from $table";
if ($where != "") {
$sql_query .= " where $where";
}
else {
$sql_query .= " where 1";
for ($i=0;$i<count($fields);$i++) {
if (!empty($fields) && $fields[$i] != "") {
$quot="";
if ($types[$i]=="string"||$types[$i]=="blob") {
$quot="\"";
$cmp="like";
}
elseif($types[$i]=="date"||$types[$i]=="time") {
$quot="\"";
$cmp="=";
}
else {
$cmp="=";
$quot="";
if (substr($fields[$i],0,1)=="<" || substr($fields[$i],0,1)==">") $cmp="";
}
$sql_query .= " and $names[$i] $cmp $quot$fields[$i]$quot";
}
}
}
if (empty($sessionMaxRows)) {
include("config.inc.php3");
$sessionMaxRows = $cfgMaxRows;
}
Header("Location:sql.php3?sql_query=".urlencode($sql_query)."&goto=db_details.php3&server=$server&lang=$lang&db=$db&table=$table&pos=0&sessionMaxRows=$sessionMaxRows");
}
?> ?>