nav33n 472 Purple hazed! Team Colleague Featured Poster

Here is an example.

<html>
<body>
<ul>
<?php
for($i=65;$i<=90;$i++) {
	echo "<li><a href='char.php?alpha=".chr($i)."'>".chr($i)."</a></li>";
}
?>
</ul>
</body>
</html>
<?php
if(isset($_REQUEST['alpha'])) {
	$alphabet = $_REQUEST['alpha'];
	echo "You selected alphabet: ".$alphabet;
	/* 
	* Then you can query the table for fonts starting from the selected alphabet like
	* $query = "select * from fonts_table where font_name like '%".$alphabet."%'";
	* Then display the results.
	*/	
}
?>

Maybe you can also save an image of the font (like this, http://www.getfreefonts.info/samples/aajaxsurrealfreak.gif) in the table along with the font_name. Then display corresponding font image next to its name.

nav33n 472 Purple hazed! Team Colleague Featured Poster


Do not post homework problems expecting a quick answer without showing any effort yourself.

Seems like you didn't read the member rules.
Ch, ch. Read more on count and group by clauses. After reading them, you will be able to solve this query yourself. :)

Good luck.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I agree because I used to solve questions like crazy in the php forum but now there are fewer questions that are not already solved by another member.

Hmm.. Maybe recession is a factor too. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Dude, datatype as in int, varchar, date, datetime, etc.

ALTER TABLE clown_contest MODIFY COLUMN `location` varchar(40) AFTER `state`

Clear ? :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I didn't go through so many functions in your script, but it works. You are supposed to select the options from the 2nd list before submitting. Unless you select them, they are not selected by default.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb Shaun! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Not only echo, you will get this warning if you have session_start along with header function. Use

ob_start();

as the first line of your script to turn on output buffering and

ob_end_flush();

as the last line to flush the output to the buffer.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Very simple.

<html>
<head>
<script type="text/javascript">
function checkCheckbox() {
 var countselection = 0;
 var maximumselection = 2;
 var ch = document.getElementsByName('choice');
 for(i=0;i< ch.length;i++) {
  if (ch[i].checked) {
   countselection++;
  }
 }
 for(i=0; i < ch.length;i++) {
  if (!ch[i].checked) {
	if(countselection == maximumselection) {
  		ch[i].disabled=true;
	} else {
		ch[i].disabled=false;
	}
  }
 }
}
</script>
</head>
<body>
<form name="form">
1 <input type="checkbox" name="choice" value="1" onclick="checkCheckbox();" /><br />
2 <input type="checkbox" name="choice" value="2" onclick="checkCheckbox();" /><br />
3 <input type="checkbox" name="choice" value="3" onclick="checkCheckbox();" /><br />
4 <input type="checkbox" name="choice" value="4" onclick="checkCheckbox();" /><br />
5 <input type="checkbox" name="choice" value="5" onclick="checkCheckbox();" /><br />
6 <input type="checkbox" name="choice" value="6" onclick="checkCheckbox();" /><br />
</form>
</body>
</html>

Cheers! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

To get a new line, you should add a <br /> to your echo.
ie.,

<?php
echo $abbr['US']['MI']."<br />";  
?>
//or simply
<?php
echo $abbr['US']['MI'];  
echo "<br />";
?>

Also, can you use the php include function in arrays like I used the HTML image function in my japanesemotors example above?

That's a good one. I never did this (or even thought of having an include in an array).
But It doesn't work. Whenever you call the construct "include", it will start processing the 'included' file, ie., it will print if there is any print statement, or make the variables in the included file accessible to the 'base' file (the file where you are using include).
Here is a small example I tried out.

<?php
//include1.php
echo "From Include 1<br>";
?>
<?php
//include2.php
echo "From Include 2<br>";
?>
<?php
//include_in_array.php
$arr = array("a"=>include "include1.php", "b"=>include "include2.php" );
?>

There are 3 files, include1.php, include2.php and include_in_array.php . When you execute the file include_in_array.php , you will see 2 lines (From Include1 and From Include2) printed in the browser.
If you try printing $arr , it will print 1, which simply indicates that the file include1.php was included successfully.
So, the bottomline is, you can't include a file in an array.

network18 commented: include in a array..! really good one!! +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

ob_start, as it indicates, will start output buffering. If you are using ob_start, then you should also use ob_end_flush, ie., flushing the output buffer.
I have used ob_start at places when I had already echo-ed something [which was unavoidable at that time] before starting the session or calling the header function [to get rid of the headers already sent... warning].
Here is an example of what I am talking about.

