Graphix 68 ---

What do you mean by 'A black color around image'? Send us a screenshot of how it looks like in Firefox/Chrome and how it looks in IE

Graphix 68 ---

You have it figured out pretty good by yourself, but to help you in the right direction, think of something like this:

$filename = "D:/some/folder/example.txt";
$text = "<a href='delete.php?file=".$file."'>Delete ".$file."</a>";

And apply that to your own script (thus making a new page called 'delete.php' that retrieves the filename from the URL using GET and deletes it)

~G

Graphix 68 ---

When I meant 'indenting & spacing', I meant it a bit differently than you did it (see the code). Also you can't compare dates using the strings, you first need to convert them to UNIX timestamps (see http://php.net/manual/en/function.strtotime.php for more explaination).

<?php 
/* The date limit when the page needs to be redirected: */
$timelimit = '2012-02-10 00:00:00';

/* The current date: */
$timenow = date('Y-m-d H:i:s');

/* Comparing the two dates: */
if ( strtotime($timenow) > strtotime($timelimit) ) {

	/* Redirecting user to another page: */
	header( "HTTP/1.1 301 Moved Permanently" );
	header( "Status: 301 Moved Permanently" );
	header( "Location: http://www.redirectsite.com" );
	exit(0); 

} else { 

	/* Showing page content: */
	echo "http://www.contestpage.com"; 
}

?>

As for the redirecting, I think it is either this or a JavaScript redirect (which is client side). Try googling it.

~G

Graphix 68 ---

Your code isn't comparing correctly. You want to see whether text needs to be shown using the 'if' condition, but you are comparing a date? You are also using the assign operator '=' instead of the comparing operator '==':

Line 4-10 should be:

if ($showtxt == false) {
...
...
...
...
} else {
  echo "Page content";
}

I'm not sure whether you can compare dates like that, but I guess you can find that out by yourself. You also might consider indenting & commenting your code!

~G

Graphix 68 ---

In my opinion, the three javascript function initForm and showHideBox are unnessecary. When the page reloads, the option that is chosen is already selected (so initForm is obsolete) and using a simple if condition, you can render showHideBox obsolete too!

I'il explain with some code:

//
// As you have not given all your code I assume a few things:
//    > $diag is the ID of the selected diagnostic ($_GET['selectedDiag'])
//    > The query $quer2 retrieves all the diagnostic dropdown values
//    > The query $quer retrieves all causes WHERE diagnosticId = $diag (and same with $mediquery)


/* Opening form: */
echo "<form method='post' name='f1' action=''>";

/* Opening diagnostic dropdown with default option: */
echo "
<select id='selectedDiag' name='selectedDiag' onchange='reload(this.form)'>
<option value=''>Select diagnosis</option>
";

while($noticia2 = mysql_fetch_array($quer2)) { 
	if($noticia2['diagnosisId'] == $diag) {
	  echo "<option selected='selected' value='".$noticia2['diagnosisId']."'>".$noticia2['diagnosisName']."</option>";
	} else {
	  echo "<option value='".$noticia2['diagnosisId']."'>".$noticia2['diagnosisName']."</option>";
	}
}

/* Closing diagnostic dropdown with 'other' option: */
echo "<option value='other'>Other</option>
</select>";

/* Only if the diagnostic is set: */
if (isset($diag)) {

/******************************************************************************
 * I'il let you correct this part yourself: 
*/
	echo "<select name='cause'>
	<option value=''>Select cause</option>";
	while($noticia = mysql_fetch_array($quer)) { 
	echo  "<option value='$noticia[causeId]'>$noticia[cause]</option>";
	}
	echo "</select>";

	//////////        Starting of third drop downlist /////////
	echo "<select name='medicine'>
	<option value=''>Select medicine</option>";
	while($noticiamed = mysql_fetch_array($mediquery)) { 
	echo  "<option value='$noticiamed[medicineId]'>$noticiamed[medicineName]</option>";
	}
	echo "</select>";

/*********************************************************************************/

}

/* Showing submit button: */
echo "<input type='submit' name='submit_button' value='Submit'>";

