nav33n 472 Purple hazed! Team Colleague Featured Poster

Why not use order by clause in your query itself ?

$query = "select * from table order by colname [asc | desc ]";

[asc | desc ] is optional. You can sort the records in ascending order or descending order on one or multiple columns.
Or, you can also fetch the records from the table into an array and sort the array and get the max or min value from it.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Great ! Congrats :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. An array of checkboxes. When the user submits the form, only those checkboxes which were selected, will be posted. You can then build your query depending on the checkboxes the user selects. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't know whats causing the error. You can run queries in a for loop. Once you have freed the result using mysql_free_result, that resource identifier is freed. Actually, if your query isn't too complicated, you don't have to use free_result as php frees the result at the end of execution of the script. Source: http://nl3.php.net/mysql_free_result

Can you post your code here ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yeah.. You can store the description in whatever way you want..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes. Using insert query you can insert anything, long text, short text, image, etc :)

What do you mean by describe it ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome.

No. You can't store a value in the table without using an insert query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Y/w. I ll be here.. ( I hope!)

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you execute a query, a resource identifier will be assigned to $result. mysql_free_result will free this value.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$q = "show tables";

I have 26 tables...shall i write all the names at once

$q="show a,b,c...z";

Show tables will get all the 26 tables (If you have 26 tables in the database) . Thats a mysql query.

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. The code that I have given will search for all the tables in the database. (make sure you have only those tables in the database which you want to search). And what I mean by print your query is, echo $searchtables;
Tell us what it prints on the screen.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Why ? print_r($arrayname) should work fine.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Have you changed the column and table names to suit your requirements ? Print out $searchtables and tell us what it prints.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You have to re-write your code. Or, you can search the internet for a software (if there is any) to convert jsp application to php.

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
$var = array( ); //declare an array
$query = "select * from table";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
  $var[] = $row['name']; //assign a value 
}
?>

Note: The code works even without declaring a variable as array.
But, you can't use a normal variable to act like an array. Example,

<?php
$x = 100;
$x[] = "10";
print $x;
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Print the query and show us what it says..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Basically, you need another table (comments) with columns to store who wrote the comment, on whose profile was the comment written and the comment. (You also may need more columns like date). I hope every user has a unique userid. Store the userids ("from" and "to" ) and comment in the table. Then while displaying the profile, check if there are any entries for this userid. If any rows found, display it.

nav33n 472 Purple hazed! Team Colleague Featured Poster

As you have already said it yourself, you don't have to explicitly declare a variable as an array to use it like an array. You can simply use $var[] = "value"; This will treat $var as an array. But, its always a good practice to initialize a variable before using it. (But most of them don't do it ;) )

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. Is this how you want your script to work ? The user can select different checkboxes and enter a search string next to the checkbox. Then when he clicks on search, It should return all the matching records ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can do it this way.

<?php
$con = mysql_connect("localhost","root");
mysql_select_db("test");
//get all the tables from the database test
$q = "show tables";
$r = mysql_query($q);
$searchresult = array();
while($row = mysql_fetch_array($r)) {
	$table = $row[0]; // get the tablename
	$searchtables = "select * from ".$table." where col1 like '%".$searchstring."%'"; //search the table column for the search string
	$result = mysql_query($searchtables);
	while($rows = mysql_fetch_array($result)) {
		$searchresult[] = $rows['name'];
	}
}
// $searchresult will have all the records from all the tables for the searchstring
?>

Cheers,
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

Awesome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep.. My example works with 2 dropdowns in a same page.

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) lol.. no ! I am a learner.. I am glad your problem was fixed !

nav33n 472 Purple hazed! Team Colleague Featured Poster

What second page ? Why dont you keep everything in the same page ? :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

I'm in a situation where I have to pass javascript variable to php without redirect (no $_get[]).

OP said he don't want to use $_GET[] ! I think he wants something like this.

<script type='text/javascript'>
var xyz;
xyz = 1000;
<?php 
$value = xyz; // he wants xyz value of javascript to be assigned to php variable  $value. 
?>
</script>
//But this is possible
<?php
$value = 100;
?>
<script type='text/javascript'>
var xyz;
xyz = <?php echo $value; ?>;
alert (xyz);
</script>
nav33n 472 Purple hazed! Team Colleague Featured Poster

AFAIK, you can do it the other way, ie., assigning a php variable value to a javascript variable. Assigning a javascript variable value to a php variable is not possible since php is a server side scripting language.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Use firefox to execute your scripts. Make use of error console to see any javascript error.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't know what you mean by that.. But, if you use "if file exists" and add a random number to the image, What is the point in storing the filename in the table ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. I haven't used crons.. But this can be of some use to you on how to run crons. http://www.modwest.com/help/kb5-125.html
Note: You need linux to run cron jobs.

nav33n 472 Purple hazed! Team Colleague Featured Poster

is it possible to a random number to a image file without it becoming a part of that file name.

No.. You can rename a file by concating a random number. You cant add random number to an image without changing its name..

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can do it in 2 ways. Configure a cron job to run everyday at a certain time and send out mails if there are any records for that particular date. The other way is to write a script and execute it manually everyday.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Then use a sub query.

$query = "select D_Name from Department where col_No = (select col_No from College where col_name = '$firstdropdownlistvalue')";

