2 Replies - 414 Views - Last Post: 15 December 2011 - 04:34 AM Rate Topic: -----

#1 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Searching specific type..

Posted 15 December 2011 - 03:02 AM

i dont know if the title is correct but what i want my code to be is like this:

I want to Generate a certain report
like only the accounts who's name is "zyra" or only the accounts that are made in a certain branch like only in "first branch" or in "Second Branch" etc.

or generate/print only the one who availed the service "Braces" or " cleaning of Teeth" and more to be specific..

my code as of now is like this
<?php
   
	echo "<div name=\"repsel\">";
	echo "<a href=\"genrep.php?action=userinfo\">User Information</a><br/>";
	echo "<a href=\"genrep.php?action=usertreatment\">Users Accounts</a><br/>";
	echo "<a href=\"genrep.php?action=appointments\">Appointments Made</a>";
	echo "</div>";
	//User Appointments load
   if(isset($_GET["action"]) && $_GET["action"] == "appointments"){
	$_POST['SUBMITTED']=true;
	echo "<form method=\"post\" action=\"genrep.php?action=appointments\">";
	echo "<input type='text' name='search'/>";
	echo "Search by:<select name='typie'>";
	echo "<option value='firstname'>name</option>";
	echo "<option value='branch'>branch</option>";
	echo "<option value='availed_service'>service</option>";
	echo "<option value='address'>address</option>";
	echo "<option value='dentistname'>dentist name</option>";
	echo "</select>";
	echo "<input type=\"submit\" name=\"SUBMITTED\" value=\"submit\">";
	echo "</form>";
	
	if(isset($_POST['SUBMITTED'])){
	     echo $type = $_POST['typie'];
		 echo "<br/>";
		 echo $what = $_POST['search'];
			$zxc="SELECT * FROM appointments WHERE '$type' = '$what'";
			$query=mysql_query($zxc) or die(mysql_error());
			$_SESSION['print']=$zxc;
			$_SESSION['ano']="Appointments";
			echo "<p><a href=\"print.php\"><input type='submit' value='Print'/></a></p>";
			echo "<table border=\"1\" >";	
			echo "<tr><td>First Name</td><td>Last Name</td><td>Address</td><td>Dentist Name</td><td>Availed Services</td><td>Payment</td><td>Date</td><td>Time</td><td>Remarks</td></tr>";	
			while($arr=mysql_fetch_array($query)){
			echo "<tr><td>".$arr['firstname']."</td><td>".$arr['lastname']."</td><td>".$arr['address']."</td><td>".$arr['dentistname']."</td><td>".$arr['availed_service']."</td><td>".$arr['payment']."</td><td
			>".$arr['date']."</td><td>".$arr['time']."</td><td>".$arr['remarks']."</td></tr>";
	}	
			echo "</table>";
		
	}
			
	}
?>



but the problem is it wont show any output after submitting a query or a input
any help would be appreciated well.

i hope i explained it well..

This post has been edited by Syfer: 15 December 2011 - 03:10 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Searching specific type..

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,256
  • Joined: 08-June 10

Re: Searching specific type..

Posted 15 December 2011 - 04:09 AM

issue 1, you don't open a session, which should generate a couple of warnings.

issue 2, on line 27 you compare 2 values. if they match, the query returns your complete database, otherwise nothing at all. (you probably meant the first to be the field name, but you would have to quote that by backticks, not apostrophes)

issue 3, you're highly susceptible to SQL injection.

This post has been edited by Dormilich: 15 December 2011 - 04:10 AM

Was This Post Helpful? 3
  • +
  • -

#3 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Re: Searching specific type..

Posted 15 December 2011 - 04:34 AM

Thanks :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1