/* Closing form: */
echo "</form>";

I think this will help you make the four dropdown work.

~G

Graphix 68 ---

Hi!

I've read that you are just starting to learn PHP! Good :)

It makes it easier to read your code if you have a few coding guidelines:

>> Indent and comment your code, keeping statements and function calles seperated and clarified:

/* Doing something: */
doSomething();

/* Doing something else: */
doSomethingElse();

/* Indicates whether something needs to be shown: */
$shown = true;

/* Only if it needs to be shown: */
if ($shown == true) {
     
     /* Showing something: */
     echo "Something";
     
}

/* Doing a loop: */
while ($a == 0) {

     //.... Code block ....

}

// I hope you get the picture by now,
// because typing this isn't really helping you at all with your problem...

>> Also, you might want to read up on how to properly write HTML (watch the use of quotes and ';'):

<img src='myimage.png' border='0' onclick='doSomething("StringArgument");' />

And as a final check, you can always go to the guys that design HTML: http://validator.w3.org/

>> Oh and one last thing, don't use old syntax for your HTML:

<script type='text/javascript'>
function reload(form)
{
  var val = form.selectedDiag.options[form.selectedDiag.options.selectedIndex].value;
  self.location='updateMedicalRecords.php?selectedDiag=' + val ;
}  
</script>

I think you will find your answer when you've cleaned up your code.

~G

Graphix 68 ---
diafol commented: Thank you G - saves me posting a sarcy comment +14
Graphix 68 ---

Alright... I haven't taken a look at the thread for a few hours now and see EvolutionFallen helping :) Well OK.

Some small remarks:

>> You should still read through my previous reply and clean the values you collect with POST, as this makes your SQL vunerable for attacks!

>> If you check the following bit of code EvolutionFallen provided:

$sql = "INSERT INTO comments (page_id, comment) VALUES ($myid, '$comment')" or die(mysql_error());
   mysql_query( $sql, $mymysql );

You should notice that you declare an string to an variable and if THAT doesn't work, you let mysql print its last error??? Pretty strange coding to me! Take a look at this:

$query = "THIS is MY query";
$result = mysql_query($query) or die("Could not execute query");

It prevents the visitor from seeing errors if the occur AND they tell you that the query is wrong. Ofcourse, if you are testing and want to know why a query fails, you put mysql_error() as parameter for die() . But remember to remove it when putting it on a live site ;).

Also, regarding your form and show page:

while ($row = mysql_fetch_array($sql)) {
$comment = $row['comment'];
}

Is a correct loop, but you are not echo'ing anything! Try this:

while ($row = mysql_fetch_array($sql)) {
  $comment = $row['comment'];
  echo $comment;
}

Also the returning reply "Still not working" doesn't really help clarify what's going wrong (although more experienced programmers can spot it easier).

You might want to take a look in …

Graphix 68 ---

You have the variable $page_id in your HTML form, which specifies which page the comment should be placed.

You only need to retrieve the comments from the database that have $page_id as page_id.

I'il give you an head start:

SELECT * FROM table_name WHERE column='value'

Now you need to apply that SQL-query to your code, and loop through the result. If you don't know how:

You now need to retrieve the rows from the table, run through the result with a loop, echo'ing each comment. If you don't know how, try reading a good book or searching online.

~G

Graphix 68 ---

Oh and if you run into a problem with the "showing comments"-part: first try to figure out what the problem is yourself and if you still can't find the solution, post a reply and I'il take a look at it.

Graphix 68 ---

Adding comment part

1. Database

Alright, let's review: you have a table with four columns: comment_id, page-id, comment_content, timestamp

So your database is set up and you can start writing code.

2. HTML form

You have made an initial form, but does it cover the two columns it needs to fill? page_id, check, comment_content, check. So your form is done.

3. PHP code

You retrieve the values given to you by the form and execute them in a query. So this is done too.

So you're done for the adding comment part (assuming it works, you should test the variables and add a few fake comments to make sure it works). Also it's not really secure, in my experience, you should a captcha or some sort of verification before you put code like this online.