This will return the D_name of the selected col_name.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ah ! Then, *I think* you need a loop to do that.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you know the values, you can do something like this.

insert into table (col1) values (val1),(val2),(val3)

This will insert 3 records to the table.

nav33n 472 Purple hazed! Team Colleague Featured Poster

What do you mean by without using for or while loop ? What's the problem in inserting a record directly ? ie., insert into tablename (col1,col2) values ('val1','val2')

nav33n 472 Purple hazed! Team Colleague Featured Poster

onchange="javascript: document.delete.submit();" instead of
onchange=javascript: document.delete.submit();

Secondly,

$get_list_result2 = mysql_query("select * from College where Col_Name='$firstdropdownlistvalue'");
$get_list_result3= mysql_query("select D_Name from Department where Col_No='$get_list_result2'");

is wrong. What are you trying to do ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

The above query doesn't work because, it will search for the record where shape is like "$searchshapeone" AND again, like, "$searchshapetwo". It will work only if there is a record in the database with shape like both $searchshapeone and $searchshapetwo. For example, If there is a record in the table with shape, for example, 12345, if $searchshapeone = 123 and $searchshapetwo = 345, then your query will work (because both conditions ie., shape like '%123%' and shape like '%345%' are satisfied). Try out with OR condition. It will work !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Post your latest code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I said it in the other thread, have an onchange event to submit the page when you select a value from the dropdown list. When the page is submitted, you can know which option was selected from the dropdown list. ($val = $_POST; ) Then query the table with this value as condition and retrieve the data.

OmniX commented: awesome as usual ;) +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi, the above code works fine. You just have to change the tablenames/column names. Anyway, When the page gets submitted, echo the value of 1st dropdownlist. See if the value is passed correctly. If yes, then the problem must be with your 2nd query. Check your query. See if your query is right. If it is correct, then, something is going wrong while fetching the records from the table. :) You should check this yourself because I dont have the access to your table and I don't know what exactly is the problem.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay ! Well, I just re-wrote the whole code and it works ! Change the column names and tablename to suit your needs ! :) If this doesn't work, then, I don't know, something must be wrong from your side.

<?php
	$con = mysql_connect("localhost","root");
	mysql_select_db("test");
	
	$firstdropdownlistvalue = $_POST['dropdown1'];
	
	$query = "select order_id from orders";
	$result = mysql_query($query);
	echo "<form method='post' name='form1' action='test.php'>";
	echo "<select name=dropdown1 onchange='javascript: document.form1.submit();'>";
	while($row = mysql_fetch_array($result)) {
		$value = $row['order_id'];
		if($value == $firstdropdownlistvalue) { $selected = "selected"; } else { $selected = ""; }
		echo "<option value='".$value."' $selected>".$value."</option>";
	}
	echo "</select>";
	
	$query2 = "select * from orders where order_id = '$firstdropdownlistvalue'";
	$result2 = mysql_query($query2);
	echo "<select name=dropdown2>";
	while($row2 = mysql_fetch_array($result2)) {
		$value2 = $row2['amount'];
		echo "<option value='".$value2."'>$value2</option>";
	}
	echo "</select>";
	echo "</form>";
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hey, If you don't have any "processing" in your script, why not redirect the script to the same page ? Will it still have the images in the cache ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

First of all, you don't have an onchange event to submit the page. secondly, you should have a value for the option. Here is a simple example. I haven't tested it, but it should work with little tuning (which you have to figure it yourself !)

<?php
	$con = mysql_connect("localhost","root");
	mysql_select_db("test");
	$query = "select col1 from table";
	$result = mysql_query($query);
	echo "<form method='post' action='test.php'>";
	echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>";
	while($row = mysql_fetch_array($result)) {
		$value = $row['col1'];
		echo "<option value='".$value."'>$value</option>";
	}
	echo "</select>";
	
	$firstdropdownlistvalue = $_POST['dropdown1'];
	$query2 = "select * from table where col2 = '$firstdropdownlistvalue'";
	$result2 = mysql_query($query2);
	echo "<select name=dropdown2>";
	while($row2 = mysql_fetch_array($result2)) {
		$value2 = $row2['col1'];
		echo "<option value='".$value2."'>$value2</option>";
	}
	echo "</select>";
	echo "</form>";
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

You can find anything on google ! Well, Just install eclipse and install this plugin..
http://sourceforge.net/project/showfiles.php?group_id=57621

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep ! <head> tag is the right place to put meta tags. I haven't come across caching problem, but maybe you can use this.

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

Source: http://nl2.php.net/header Ex. 2

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you post your code here ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

heh.. no probs ! As the warning itself says, chmod didn't find the file (and hence unlink didn't work). Check if the path to the file is correct for chmod and unlink!

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) remove @ and check if it throws any error. You are supposed to delete the file with the extension !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Check if the number is greater than 0. If it is, then show it in green and negative in red. :-/ What is the problem ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

This has been discussed so many times. Either use ajax or this way. In the first dropdown list, list all the states. Have an onchange event to submit the form for the 1st dropdown list. When a user selects an option from the 1st dropdown list, onchange event will be fired and the form will be submitted. You can then access the selected value of 1st dropdown list by doing $firstdropdownlistvalue = $_POST['dropdownlistname']; You can then query the database for this particular state and get all the cities in the 2nd dropdown list.