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

Umm.. well, here is a simple example for file upload.. http://www.tizag.com/phpT/fileupload.php Check that out !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Writing data to a file is very simple. Open a file with different modes using fopen. Write contents to it using fwrite. Then close the file. http://nl.php.net/manual/en/function.fopen.php . I dont understand what exactly you mean by enable the form to upload a file to my server. Isn't file uploading enabled in your server ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

magic_quotes is not the best function out there as it can cause slashes to be added in places they are not needed. read http://en.wikipedia.org/wiki/Magic_quotes for details on that subject.

Hmm.. Thats a good link ! But, I would rather use mysql_real_escape_string than addslashes and stripslashes because if you use mysql_real_escape_string, you dont have to worry about stripslashes.

nav33n 472 Purple hazed! Team Colleague Featured Poster

you are welcome :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can make use of nl2br to convert \n (new line) to <br />.

nav33n 472 Purple hazed! Team Colleague Featured Poster

ust off the top of my head I'm assuming the addslashes function will take nasty characters like " and add a slash in front of them (which is used for cleaning a variable to be INPUT into the database?) and then stripslashes is to be used when they come back out of the database so that all the evil characters like " are back again

Absolutely. But check if get_magic_quotes_gpc is turned on. If it is turned on, then you don't have to explicitly escape '.

nav33n 472 Purple hazed! Team Colleague Featured Poster

No.. Just use $ngclasses = mysql_fetch_array($result);

nav33n 472 Purple hazed! Team Colleague Featured Poster

list($ngclasses) = mysql_fetch_array($result);

is wrong. It will assign the 0th index of the array fetched by $result to a variable $ngclasses. If you want $ngclasses to be an array, don't use list. Well, here is more on list.
http://nl2.php.net/manual/en/function.list.php

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes. Possible.

<?php
if($_POST['metode'] == "Authorname") {
//if the user selects authorname from the list then use this query
$query = "select * from tablename where firstname like '%$searchtext%' or lastname like '%$searchtext%'";
} else {
   // else use other query 
}
dottomm commented: Fantastic!!!! +1
nav33n 472 Purple hazed! Team Colleague Featured Poster
$query = "select * from table where AuthorFirstName like '%$searchstring%' or AuthorLastName like '%$searchstring%'";

This will look for $searchstring in both AuthorFirstName and AuthorLastName fields. :) I hope thats what you want !

nav33n 472 Purple hazed! Team Colleague Featured Poster

There is a typo in ENCTYPE. It should be form-data.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. not really.. sorry ! But, google is your friend :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You need to put mysql_query inside the foreach loop as well..

$values = $_GET['tta'];
echo "size of array = ".sizeof($values)."<br>"; 
foreach ($values as $question_equation) {
$sql = "INSERT INTO venn (question_equation) VALUES ('$question_equation')
	";
	if (@mysql_query($sql)) {
echo '<p>questions added</p>';
} else {
echo '<p>ERROR questions not added' .
	mysql_error() . '</p>';
}
	//echo $values;
echo $question_equation;
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Try this.

mysql_query("SELECT * FROM $quiz_name");

If this doesn't work, print out the query and run it in phpmyadmin/mysql console. See what the problem is.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Do you have the database connection in your script ? And Check if $quiz_name isn't empty.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$result = mysql_query("SELECT * FROM '$quiz_name'");
$num_rows = mysql_num_rows($result12);

$result12 should be $result.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Oh thanks.. But wouldn't it affect the query if we do it like

select team_ID,teamname,teampassword from teams where teamemail='{$email}'

Because, anything between ' ' will be considered as a value.. isn't it ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

$teampassword=getvar("teampassword")

Missing ; at the end. Didn't you get any parse error ? Hmm! And

select team_ID,teamname,teampassword from teams where teamemail='{$email}'

shouldn't that be

select team_ID,teamname,teampassword from teams where teamemail='$email'

And also here,

<input type='text' name='email' value='{$email}'>

Why is value='{$email'} ? When you query the table, it will look for email, for example, {test@test.com} !

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Almost correct. When you submit the page, the checkboxes which were checked will be passed on to the next page. You can use foreach to get the checked values. Query the table and get the rows for these ID's.

<?php
foreach($_POST['checkboxname'] as $value){
$query = "select * from table where id='$value'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
 $school = $row['school'];
$date = $row['date']; //and so on..
//Then insert these values to the table
$insert = "insert into table2 (col1,col2) values ('$school','$date')";
mysql_query($insert);
}
}
//so, it will insert a row in the table for every checked checkbox value

I hope thats clear..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Then query the table with the ID's passed.. Get the row and insert it to another table.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I dont understand.. You already have a record in the table and you want to insert another record for the same ID ? Can you explain in detail what exactly are you trying to do ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

