Jump to content

celestineweb

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

celestineweb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I solved it:- if ($num<=0) { echo "we do not have anyone listed in this town yet please press back button to make another selection"; ?> </div> <? include '../ssi/right_nav.php'; include '../ssi/footer.php'; exit; } If anyone has a nicer way of doing this please let me know
  2. The script below calls other scripts to build the page. <? include '../ssi/top.php'; include '../ssi/left_nav.php'; include '../ssi/headline1.php'; include '../ssi/headline2.php'; include '../ssi/headline3.php'; include '../ssi/advert1.php'; include '../ssi/content.php'; include '../ssi/right_nav.php'; include '../ssi/footer.php'; ?> This is part of the content.php script:- $query="SELECT * FROM users WHERE country='$country' ORDER BY last_name ASC"; $result=mysql_query($query); $num=mysql_numrows($result); //error checking country if ($num<=0) { echo "we do not have anyone listed in this country yet please press back button to make another selection"; exit; } If the 'if' statement is true the script exits and does not action :- include '../ssi/right_nav.php'; include '../ssi/footer.php'; in the layout page. Is there a way round this, I have tried including the above in the if statement and read throught the books but cannot find a solution. If I remove the exit statement the page loads ok but also shows results from the database that are not wanted.
  3. On further checking if I put in the search:- Catagory=A Town=B Country=C It finds records that equal A, B & C but it also finds records with A & C where be = something else but it includes this record because it hase something in the field and nurrows is greater than 0. Do I have to live with this or is there a better solution than the one I found?
  4. Thanks for pointing me in the right direction I had gone round this problem so many time I could not see the wood for the trees. Changed Query section to this:- //$result=mysql_query($query); $query="SELECT * FROM listings WHERE therapist_catagory='$catagory'"; $result=mysql_query($query); $num=mysql_numrows($result); echo "num=$num"; //error checking catagory if ($num<=0) { echo "we do not have a listing for this catagory yet - please press back button to make another selection"; exit; } $query="SELECT * FROM listings WHERE town='$town'"; $result=mysql_query($query); $num=mysql_numrows($result); //error checking town if ($num<=0) { echo "we do not have a listing for this catagory yet - please press back button to make another selection"; exit; } $query="SELECT * FROM listings WHERE country='$country'"; $result=mysql_query($query); $num=mysql_numrows($result); //error checking country if ($num<=0) { echo "we do not have a listing for this catagory yet - please press back button to make another selection"; exit; } and it does everything I want it to. Will change the echo "we do not..... to link to an error page later when I build the site around this database.
  5. Hi Search form has three values it submits to my php script. It searches the database and produces results found. I want to check that each value submitted by the form actually exists in the database and if not throw you back to search form. <? $username="******"; $password="*****"; $database="******"; //Retreive data from form $catagory = $_POST['catagory']; $town = $_POST['town']; $country = $_POST['country']; //Error check form input if ($town=="") { echo "You must enter a town near you for an accurate search - Press back button to try again"; } if ($country=="") { echo "Please enter the country you wish to search in - Press back button to try again"; } //trim trim ($catagory || $town || $country); //Test input for debugging only echo $catagory; echo $town; echo $country; //Connect to database mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); //query database $query=("SELECT * FROM listings WHERE therapist_catagory='$catagory'and town='$town' and country='$country'"); $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center><h1>Search Results</h1></center></b><br><hr><br>"; $i=0; while ($i < $num) { $first_name=mysql_result($result,$i,"first_name"); $last_name=mysql_result($result,$i,"last_name"); $company_name =mysql_result($result,$i,"company_name"); $phone_number=mysql_result($result,$i,"phone_number"); $mobile=mysql_result($result,$i,"mobile"); $email=mysql_result($result,$i,"email"); $therapist_catagory =mysql_result($result,$i,"therapist_catagory"); $website =mysql_result($result,$i,"website"); $town =mysql_result($result,$i,"town"); $country=mysql_result($result,$i,"country"); $description=mysql_result($result,$i,"description"); $email_repeat=mysql_result($result,$i,"email_repeat"); //error checking //if ($therapist_catagory!=$catagory) //{ //echo "we do not have a listing for this catagory yet - please press back button to make another selection"; //} ?> <link href="/css_files/wolo.css" rel="stylesheet" type="text/css"> <table width="70%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr> <td width="38%"><h3 align="left">Name</h3></td> <td width="62%"><p align="left"><? echo "$first_name $last_name" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Company Name</h3></td> <td width="62%"><p align="left"><? echo "$company_name" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Phone Number</h3></td> <td width="62%"><p align="left"><? echo "$phone_number" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Mobile</h3></td> <td width="62%"><p align="left"><? echo "$mobile" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Email</h3></td> <td width="62%"><a href="mailto:<? echo "$email"?>"><p><? echo "$email"?></p></a></td> </tr> <tr> <td width="38%"><h3 align="left">Therapist Catagory</h3></td> <td width="62%"><p align="left"><? echo "$therapist_catagory" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Website Address</h3></td> <td width="62%"><a href="<? echo $website;?>"><p><? echo "$website"?></p></a></td> </tr> <tr> <td width="38%"><h3 align="left">Town</h3></td> <td width="62%"><p align="left"><? echo "$town" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Country</h3></td> <td width="62%"><p align="left"><? echo "$country" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Description Of Service Offered</h3></td> <td width="62%"><p align="left"><? echo "$description" ?></p></td> </tr> <tr> <td width="38%"><h3 align="left">Email Confirmation</h3></td> <td width="62%"><a href="mailto:<? echo "$email_repeat"?>"><p><? echo "$email_repeat"?></p></a></td> </tr> </table ><br><hr><br> <? $i++; } ?> Database fields (reproduced here as best I can):- Field Type Null Default id int(7) Yes NULL first_name varchar(50) Yes NULL last_name varchar(50) Yes NULL company_name varchar(50) Yes NULL phone_number varchar(11) Yes NULL mobile varchar(11) Yes NULL email varchar(50) Yes NULL therapist_catagory varchar(50) Yes NULL website varchar(50) Yes NULL town varchar(50) Yes NULL country varchar(50) Yes NULL description longtext Yes NULL email_repeat varchar(50) Yes NULL Any suggestions greatfullt recieved.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.