I once allowed anyone to add comments to my website without a captcha, and it resulted in 50000 (no really, I am not kidding) comments of advertisements about viagra.

Also you might consider cleaning your variables before executing them in an query (prevents SQL-injection):

$variable = htmlentities(addslashes($_POST['variable']));

Showing comments part

You now need to retrieve the rows from the table, run through the result with a loop, echo'ing each comment. If you don't know how, try reading a good book or searching online.

~G

Graphix 68 ---

Umm, try this checklist:

A. Is "users" the correct table?
B. Is the name of the column that holds the level really "level", as you described on line 25?
C. You should have fixed it by now, if not, post a reply :)

~G

Graphix 68 ---

Hi tstory28,

After a quick look through your code, I would like to suggest a few things:

- Put a new if statement around line 6 to 61, in which you check whether the email and password form variable are set (if (isset($_POST['email) && .....) and delete the if statement in line 10

- Line 7, 8 - Clean the form value first: $variable = htmlentities(addslashes($_POST['form_variable'])); - Line 26 - Add an echo in which you show all the variables from the database:

echo "dbemail=".$dbemail.", dbpassword=".$dbpassword.", dbname=".$dbname.", dblevel=".$dblevel;

If you did all those steps (especially the last one), you will find out why your code is not working (probably because dblevel is empty, but you'll see)

~G

tstory28 commented: This helped me find my issue. +1
Graphix 68 ---

Well, you call the function calcHeight, however in your javascript code, the function is called calcheight , (notice the caption). Also your function just retrieves the height? I assume you have some code that sets the height of the iframe that you have not posted.

~G

Graphix 68 ---

What code?

Graphix 68 ---

Good job you figured that out

Graphix 68 ---

You can handle the keys pressed on the keyboard:

document.onkeypress = function(e) {
 return HandleKey(e);
}

function HandleKey(event2) {

     var key;  
     
     /* Retrieving the pressed key: */
	 
     if (window.event) {
          key = window.event.keyCode; //IE
     } else {
          key = event2.which; //firefox    
     }
	 
     /* Switching the pressed key: */
	 
     if (key == 97) {
	 
	alert("You pressed the left arrow!");
	return false;
		
     } 
	 
}

You only need to find the keycode of the "H" key.

~G

Graphix 68 ---

I thought that it was pretty obvious ;) but anyway here it is:

<DIV title='Long Term Focus' style='font-weight:bold; font-size:24px; color:green'>&#x25A0;</DIV>

~G

Graphix 68 ---
Graphix 68 ---

Line 1 - No document type?

Line 2 - You forgot to add <title>MyTitle</title> element

Line 4 to 16 - Your script needs to be either within the <head> or within the <body> tag

Line 20 - You did not add the id attribute:

<select name="box" id="box">

Line 21 - The correct syntax for having a option selected is selected="selected" (see reference)

~G

Graphix 68 ---

You can redirect visitors after you processed the form (around line 175) using the Header() function:

header('Location: http://www.example.com/');

See the reference: http://php.net/manual/en/function.header.php

~G

Graphix 68 ---

Ok your problem lies in the following two functions:

function ozn(opcija,id){
document.getElementById(id).style.background="rgb(167,120,50)";
document.getElementById(id).onclick=function(){mak('+opcija+',this.id);}
urediFont(opcija);
}

function mak(opcija,id){
document.getElementById(id).style.background="rgb(199,147,69)";
document.getElementById(id).onclick=function(){ozn('+opcija+',this.id);}
urediFont(opcija);
}

They need to be changed into:

function ozn(opcija,id){
document.getElementById(id).style.background="rgb(167,120,50)";
document.getElementById(id).onclick=function(){mak(opcija,this.id);}
urediFont(opcija);
}

function mak(opcija,id){
document.getElementById(id).style.background="rgb(199,147,69)";
document.getElementById(id).onclick=function(){ozn(opcija,this.id);}
urediFont(opcija);
}

~G

PS: I do not have any clue which language this is, so all the variables names are confusing to me. Perhaps program in english so your code is more understandable to people. Just a suggestion for in the future ;)

Graphix 68 ---

When the user selects a text, he can press the 'B'-button to bold and to unbold the selected text. However, when he presses the 'B'-button without having the text selected, the user can enter text which will turn up bold. If the user wants to stop with this, he can unbold by clicking the 'B'-button.

~G

Graphix 68 ---

Ivan, I see you used the tutorials I gave you to make a rich text editor, but you did not copy them correctly. For instance, line 9 and 10, you neglected to close the <body> and <html> tag, which is probably causing your problems.

If you want to change the background color of the selected text, you just simply use the following:

urediFont('BackColor', 'blue');

For a complete reference see:
http://msdn.microsoft.com/en-us/library/ms533049%28v=VS.85%29.aspx

I would highly recommend that you read through my tutorial again:
http://www.webdevproject.com/projects/solo/project31.html

Also, commenting/indenting on your code is advisable, as we can then understand the code alot better. (Code guidelines)

~G

Graphix 68 ---

It's not the fault of the HTML nor CSS, if you would read the sourcecode, you would see that after every dot (.) there is a unknown character icon. This is caused by your editor that you use to type the text (your CMS perhaps), which adds a unknown character after every dot.

~G

PS: You should validate your CSS using w3 CSS validator, on first glance, I saw that line 5 should be: font-style:none;

Graphix 68 ---

Line 22, 33, 35, 37, 44 - You forgot to close the quotes

~G

Graphix 68 ---

A) This is not the existing scripts forum
B) Send an email to the person that wrote this script and ask him to answer your question
C) The code is extremely unreadable, unclear and confusing. As I did not wrote the code, I have no idea what it does. It does not even have any comments.

