Jump to content

quick form help


pratkal

Recommended Posts

when i visit mydomain.com/search.php?stream=0 the script post all the result from stream = 0 from sql user ( stream 0 is shown in result as Math )when i visit mydomain.com/search.php?stream=1 ( stream id = 1 from sql ) the script show no result @ all

Link to comment
Share on other sites

  • Replies 64
  • Created
  • Last Reply

make sure that any rows returning or not when you pass 1 or rather than 0. you may add this line after mysql_query to be confirm.

echo mysql_num_rows($result);

it will show the return rows number.what is it printing?

Link to comment
Share on other sites

and one more thing

$row = mysql_fetch_assoc($result);
you should remove it. everytime you will use mysql_fetch_* internal resource pointer will move forward.So it could create unwanted trouble.
Link to comment
Share on other sites

while no result for other streams
if there is no result it wont show you anything.
Link to comment
Share on other sites

nvm still didnt worked

<?phpinclude 'config.php';$con = mysql_connect("$dbhost","$dbuser","$dbpass");if (!$con) {	echo "Unable to connect to DB: " . mysql_error();	exit;}mysql_select_db("$dbname");if (!mysql_select_db("$dbname")) {	echo "Unable to select mydbname: " . mysql_error();	exit;}$sql = "SELECT * FROM userWHERE `stream0`={$_GET['stream0']}OR`stream1`={$_GET['stream']}OR `stream2`={$_GET['stream0']}";$result = mysql_query($sql) or exit . mysql_error();$stream[0]="Math";$stream[1]="Physics";$stream[2]="Chemistry";$stream[3]="Computers Basic";$stream[4]="Computer laungages";$stream[5]="Computer Hardware";$stream[6]="Engg - M1 , M2 , M3";$stream[7]="English";$stream[8]="Management";$stream[9]="Principle";$stream[10]="Vice Principle";$stream[11]="Adminstartive";$stream[12]="Other";// While a row of data exists, put that row in $row as an associative array// Note: If you're expecting just one row, no need to use a loop// Note: If you put extract($row); inside the following	 loop, you'll//	   then create $userid, $fullname, and $userstatuswhile ($row = mysql_fetch_assoc($result)) {echo "USer Registration ID ";echo $row['id'] . "<BR>";echo "Name-";echo $row['name'] . "<BR>";echo "Email-";echo $row['email'] . "<BR>";echo "Mobile";echo $row['contact'] . "<BR>";echo "stream"; echo $stream[$_GET['stream']] . "<BR>";; echo Age;echo $row['date'];echo $row['month'];echo $row['year'] . "<BR>";}mysql_close($con);?>

why and is now presenting me with any result?sql seems to be working on phpmyadmin

SELECT * FROM userWHERE  `stream0` =5OR  `stream1` =3OR  `stream2` =2LIMIT 0 , 30

Link to comment
Share on other sites

what is the echo of $sql?. You need to check it that all expected data are coming or not from $_GET

Link to comment
Share on other sites

the request data is coming because script work fine earlier for 1 single searchok did a quick changeand was able to echo out the stream valueok edited the code little$st=$_GET['stream'];echo $st;$sql = "SELECT * FROM userWHERE stream0={$st}OR stream1={$st}OR stream2={$st}limit 0-100";what is possible mistake here

Link to comment
Share on other sites

i guess u meant sql table

	id	int(11)			No	None	AUTO_INCREMENT	 	 	 	 	 	 		username	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	password	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	name	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	email	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	######	varchar(10)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	date	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	month	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	year	varchar(25)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	edu	varchar(500)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	contact	varchar(10)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	sal	int(10)			No	None		 	 	 	 	 	 		address	varchar(100)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	stream0	varchar(500)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	stream1	varchar(500)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	stream2	varchar(500)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	status	varchar(500)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	esal	int(10)			No	None		 	 	 	 	 	 		currentjob	varchar(100)	latin1_swedish_ci		No	None		 	 	 	 	 	 	 	about	varchar(500)	latin1_swedish_ci		Yes	NULL		 	 	 	 	 	 	 	djob	varchar(500)	latin1_swedish_ci		No	None

Link to comment
Share on other sites

you need to echo this $sql

$sql = "SELECT * FROM userWHERE `stream0`={$_GET['stream0']}OR`stream1`={$_GET['stream']}OR `stream2`={$_GET['stream0']}";
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...