Php Mysql

Status
Not open for further replies.

jay_bo

Daemon Poster
Messages
889
hi i have created a mysql table database and i wanted to inclucde it into my site. what i want to do is create a form to search the database. Can anyone help me do it, i need help linking the database to the site.

What i want to do is they do fill in a form when they want to come and stay at the hotel and then it comes up with what rooms are availble, but if i did it in mysql wont there be loads of dates and time consuming in doing it.

thanks, Also could i use Ms Access instead of My sql which one would be better
 
What you want basically is a search form and the reason behind it is for a hotel buisness wants a program that tells them which room is available for rent? I wouldn't see any reason for a date and time unless you want to include how many days left until a guest has before they are kicked out or will have to pay more for more stays...

Pretty much you will need this basic code to "select" the table. I got the example from here: MySQL Tutorial - Select

<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM example")
or die(mysql_error());

echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Age</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['age'];
echo "</td></tr>";
}

echo "</table>";
?>
 
i have more than 1 problem. My database is password procted so wont i need to include it in that text. And i mean say todays date is the 27 june 2007 a i wanted to see if i could get a room fr 20 december 07 they will have to be loads of date up to december.
 
Sorry. I should have explained the connection part.

In the mysql_connect() your password goes in the third section:
mysql_connect("localhost", "login name", "password") or die(mysql_error());

In the section here you specify which database to use.
mysql_select_db("database name") or die(mysql_error());

As far as the dates and such, I'm not too sure. I've started learning php, but then I started learning flash. My best suggestion is to find a tutorials site, or even better go to a Barnes & Noble and find you a book for php & mysql, read through it and you should get your answer.
 
so i just drag my mysql database into the server, what about if you dont use a username?
 
Status
Not open for further replies.
Back
Top Bottom