I assume you did not wrote this script, and if you do you'd better improve your programming skills ;) (Code Guidelines: http://www.webdevproject.com/guides/programming/guide2.html)

~G

Graphix 68 ---

When you want to darken a page, you place the following HTML right after the <body> tag:

<div id='darkscreen' style='position:fixed; top:0px; left:0px; color:black; opacity:0.5; filter:alpha(opacity=50); width:100%; height:100%;'></div>

If you want to toggle its display, you can use:

document.getElementById('darkscreen').style.display = 'inline'; // Show
document.getElementById('darkscreen').style.display = 'none'; // Don't Show

~G

Graphix 68 ---

There is nothing tiny about it ;)

References and tutorials on developing rich text editors are rare and extremely difficult to find (I never found one till today). You should check out the open-source rich text editors and try to understand what they do in the sourcecode.

An example of an open-source WYSIWYG editor:
http://nicedit.com/

Try googling though to find the (maybe) one tutorial on the web on this subject? If you found it, feel free to post it below for others (including myself)!

EDIT:

Finally found one: http://www.webreference.com/programming/javascript/gr/column11/

EDIT2:

This one is better: http://www.geekpedia.com/tutorial198_Creating-a-Rich-Text-Editor-using-JavaScript.html

~G

Graphix 68 ---

You mean blur = make more light?

See the following link: http://www.w3schools.com/Css/css_image_transparency.asp

~G

Graphix 68 ---

It is positioned fixed:

<div style='position:fixed; bottom:0px; left:0px; height:20px; width:100%; background-color:blue; z-index:100000000000;'>
 This is a bar on the bottom
</div>

However, this only works in FF. As you can see at DaniWeb, the toolbar only pops up in FF and not in IE.

~G

Graphix 68 ---

Look, I was willing to correct your code and remove the syntax errors. Apply my code, and work the PHP out yourself. The JavaScript timer should work. Also check the HTML source code for wrong output.

~G

Graphix 68 ---

As this is urgent, iil give you the solution, but study the code and learn from your mistakes. Each code lines needs to end with a ;, use more spaces and pay attention on how I use the setTimeout() function:

setTimeout(function(){
//Here should be all the code you want executed
}, 0);

And here how it is implemented:

<script type='text/javascript'> 
<!-- 

 var milisec=0;
 var seconds=<?php echo $s;?>;
 // I directed this (document.counter.d2.value='0';) to setTimeout, as the document has not yet been loaded

