to retrieve field name from database - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > PHP » to retrieve field name from database


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-12-2006   #1 (permalink)
aaron
Junior Member
 
Join Date: Jul 2006
Age: 52
Posts: 24
Default to retrieve field name from database

hello,
i have the form which has text box called hotel name and a button called "GO"..
when I insert the hotel name in d box and click on "GO" button, i need to select the exact match from database and display on the page..

here is the form that allows hotel name to b entered..
<html>
<head>
<title>Search Hotel name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php

echo'<form method="Post" action="select_list.php">';
echo "<table border='0'>";

echo"<tr><td valign=top align='left'>Hotel Name</td><td valign=top width=67%><input type=text name=hotelname value=".$hotelname."></td></tr>";

echo"<tr><td colspan=2 align=right><input type=submit value=Go></td></tr>";

echo"</table>";
echo"</form>";

?>
</body>
</html>


here is d PHP code tht shld retrieve data from tables;;

<html>
<head>
<title>select List</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
mysql_select_db('Travel') or die("cannot select the database");
$hotelname=$_POST['hotelname'];

$query="SELECT Hotel_name FROM hoteldetails ";
if($hotelname).$query.= "AND hotel_name LIKE '%$hotelname%'";
$query.="ORDER BY hotel_name ";

$result=mysql_query($query) or die ("Query failed:" );
echo'<table border="1"><tr><td>Hotel Name</td></tr>';
while(list($hotelname)=mysql_fetch_row($result)){
echo'<tr><td>$hotelname</td></tr>';
}
echo'</table>';

?>
</body>
</html>
bt it is not able to retrive data..plz help me out

thanks..
Aaron
aaron is offline   Reply With Quote


Old 07-13-2006   #2 (permalink)
robtrevino
Member
 
Join Date: Jul 2006
Age: 26
Posts: 30
Default

what error are you getting? I assume you have phpmyadmin or something like that. Try entering the sQL directly into it and see what it tells you.
robtrevino is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you access a field value in the current record? agaba175 ASP 0 08-05-2006 08:20 PM
Database Links aaron Programming 0 07-29-2006 04:18 PM
SCIFI Database Aqua All Things General 20 07-24-2006 03:44 PM
Unable to retrieve large amount of data from a textarea control clayton ASP 0 07-08-2006 06:28 PM


footer left
All times are GMT. The time now is 10:00 PM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Loan | Loans | Mortgages | Loan | Free Ringtone

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49