<?php
echo "hi<br>";
session_start();
echo "Bye<br>";
?>

This will throw an error, saying,

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

But this will not throw any error.

<?php
ob_start();
echo "hi<br>";
session_start();
echo "Bye<br>";
ob_end_flush();
?>

I have also seen/heard some people saying that using ob_start will cause overhead for the server as it has to keep the output in the buffer, until its flushed, but I am not sure how far it is true.
That's my 2 cents :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You forgot the datatype! (doh, even I forgot it in the syntax).
Sorry, here is the right syntax.

ALTER TABLE tablename MODIFY COLUMN columnname datatype AFTER columnname

This works for sure!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cheers! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

I am glad I could help :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) You forgot the column name as the 2nd parameter for mysql_result.
http://php.net/manual/en/function.mysql-result.php

nav33n 472 Purple hazed! Team Colleague Featured Poster

Condition is a mysql reserved keyword. In order to use it, you have to use ` [don't confuse it for single quote]. ie., `condition`. In my opinion, use some other word instead of condition to avoid the same problem in future.
Here is a list of all the reserved keywords in mysql.
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yeah, ofcourse. :) $string is just a variable name. You can give any name to a variable.
See Php naming convention here .

nav33n 472 Purple hazed! Team Colleague Featured Poster

Clear @ before mysql_query and see if it throws any error. Also, you can have

$result = mysql_query($query) or die(mysql_error());

to print the error when the query fails.

P.S. @ suppresses the errors, so you shouldn't use it in testing scenarios. That will make your life hard to know where exactly the error is.

nav33n 472 Purple hazed! Team Colleague Featured Poster

you could also make a function out of it

<?php
   function arrayToString($array) {
      $string = '';
      foreach($array as $value) {
         $string .= "{$string}, {$value} ";
      }
      return $string;
   }

   echo arrayToString($_POST['Prefered_Engineers']);
?>

Or simply,

$string = implode(",",$_POST['Prefered_Engineers']);
leviathan185 commented: Turned many lines of ordinary code into 1 line of magic +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. You are right! That makes sense..

nav33n 472 Purple hazed! Team Colleague Featured Poster

@cwarn23, I think the OP was saying, that it shows only 1 record instead of 2 !
@levsha,
Are you sure you have 2 records for that query ? If you have 2 records, it *should* display them. There is nothing wrong with the query or the while loop.

nav33n 472 Purple hazed! Team Colleague Featured Poster

k

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hey, sorry. I misunderstood the question.

/*
ALTER TABLE tablename MODIFY COLUMN columnname AFTER columnname 
*/
Eg. ALTER TABLE members MODIFY COLUMN date_of_birth date AFTER username

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are supposed to put mysql_fetch_array in a while loop.

while( $data2 = mysql_fetch_array($query)) {
echo $data2['firstname']; 
echo $data2['lastname'];
echo $data2['task']; 
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Very simple.

ALTER TABLE tablename ADD columnname datatype AFTER columnname
nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't recommend using mysql_fetch_row though. This will return an array with numeric indices and the script will fail if you add a new column to your table.
I personally prefer using mysql_fetch_assoc . You can also use mysql_fetch_array($result,mysql_assoc) to get the records based on its associative names.

nav33n 472 Purple hazed! Team Colleague Featured Poster

This code will throw an error at line4 saying "headers already sent"
So no echoes before the header() :)

Probably you didn't get my point. I was trying to demonstrate the use of exit after header function. Even though it will throw an error, it will still print This data is supposed to be secure... . Imagine some really secure data instead of echo statement. If you don't have exit, it will execute it (as cwarn23 has already pointed). Using exit will cut the chances of executing unwanted code.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Wow what a nice funny video. I really like this video. I have saved this link in my book marks. Thanks a lot for sharing such a nice and funny video.

Are you a bot ? Or do you/your team copy paste the same thing in all the threads you bump once in a while ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

also do we need to use the exit() below it?Will it ever get executed when already redirected to the header-location page?No it will get its turn to execute.

The exit function is used as a safety measure just in case the end user gets to echo something before header function (that will cause an error and header will not redirect).
Here is an example,

<?php
$x = empty($x) ? 1 : $x;
if($x == 1) {
	echo "Welcome";
	header("location: http://www.google.com");
}
echo "This data is supposed to be secure...";
/* more secure stuff here.... */
?>

But if you use exit after the header function, It will exit without processing any further.

<?php
$x = empty($x) ? 1 : $x;
if($x == 1) {
	echo "Welcome";
	header("location: http://www.google.com");
        exit;
}
echo "This data is supposed to be secure...";
/* more secure stuff here.... */
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Looks like a bunch of ones and zeros with a few letters to me.

No, see the 3rd image.
From the website:

This is an animation of the clock that shows in "fast forward" how it in twelve hours goes around.

Quite an effort !

nav33n 472 Purple hazed! Team Colleague Featured Poster

What I am trying to do is view a post whilst not logged in then clicking on reply to post, it used to work why has it stopped recently.

Yep. There is a bug. This is what I did.
I logged out, came back to this thread and tried to 'reply with quote'. It asked me to log in.
Url : http://www.daniweb.com/forums/newreply.php?do=newreply&p=1048814 which said,

You're trying to access something for members only! Please register or login to continue ...

Fair enough. Then, when I tried to log in, I got this url ( http://www.daniweb.com/forums/login.php?do=login ), which redirected me back to http://www.daniweb.com/forums/newreply.php?do=newreply&p=1048814 , asking me to log in again.
The Go back button, as well as, Click here if your browser does not automatically redirect you. will take me back to the same url: http://www.daniweb.com/forums/newreply.php?do=newreply&p=1048814 .
Tested in IE7, FF 3.5.5 and my computer is a cookie monster :P Seems like there is some problem with the session.

jasimp commented: Nice work +0
jephthah commented: check out the big brain on Brad! ;) +0
nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep! It sure is. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster
nav33n 472 Purple hazed! Team Colleague Featured Poster

Have onsubmit event for form. Here is ane example.

<?php 
if(isset($_REQUEST['submit'])) {
	print "<pre>";
	print_r($_REQUEST);
	print "</pre>";
}
?>
<html>
<head>
<script type='text/javascript'>
function validate(form) {
	if(form.name.value == "") {
		alert("Name cannot be empty");
		return false;
	}
	return true;
}
</script>
</head>
<body>
<form method='post' onSubmit='javascript: return validate(this);'>
Name: <input type='text' name='name'><br />
Age: <input type='text' name='age'><br />
<input type='submit' name='submit' value='submit'>
</form>
</body>
</html>

The part in <?php if($_REQ...) can be in your data.php .

Good luck!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Do as above. But, If you are a novice user and you find it hard to use ajax, then you can do the traditional way. Submit the form having an onchange event on all the dropdowns. When you select, say milk, from the first dropdown, submit the form, so $_REQUEST is available, which can be used to query the table to get all its related options, and so on.
As I said, its a traditional way and it will work. But, If you don't want to submit the form for each dropdown, then you *should* use ajax.

nav33n 472 Purple hazed! Team Colleague Featured Poster

There are still some typos. $GET_ instead of $_GET. One simple suggestion though. You don't need a switch/if-elseif-else condition to find out the day. A simple array will do it. This is what I am talking about.

<?php
//nodag = Norwegian day
//endag = English Day
// dag = day
if(!isset($_GET['ok'])) { //start if
?>
<form action="" method="get">
<select name="lan">
	<option value="eng">English</option>
	<option value="no">Norsk</option>
	</select>
<input type="submit" name="ok" value="Ok">
</form>
<?php
}// end if
elseif($_GET["lan"] = "no") { //start elseif
$norwegian_days = array("Monday"=>"Mandag","Tuesday"=>"Tirsdag","Wednesday"=>"Onsdag","Thursday"=>"Torsdag","Friday"=>"Fredag","Saturday"=>"Lordag","Sunday"=>"Sondag");
$endag = date("l");
$nodag = $norwegian_days[$endag];
echo $nodag;
} // end elseif
else { // start else
$endag = date("l");
echo $endag;
}// end else
?>

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

I am not sure about the logic you are using. Check your loops to see if its not looping unnecessarily. Print your query and see if its the query that is failing. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Wow! This thread is unbelievable and you guys are mind blowing! :P

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi, If I understand your question right, this should do the trick.

select * from customers c, cust_packages cp 
where c.cust_custnr = cp.cpack_usernr group by cpack_usernr
having count( * ) =1 and cpack_canceldate != '0000-00-00'

This will select all the customers with only 1 record in table cust_packages (meaning, they have not registered again) and their canceldate can be anything but not 0000-00-00.
Cheers!
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

It could be that you are using single quotes around the values that are meant to be integers, the single quotes are converting them to strings.

You are almost right. Since its a function, there is no need for single quotes for mysql_insert_id.
Secondly, Even integers can have single quotes around them. It will not cause any problems. The main thing is, integers can work without single quotes around them, but strings will not work.
@futhonguy,
You can query the table with that word and if it returns more than 1 row, then use that id.
Eg.

$b_add = $_REQUEST['b_add'];
$query = "select id from tableB where B_add = '$b_add'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0) {
   $row = mysql_fetch_assoc($result);
   $id = $row['id'];
 //insert $id to tableA
} else {
 //insert a record to tableB
//insert mysql_insert_id to tableA
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Maybe the root cause for all this confusion is the word dehasher. ;) Its not exactly a dehasher, but a hash-matcher ! :icon_cool:

nav33n 472 Purple hazed! Team Colleague Featured Poster

I am little confused about this part.

But what Im trying to do is having the user to enter values into Table B where the id of Table B will automatically appear onto Table A.

If I get it right, When you insert a record to table B, you can get the id by using mysql's last_insert_id or php's mysql_insert_id. You can then insert a record in table A using this value.
You can make id column of both the tables A and B as primary key (since no duplicates are allowed). Then, you can have a column in table A (for example, tableB_id) and make it a foreign key referencing table B's id column. You can add constraints after creating a table. Thats not a problem!
http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

One suggestion. When you are inserting a record to the table, you don't have to insert 'NULL' if its an auto increment field. Mysql will do it for you.
Ie.,

$orange_insert = "INSERT INTO orange (orange_name, orange_add)
	             VALUES ('$val_name', '$val_add')";

Secondly, the 'error' you are getting is not exactly an error, but a notice. You get these notices if you use a variable without initializing it. You can turn off the notices by changing your php.ini file. Change error reporting in php.ini to the following if you want to disable notices.

error_reporting = E_ALL & ~E_NOTICE

This means, show all errors except notices.
If you don't want to disable notices, then start initializing all your variables before using it.
Finally, You have an error in your code.

$result_orange = $row['$orange_id'];

should have been

$result_orange = $row['orange_id'];

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

:( No. I pay around Rs. 1200 (approx $26) for my 512kbps connection. Its around Rs. 3000 for 1 mbps (that is approx $65).

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool ! Congrats :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi, I am not sure how you are validating what mysql returns. In php, when you query the table, for example,

//query the table with username and password 
$query = "select * from table where username='test' and password='test'";
//execute the query and save the resource in $result. 
$result = mysql_query($query);
//If the variable $result is true and if the query returns more than 0 rows, (meaning, there is a record!) then display convenient message.
if(mysql_num_rows($result) > 0) {
 echo "Username and password exists!";
} else {
//else, no records exist
 echo "No records found.";
}

In php however, this will return false if a record doesn't exist in the table. If it has a record, then it will return all the columns of that record as a resource.
I am not sure about Java, but I think mysql will return an empty result set if no records are found.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi, can you elaborate your question ?
If you are inserting the value to the table from php, you can use substr to insert only a part of a string. If you are directly inserting the record to the table, you can use mysql's substring function.
If this solves your problem, well and good.. If it doesn't, please explain your question in detail.
P.S you can only edit your post within 30 mins of posting! :)

Cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

i looked at your message you didn't show me any direction

Okay! Here is the direction. From this point >> * << Go straight up and stop when you see the text "Software Development". Since you have already traveled this far, you might be tired and maybe you need a break. Take a break and hover over it (the text "Software development"). You will see a drop down list. The first option you see is C++ forum. Come down a little and click on it. This will take you to C++ forum. When you are there, you can start a new thread and post your question (follow Grn Xtrm's guidelines while posting your question).
Clear enough ? :icon_rolleyes:

Grn Xtrm commented: Very clear, indeed. :) +0
Ancient Dragon commented: nice :) +0
Will Gresham commented: Haha :) +0
kvprajapati commented: nice. +0
nav33n 472 Purple hazed! Team Colleague Featured Poster

The quality is okay. The seek bar doesn't work though. And since it doesn't work, it's difficult to know the duration of the video (and go forward or backwards). But, overall, thumbs up for the effort.
(One suggestion. If you also provide the source code along with the tutorial, it would be good).
Eg. http://www.phpvideotutorials.com/lesson02/

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, she has her priorities, do you really need to 'fix' something that nobody will click anyway? Removing the link would require more code, not less.

I know she has her priorities (Its been a week since I posted this thread and haven't got her reply. So, I know she's busy). Moreover, that was just a suggestion (it's `daniweb community feedback`, isn't it ?) not an order.
Lastly, removing the link wouldn't need more than 2 lines of code (maybe less).

$html = ($post_currently_negative=="0") ? "No hyperlink" : "Show hyperlink";

:)