What are you doing with the ID ? Are you using it to do anything important ? Like updating/inserting any value to a table ? If so, you need ID field. Umm.. Hey, why not do it this way. ID represents a row in the table. For example, If ID = 1, all the other details, $a_row, $a_row and $a_row will have the relevant value. Why not query the table and get the data when the user submits the form ?
Ie., from your code, you have passed 2 values to the next page.

Array ( [0] => 9 [1] => 14 )

Query the table and get the rows where ID = 9 and 14 respectively.

<?php
foreach($_POST['checkboxname'] as $value){
$query = "select * from table where id='$value'";
//execute the query and get the rows and print it..
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, if you wish to use sessions, its going to be a lil tedious because, say for example, there are 10 checkboxes and the user selects 5. You need to have an array of session variables and get only the selected index of the checkbox. Thats going to be very difficult !
But you can try this alternative. Instead of,

<input type="checkbox" name="hello[]" value="'.$a_row.'">

pass $row, $row and $row as the value.

$value = $row['date']. ";".$row['school'].";".$row['people'];
<input type="checkbox" name="hello[]" value=".$value.">

So, when a checkbox is checked, all these values are passed onto the next page as the checkbox value.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You mean, you want to see all the other details like

<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".

? You cant. If you want all these details to be passed onto the next page, have textboxes assign these values to the textboxes and then you can get these values in the next page. Or, use session.

nav33n 472 Purple hazed! Team Colleague Featured Poster

In the next page, if you do, print_r($_POST); you will see ONLY the list of checkboxes which were checked..

nav33n 472 Purple hazed! Team Colleague Featured Poster

I dont see line 30 in that code snippet !
And btw, instead of echo "<td>$row['last_name']</td>"; Try, echo "<td>".$row['last_name']."</td>";

nav33n 472 Purple hazed! Team Colleague Featured Poster

echo '<image src="'.$row.'" width=50 height=80>';

Thats wrong.
1. Its <img tag.
2. You can't directly give Img src = $row.

Check this or this .

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can't see the image. You need to write a php script to see the image.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can't view an image from mysql console.

nav33n 472 Purple hazed! Team Colleague Featured Poster

document.formName.task.value=='del';

Should be document.formName.task.value='del';

Venom Rush commented: helped alot ;) +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Nope.. $_POST will not hold any value. You can do it this way (again, as DangerDev mentioned), have a hidden variable (task). When you click on 1st button, assign a value to task variable. document.formname.task.value='add'; Similarly, assign another value when another button is clicked. document.formname.task.value='delete'; Then you can check what value task variable holds.