function display(){ 
 if (milisec <= 0){ 
    milisec = 9;
    seconds -= 1; 
 } 
 if (seconds <= -1){ 
    milisec = 0;
    seconds += 1;
 } else {
    milisec-=1;
    document.counter.d2.value=seconds;
    setTimeout(function(){ display(); },100);
 }
} 
window.onload=function() {
document.counter.d2.value='0';
display();
}
--> 
</script>

~G

Graphix 68 ---

Well, that is alot more difficult. Anyway here how it is done:

<form name='MyForm' onsubmit='checkValue();' action=''>

And then in the JavaScript:

var form_allowed_to_submit = false; // This is a global variable

function checkValue() {
 if (form_allowed_to_submit == false) {
  prompt2('Confirm','Do you realy want to submit form?', 'yes()','no()','Yes','No');
 }
 return form_allowed to_submit;
}

And then in your yes() function:

form_allowed_to_submit = true;
document.MyForm.submit();
Graphix 68 ---

I hope you set the variable $id in code you have not shown yet, and cleaned that with htmlentities() and addslashes(). If you are counting on register_global of PHP, you are creating a huge security leak. Well anyway, to solve your problem, you first need to select the row, check whether there is a row with that id (num_rows > 0) and then delete it:

$q1 = "SELECT * FROM databasemanager WHERE id='".$id."' LIMIT 1";
$r1 = mysql_query($q1) or die("Could not retrieve row. 1");

if (mysql_num_rows($r1) > 0) { // If the id exists

$q2 = "DELETE FROM databasemanager WHERE id='".$id."' LIMIT 1 ";
$r2 = mysql_query($q2) or die("Could not delete row. 2");

// The rest of your code...

}

~G

Graphix 68 ---

You can easily ask the user whether he wants to submit the form or not:

<form method='post' action='' onsubmit='return confirm("Are you sure you want to submit this form?");'>

The confirm() returns true if the user selected "yes" and false if the user selected "no".

~G

Graphix 68 ---

You can not open a .js file in your browser. You need to link it to a HTML file by using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My first page with JavaScript</title>
<script type='text/javascript' src='scripts/MyScript.js'></script>
</head>
<body>
</body>
</html>

Or write the code into the HTML file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My first page with JavaScript</title>
<script type='text/javascript'>
alert("This is some JavaScript code!");
</script>
</head>
<body>
</body>
</html>

~G

Graphix 68 ---

I don't know how the update() function is formatted. Post your code else I can't help.

~G

Graphix 68 ---

Thats fairly easy:

<script type='text/javascript'>window.onload=function(){ update(document.getElementById('qty')); }</script>

You should place this beneath the form HTML, so that the id already exists.

~G

pietpiraat commented: Great helper +0
Graphix 68 ---

line 21 - You put pans at 1 every time the loop is repeated.

~G

aladar04 commented: sorry, not helpful. +0
Graphix 68 ---
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = 1;
}

~G

Graphix 68 ---

It should work, seeing your code. Perhaps change the name of the input to "submitbutton' to avoid complications, also do not use the alt attribute. If that doesn't work, perhaps you should use the following:

<form method="post" name='BidForm'>
... The rest of the table...
<img src='images/console_button_place_bid.gif' alt='Place Bid' onmouseover='this.style.cursor="pointer"' onclick='document.BidForm.submit()' />
</form>

~G

Graphix 68 ---

I personally don't like regex, as it takes alot of processing time and it's syntax is very difficult. You can better use a own written function that just simply loops the string, checking each character whether you want it in or not:

function checkString(var string) {

   var stringlength = string.length;
   var i;
   for (i = 0; i < stringlength; i++) {
      if ((string.substr(i, 1)) == "#") {
         alert("Invalid string!");
      }
   }
}

Anyway, for your regex question: see the following page: http://www.evolt.org/article/Regular_Expressions_in_JavaScript/17/36435/

~G

Graphix 68 ---

- What would be better in this situation, to use XML or a TEXT string with the AJAX call back?

