Jump to content
phynx

Problema cu php query...

Recommended Posts

Posted

<html>
<head>
<title>INTEROGARE BAZA DE DATE</title>
<style type="text/css">
table{
background-color: #FCF;
}
th {
width: 150px;
text-align: left;}
</style>

</head>
<body>

<form method="post" action="index.php">
<input type="hidden" name="trimis" value="true" />

<label>category:

<select name="category">
<option value="Nume">Nume</option>
<option value="Prenume">Prenume</option>
<option value="Data_Nasterii">Data_Nasterii</option>

</select>

</label>

<label>
criteria: <input type="text" name="criteria" />
</label>
<input type="submit" />
</form>

<?php

$link = mysqli_connect(.....);
if (isset($_POST['trimis'])) {
//conectare la baza de date
include('conectare.php');
$category = $_POST['category'] ;
$criteria = $_POST['criteria'];
$query = "SELECT * FROM elevi WHERE $category = '$criteria'";
$result = mysqli_query($link,$query) or die('eroare');

echo "<table>";
echo "<tr> <th>Nume</th> <th>Prenume</th> <th>Data nasterii</th> </tr>";

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<tr><td>";
echo $row['Nume'];
echo "</td><td>";
echo $row['Prenume'];
echo "</td><td>";
echo $row['Data_nasterii'];
echo "</td></tr>";


}


echo "</table>";



} // Sfarsitul principalului if




?>


</body>
</html>

Am acest cod care l-am facut pentru a interoga o baza de date dupa anumite criterii... Cand il execut imi afiseaza mesajul EROARE care il am aici "$result = mysqli_query($link,$query) or die('eroare');" .. Ce gresesc?? Conectarea la baza de date se face.. Tabelele sunt bune.. Nu inteleg.

Guest []kw3rln
Posted

baga or die(mysqli_error($link)) sau cum dreq e la mysqli

oricum primesti ban..sectiune gresita

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...