if($_POST['task']=="add"){
//add
} 
if($_POST['task']=="delete"){
//delete
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

eg. document.formname.submitButtonName.submit();

I dont think you can. But you can do this. Instead of having a submit button for delete button, have a normal button as DangerDev has mentioned. Then onclick call a javascript function and submit the page. Eg.

<?php
	print_r($_POST);
?>
<html>
<head>
<script type="text/javascript">
function delsubmit() {
	var conf;
	conf=confirm("Are you sure ?");
	if(conf) {
		document.test.submit();
	} else {
		return false;
	}
}
</script>
</head>
<body>
<form name="test" method="post" action="<?php echo $PHP_SELF; ?>">
<input type="text" name="name" value="1">
<input type="button" name="button" value="Delete" onclick="javascript: return delsubmit();">
</form>
</body>
</html>

This is just a simple example. The next snippet of code will not work, because there is already a submit button. Eg.

<?php
	print_r($_POST);
?>
<html>
<head>
<script type="text/javascript">
function delsubmit() {
	var conf;
	conf=confirm("Are you sure ?");
	if(conf) {
		document.test.submit();
	} else {
		return false;
	}
}
</script>
</head>
<body>
<form name="test" method="post" action="<?php echo $PHP_SELF; ?>">
<input type="text" name="name" value="1">
<input type="submit" name="submit" value="add">
<input type="button" name="button" value="Delete" onclick="javascript: return delsubmit();">
</form>
</body>
</html>

To make both of them work, you should have 2 buttons. Eg.

<?php
	print_r($_POST);
?>
<html>
<head>
<script type="text/javascript">
function delsubmit() {
	var conf;
	conf=confirm("Are you sure ?");
	if(conf) {
		document.test.submit();
	} else {
		return false;
	}
}
</script>
</head>
<body>
<form name="test" method="post" action="<?php echo $PHP_SELF; ?>">
<input type="text" name="name" value="1">
<input type="button" name="button" value="add" onclick="javascript: document.test.submit();">
<input type="button" name="button" value="Delete" onclick="javascript: return delsubmit();">
</form>
</body>
</html>

If you still have problems, let me know!
Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Beer mug ? Party time ? eh ? ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

No..that isn't the problem.. The problem is missing ; in here..

echo "<tr>"

nav33n 472 Purple hazed! Team Colleague Featured Poster

I'm probably getting annoying now.

Lol.. Nah !

Anyway, if its connecting to getjobnumber.php page, what is the name of this page ? If this is a different page, put

$jobnumber=$_POST['job_number'];

$con = mysql_connect("localhost","root","rilke123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("parsec", $con);

$query = "SELECT * FROM customers WHERE job_number='$jobnumber'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo $row['first_name'];
echo $row['last_name'];
//etc...
}

in getjobnumber.php page.

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
print_r($_POST);
?>
<html>
<head>
<script type="text/javascript">
function save()
{
document.getElementById("schdate").value  = document.getElementById('nextsch').value;
alert ("date"+document.getElementById('schdate').value);
//when i alert it had value
}
</script>
</head>
<form name="mainform" method="post" action="1.php?impt=<?= $impt ?>">
<table>
<tr>
<td align='center' width='100'>	
	<input type='text' id='nextsch' name='nextsch'>&nbsp;</td>
	<input type=hidden name=schdate id=schdate>
	</tr></table>
<input type="submit" value="Save" name="Save" tabindex="7" style="font-size: xx-small" onclick="save();">
	</form>
</body>	
</html>

Check this..

var imp = document.getElementById('yesno').checked;

var imp will always be true with this. You can use if condition or document.getElementById('yesno').value;
Remove value='null'.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Where are you calling the javascript function ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. you have one textbox to enter the job number ? When the user enters his job number and click on submit, all his details should be displayed ? Is that right ?
Here is an example.

<?php
if(isset($_POST['submit'])) {
	$jobnumber=$_POST['jobnumber'];
	//connect
	//selectdb
	$query = "select * from table where jobnumber='$jobnumber'";
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result)){
		echo $row['columnname']; //allign it however you want to display
		echo $row['columnname1']; 
		//etc...
	}
}
?>
<html>
<body>
<form method="post" action="getjobnumber.php">
<input type="text" name="jobnumber"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Exactly !

nav33n 472 Purple hazed! Team Colleague Featured Poster

DangerDev, you can know which button was pressed by giving each button a unique name. In my example, I have called it submit1 and submit2.

nav33n 472 Purple hazed! Team Colleague Featured Poster

DangerDev, My problem is that I don't know javascript very well and haven't been able to find any solutions. Is the section of code for submitting the form correct?

document.formname.submit();

P.S. You can have two submit buttons on one form. I've used it successfully on many pages.

Since you are already using the submit button in your form, you can't submit that way (I think).

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can actually have 2 submit buttons in a form. Eg.

<?php
if($_POST['submit1']) {
	echo "Submit1 pressed! Add/update the records";
}
if($_POST['submit2']){
	echo "Submit2 was pressed ! Now delete the records !";
}
?>
<html>
<head>
<script type='text/javascript'>
function confirmdel() {
	var val = confirm("Do you really want to delete ?");
	if(val) {
		return true;
	} else {
		return false;
	}
}
function calltest() {
	alert("Hi there!");
	return true;
}
</script>
</head>
<body>
<form method="post" action="thispage.php" onsubmit="javascript: return calltest();">
<input type="submit" name="submit1" value="add"><input type="submit" name="submit2" value="delete" onclick="javascript: return confirmdel();">
</form>
</body>
</html>

But, since both the buttons are submit buttons, onSubmit event will be fired when you click either of the buttons.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Then you can truncate the table instead of dropping it and creating a new one ! mysql_query("Truncate table tablename"); will do the trick !

kevin wood commented: if you need help with php/mysql he is your man +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Do you want only 1 image to be inserted at a time for all the users ? That is, if user A uploads an image, then delete the table, create the table again, insert the values to the table. Then if user B uploads an image, again, delete the table, create the table again and insert the values to the table ? If thats the case, why not truncate the table instead of dropping it ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Try this.

<html>
<head>
</head>
<body>
<?php
print "<script type='text/javascript'>";
print "window.open('http://www.examples.com/page.html','new_window1','status=1,scrollbars=1,resizable=0,menu=no,width=320,height=220');";
print "</script>";  
?>
</body>
</html>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Check this tutorial. And here is an example how you can query your table..

nav33n 472 Purple hazed! Team Colleague Featured Poster

The point is, how you are storing the data in the table. select repair_status from table where job_number = '123' will display (the list) of repair_status for job_number 123.

nav33n 472 Purple hazed! Team Colleague Featured Poster

No.. This is fine.. Nothing wrong with the table definition.