Wenn ich auf diese Seite gehe Es ist bereits die leere Zeichenfolge in der Variablen suchen, bevor Sie den Wert in Option auswählen. Ich möchte nur den Wert suchen, wenn die Schaltfläche nicht automatisch durchsucht wird, wenn der Benutzer auf diese Seite geht. Und außerdem gibt es ein Problem bei meiner "asc" Abfrage.So durchsuchen Sie das Leerzeichen in der Abfrage nicht
Wenn ich auf diese Seite gehe. Es ist bereits suchen und die leeren Werte Already Search the Blank
zeigen, und ich fügen Sie diesen Code $asc
aber wie Sie in dem Bild sehen kann es zeigt einen Fehler, aber wenn ich in der Auswahloption auswählen wird der Fehler verschwinden und den Wert zeigen . this Ascending to Descending
Bitte geben Sie die Details Unten
<div class="nice" style=" width:20%; margin-left:10%; z-index:100px;">
<div class="control-group">
<label class="control-label" for="inputPassword">Search Catalog:</label>
<div class="controls">
<select name="catalogs">
<option></option>
<?php $result = mysqli_query($dbcon,"select * from book_catalog")or die(mysqli_error());
while ($row=mysqli_fetch_array($result)){ ?>
<option value="<?php echo $row['catalog']; ?>"><?php echo $row['catalog']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Author:</label>
<div class="controls">
<select name="status">
<option></option>
<option>Local</option>
<option>Foreign</option>
</select>
</div>
</div>
<div class="control-group" style="margin-left:210%; margin-top:-150px;">
<label class="control-label" for="inputPassword">Ascending-Descending</label>
<div class="controls">
<select name="asc" >
<option></option>
<option value="acc_id">Accession Number</option>
<option value="author">Author</option>
<option value="book_title">Book Title</option>
<option value="publisher_name">Publisher Name</option>
<option value="copyright_year">Copyright Year</option>
<option value="date_added">Date Added</option>
</select>
</div>
</div>
</div>
<input type="submit" name="submit" value="Search" style="margin-left:43%; margin-top:10%;" /> <br>
</form>
</div>
<?php
$selected_stat = "";
$selected_val = "";
$asc =""; // Storing Selected Value In Variable
if(isset($_POST['submit'])){
$selected_val = $_POST['status'];
$selected_stat = $_POST['catalogs'];
$asc = $_POST['asc']; // Storing Selected Value In Variable
}
?>
<br>
<thead>
<tr>
<th>Acc No.</th>
<th>Call Number</th>
<th>Author</th>
<th>Author Category</th>
<th>Book Title</th>
<th>Category</th>
<th>Book Copies</th>
<th>Publisher Name</th>
<th>Copyright Year</th>
<th>Date Added</th>
<th class="action">Action</th>
</tr>
</thead>
<tbody>
<?php $user_query=mysqli_query($dbcon,"select * from book where catalog = '$selected_stat' OR status = '$selected_val' ORDER BY book.$asc ASC")or die(mysqli_error($dbcon));
while($row=mysqli_fetch_array($user_query)){
$id=$row['book_id'];
?>
<tr class="del<?php echo $id ?>">
<td><?php echo $row['acc_id']; ?></td>
<td><?php echo $row['callnum']; ?></td>
<td><?php echo $row['author']; ?> </td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['book_title']; ?> </div></td>
<td><?php echo $row ['catalog']; ?> </td>
<td class="action"><?php echo $row['book_copies']; ?> </td>
<td><?php echo $row['publisher_name']; ?></td>
<td><?php echo $row['copyright_year']; ?></td>
<td><?php echo $row['date_added']; ?></td>
<?php include('toolttip_edit_delete.php'); ?>
<td class="action">
<a rel="tooltip" title="Delete" id="<?php echo $id; ?>" href="#delete_book<?php echo $id; ?>" data-toggle="modal" class="btn btn-danger"><i class="icon-trash icon-large"></i></a>
<?php include('delete_book_modal.php'); ?>
<a rel="tooltip" title="Edit" id="e<?php echo $id; ?>" href="edit_book.php<?php echo '?id='.$id; ?>" class="btn btn-success"><i class="icon-pencil icon-large"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
Sorry für mein schlechtes Englisch
Sie haben einen Fehler in Ihrer SQL-Syntax; Überprüfen Sie das Handbuch, das Ihrer MySQL-Server-Version für die richtige Syntax in der Nähe von "ASC" in Zeile 1 –