在开始之前,我知道还有更多高级方法,但这是针对 一个类项目,我必须用HTML和PHP开发它……我已经 在我的代码中使用一些Bootstrap东西,我不确定它不会 给我老师带来麻烦
所以我有这个项目,我需要帮助,因为我厌倦了撞墙撞头...
我必须创建一个搜索引擎页面来捕获3个(或所有这些)posibl值之一,这些值是用户ID,合同ID和本地ID(种类的地址),我开发了此PHP代码,以Todd Howards著名词“它起作用了……它起作用了”
<?php
//inicio de conexion y verificacion de errores//
$con = mysqli_connect ("localhost" , "root" , "");
if (!$con)
{
echo 'No conecta al servidor';
}
if (!mysqli_select_db($con,'estrella'))
{
echo 'No conecta a base de datos';
}
//Recupera valor de busqueda//
$Bcedula = $_GET['Bcedula'];
$Blocal = $_GET['Blocal'];
$Bcontrato = $_GET['Bcontrato'];
$min_length =3;
//funcion busqueda por cedula//
switch (true)
{
case (strlen($Bcedula) >= $min_length):
$Bcedula = htmlspecialchars($Bcedula);
$rawresults = mysqli_query($con, "SELECT * FROM contrato WHERE (Ncedula LIKE '%".$Bcedula."%')");
break;
case (strlen($Blocal) >= $min_length):
$Blocal = htmlspecialchars($Blocal);
$rawresults = mysqli_query($con, "SELECT * FROM contrato WHERE (Nlocal LIKE '%".$Blocal."%')");
case (strlen($Bcontrato) >= $min_length):
$Bcontrato = htmlspecialchars($Bcontrato);
$rawresults = mysqli_query($con, "SELECT * FROM contrato WHERE (Ncontrato LIKE '%".$Bcontrato."%')");
default:
echo 'error dato no encontrado';
break;
}
header("Refresh:1; url=busqueda.html");
if(mysqli_num_rows($rawresults) > 0){ // if one or more rows are returned do following
while($results = mysqli_fetch_array($rawresults)){
// $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop
echo("<p> Contrato, Cedula, Nombres, Apellidos, Local, Nit, CC, Direccion, Telefono, Valor total, Fecha inicio, N. Cuoas.</p></br>");
echo "<p>" .$results['Ncontrato'].", ".$results['Ncedula'].", ".$results['Nombre1']." ".$results['Nombre2']." ".$results['Apellido1']." ".$results['Apellido2'].", ".$results['Nlocal'].", ".$results['Nnit'].", ".$results['Ncamara'].", ".$results['Direccion'].", ".$results['Telefono'].", ".$results['Vcontrato'].", ".$results['Vfechainicio'].", ".$results['Vcuotas'].
"</p>";
// posts results gotten from database(title and text) you can also show id ($results['id'])
echo mysqli_error($con);
}
}
else{ // if there is no matching rows do following
echo "No results";
}
header("url=busqueda.html")
?>
它打印出丑陋的2串代码,而Im现在正在将其制成表格...这是问题所在...我有一个html页面,它调用php,看起来像这样
<html>
<head>
<title>Busqueda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
#Table_01 {
font-size: 10px;
background-image: url(images/Busqueda.jpg);
background-repeat: no-repeat;
}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Busqueda.psd) -->
<table id="Table_01" width="1109" height="471" border="0" cellpadding="0" cellspacing="0">
<form method="get" action="busqueda.php">
<input style="width:354px; height:20px" type="text" name="Bcedula"></td>
<input style="width:354px; height:20px" type="text" name="Nlocal"></td>
<input style="width:354px; height:20px" type="text" name="Bcontrato"></td>
</form>
<form mehod="post" action="busqueda.php">
<input style="width:912px; height:283" type="search" name="Rbusqueda">
</form>
</table>
</body>
</html>
看起来像这样 Search Engine made by me... please dont laugh too hard
所以...这是我想使它变得更好一点的交易,并在那里得到了一些引导程序代码...并为我制作了一个带有巨无霸和一张桌子的桌子...代码看起来像这样< / p>
<div class="container">
<div class="jumbotron">
<table class="table table-hover">
<thead>
<tr>
<th># de Contrato</th>
<th># de Cedula</th>
<th>Primer Nombre</th>
<th>Segundo Nombre</th>
<th>Primer Apellido</th>
<th>Segundo Apellido</th>
<th>Local</th>
<th>Nit</th>
<th>Camara de Comercio</th>
<th>Direccion</th>
<th>Telefono</th>
<th>Fecha de inicio</th>
</tr>
</thead>
<tbody>
<tr>
<?php
include 'busqueda.php';
foreach($results as $row) : ?>
<td><?php echo $row->Ncontrato ?></td>
<td><?php echo $row->Ncedula ?></td>
<td><?php echo $row->Nombre1 ?></td>
<td><?php echo $row->Nombre2 ?></td>
<td><?php echo $row->Apellido1 ?></td>
<td><?php echo $row->Apellido2 ?></td>
<td><?php echo $row->Nlocal ?></td>
<td><?php echo $row->Nnit ?></td>
<td><?php echo $row->Ncamara ?></td>
<td><?php echo $row->Direccion ?></td>
<td><?php echo $row->Telefono ?></td>
<td><?php echo $row->Vcontrato ?></td>
<td><?php echo $row->Vfechainicio ?></td>
<td><?php echo $row->Vcuotas ?></td>
</tr>
</tbody>
</table>
</div>
</div>
它用HTML代替了我以前尝试创建的Rbusqueda表单 但是它不起作用,我开始发疯...所以有人可以在这里帮助我吗?...漂亮吗?