voir ma recherche en php de dat, Ceci est mon code à ce jour:Affichage dans le tableau si la recherche correspond en php
<?php
if (isset($_POST["name"]))
{
$file = 'order.dat';
$searchfor = $_POST["name"];
// the following line prevents the browser from parsing this as HTML.
// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($file);
// escape special characters in the query
$pattern = preg_quote($searchfor, '/');
//$pattern = "/^$pattern/m"; // your string starts with $pattern (177)
$pattern = "/^$pattern.*$/m";
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
echo "Found matches:\n";
echo implode("\n", $matches[0]);
}
else{
echo "No matches found";
}
}
?>
<h3>Search Order Details</h3>
<form method="post" action="search.php" id="searchform">
<input type="text" name="name">
<input type="submit" name="submit" value="Search">
</form>
fichier order.dat contient: -
175|RC456456456|54156456177|177$
176|RC456456177|54156456177|177$
177|RC456456177|54156456465|129$
178|RC456456456|54156456177|177$
maintenant en ce moment, si la recherche se trouve alors il dit ... comme les correspondances trouvées si j'entre 177 donne la Found matches: 177|RC456456177|54156456465|129$
maintenant si j'entre 002 il dit Aucun résultat trouvé
Je veux afficher dans ce tableau si correspond à la recherche: -
<table>
<tr>
<th>Order number </th>
<th>Tranasaction id</th>
<th>Date </th>
<th>Total Price</th>
</tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</table>
Je ne sais pas ce que votre question est exactement? –
@David Je ne sais pas quelle est votre question. – Devator
@Pekka voir je veux mettre mes données dans le tableau si la recherche correspond ... comme si je saisis 177 il donne Trouvé: 177 | RC456456177 | 54156456465 | 129 $ maintenant je veux mettre ces détails dans le tableau ... signifie que je veux afficher ceci dans la table ... – John