Hello everyone,
I am building a page where one should be able to put a "code" on a search form and see a table with all the entries...
I have build a table like this:
id | tblax | celulax | lop | pod | cidade1|
The search is made by the "tblax" so for exemple, if we have this:
id | tblax | celulax | lop | pod | cidade1|
1 | 1 | 1 | 1 | 2 | 3 |
2 | 1 | 2 | 5 | 9 | 9 |
3 | 9 | 6 | 1 | 8 | 8 |
4 | 1 | 8 | 3 | 6 | 7 |
5 | 5 | 1 | 1 | 2 | 8 |
and the user searched for " 1 " it would pick up all the "1" on the "tblax" and give this result:
1 | 1 | 1 | 2 | 3 |
1 | 2 | 5 | 9 | 9 |
1 | 8 | 3 | 6 | 7 |
however, I can only make it work with the first row, I am now sure how I can make the tables multiply themselves by this criteria...
Here's the important part of the codes I have, can you please let me know what's missing?
FIRST PHP - Form to pick up "tblax" code
<?php
$host="********"; // Host name
$username="********"; // Mysql username
$password="************"; // Mysql password
$db_name="*********"; // Database name
$tbl_name="**********"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("Não há ligação ao host");
mysql_select_db("$db_name")or die("Não há ligação à database");
// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?>
<form id="form1" method="post" action="searching.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32%">Código de tabela:</td>
<td width="34%"> <label>
<input name="tblax" type="text" id="tblax" size="25" />
</label></td>
<td width="34%">
<input type="submit" name="Submit" value="Pesquisa" /></td>
</tr>
</table>
</form>
SECOND PHP - Searching.php ( results )
<?php
$host="************"; // Host name
$username="***************"; // Mysql username
$password="***********"; // Mysql password
$db_name="**********"; // Database name
$tbl_name="*********"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("Não há ligação ao host");
mysql_select_db("$db_name")or die("Não há ligação à database");
// get value of id that sent from address bar
$id=$_GET['id'];
$tblax=$_GET['tblax'];
// Retrieve data from database
$sql="SELECT * FROM $tbl_name WHERE tblax='$tblax'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);?>
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="18%"><div align="center"><strong>Tabela</strong></div></td>
<td width="30%"><div align="center"><strong>celula</strong></div></td>
<td width="20%"><div align="center"><strong>lop</strong></div></td>
<td width="21%"><div align="center"><strong>pod</strong></div></td>
<td width="11%"><div align="center"><strong>cidade</strong></div></td>
</tr>
<tr>
<td><div align="center"><? echo $rows['tblax']; ?></div></td>
<td><div align="center"><? echo $rows['celulax']; ?></div></td>
<td><div align="center"><? echo $rows['lop']; ?></div></td>
<td><div align="center"><? echo $rows['pod']; ?></div></td>
<td><div align="center"><? echo $rows['cidade']; ?></div></td>
</tr>
</table>
I have tried a bunch of things but I can't seem to make it work and show all the respective collumns... please help!