Well the easiest way to do this is to let the PHP-script that is called with AJAX to just simply return the entire table (<table> etc. etc. </table>. For example, this is the space in which the table needs to popup:

<div id='TableDiv'>
</div>

and then with the ajax-call/refresh function:

... The call ...
   document.getElementById('TableDiv').innerHTML = xmlhttp.ResponseText;
... The rest of the function ...

- With the "lower list", does each separate line/list element need to be with a form element?

The table can also be something like this, where only 1 form is required. The form can not be submitted, else the page will be reloaded. So you need to add an id to your MySQL-table as well, which is used as an argument in the functions for editing and removing. The edit function and remove function also need to have AJAX-calls to a PHP-script that gets an ID as POST/GET - data. A small example (the 1 in the RemoveTransaction and ShowFormTransaction are the ID's):

<form id='ListForm' method='post' onsubmit='return false;'>
<table
<tr>
<td>A Tranaction name..</td>
<td>Some type</td>
<td>68596</td>
<td>-97900</td>
<td>2009-08-19</td>
<td><input type='button' onclick='RemoveTransaction(1)' value='Remove' /></td>
<td><input type='button' onclick='ShowFormEditTransaction(1)' value='Edit' /></td>
</table>
</form>

- It seems there are so many types of strategies for moving data ...

See previous question

Graphix 68 ---

You are making a list that has:

>> A column with the transaction name
>> A column with the type
>> A column with the positive amount
>> A column with the negative amount
>> A column with the date and time of the transaction
>> A column with a button that onclick shows a form on adding a row
>> A column with a button that onclick shows a form on deleting a row
>> A column with a button that onclick shows a form to edit a row

Do you want the page to be reloaded with every action, or do you want it to automatically reload without the refresh.

If you want the page to reload, you only need to use PHP, MySQL and HTML. Everything is handled by the PHP script, on the reload the PHP script is re-executed and shows HTML depending on what POST/GET data it received. I'd suggest you should read PHP and MySQL for Dummies and XHTML for Dummies.

If you do not want the page to reload, you need to use PHP, MySQL, HTML and JavaScript/AJAX. The forms need to show up by using JavaScript, and when the Delete/Add/Modify button is called, a AJAX call to the PHP-script goes out with the form data and retrieves the new rows after processing the action that is required. This is the more advanced way, but can be the best if you do …

Graphix 68 ---

As far as I could see, there does not exist a counter folder in which a count.db exists. So create a folder named "counter" and create a file in that named "count.db"

~G

Graphix 68 ---

Select the database in the dropdown -> export tab -> Start button -> Depending on the options you selected phpmyadmin will return a sql file or you see it in a textarea.

~G

Graphix 68 ---

If you only want the form to be submitted from your page, you can use an ID, which is formed out of the current date and some other variables, that is send with the form.

~G

Graphix 68 ---

Your code works. Only you need to use "checked" as a value for the attribute "checked", as this is the only valid value.

<script type="text/javascript">
function checkAll(checkname, exby) {
for (i = 0; i < checkname.length; i++)
  checkname[i].checked = exby.checked ? "checked" : "";
}
</script>

<form name="form2" method="post" action="?action=evaluate"> 
  <input type="checkbox" name="all" onClick="checkAll(document.form2.checkGroup,this)">Check/Uncheck All<br>
  <input type="checkbox" name="checkGroup" value ="first">First<br>
  <input type="checkbox" name="checkGroup" value ="second">Second<br>
  <input type="checkbox" name="checkGroup" value ="third">Third<br>
  <input type="checkbox" name="checkGroup" value ="fourth">Fourth<br>
<input type="submit" name="Submit" value="Submit" style="height:23px;font-weight:bold;padding-top:0px;">
</form>

But your code works also without this small modification. If not, update your browser, it works in FF and IE.

~G

Graphix 68 ---

The small piece of code you gave, has some pretty strange coding:

Line 1 - edit is a constant???
Line 5 - Where, is this even a keyword or function ?????

Anyway, you can use the id retrieved from the GET and use that in the query that updates:

$id = $_GET['id'];
$query = "UPDATE table SET someval='$someval' WHERE id='$id'";

Also perhaps add a line that echoes what the value of $_GET is to see wheter the id is properly passed.

Explain your problem more clearly.

~G