So, this is an offshoot to my little ASP.NET experiment. That's still going strong, but I'm working two angles to compare methods.
Here's where I'm at. For starters,
Code:
<html>
<body>
<form name="form" action="2nd.php" method="get">
<input type="text" name="q" />
<input type="submit" name="Submit" value="Search" />
</form>
</body>
</html>
Plain Jane, no styling form. Search bar and a submit button.
Here's "2nd" (As in, my 2nd attempt writing this.)
Code:
<html>
<body>
<?php
$username="root";
$password="password";
$database="airports";
mysql_connect('localhost',$username);
@mysql_select_db($database) or die( "Unable to select database");
$query = $_GET['q'];
$raw="SELECT * FROM restaurants where ICAO like '$query'";
$result=mysql_query($raw);
$num=mysql_numrows ($result);
mysql_close();
?>
<?php
echo ("You searched for: ");
echo ($query)
?>
<table>
<tr>
<td>Restuarant Name</td>
<td>Description</td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"ICAO");
$f3=mysql_result($result,$i,"RESTAURANTNAME");
$f4=mysql_result($result,$i,"DESCRIPTION");
?>
<tr>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
</body>
</html>
This was originally a demonstration code on how to query a MySQL database with PHP that I tweaked a little so that it only showed the entry that matches what was entered in the search bar.
What I'm trying to do is create a layout page of sorts that has a bunch of "blanks" for lack of a better word that are replaced with different parts of the query result.
I tried mixing and matching HTML into the code, reading online how to do it, utilizing quotes and all, but I can not get it work properly. The database is incomplete, there are a few more columns that need to be added.
The echo in the beginning is the closest I could come to creating a layout type feel, although what is echoed is not part of the result, but it simply restates what was typed in. I need that in the end, so that's good, but I can't mix the result into HTML. Any good tutorials on this would be great, I'm looking too.
Thanks in advance, as always.
Bill
P.S.-
Please, if in any way what I'm saying doesn't make sense, inform me. I'll try to clarify with a neat-o picture. I'm a MSPaint Wiz, and I can dandy you up with the sweet .bmp I'm visualizing in my head. It may help, it may make you wonder why I haven't considered an art major.