raphie 3 Light Poster

Are you using Dreamweaver because of your current job or just because you have bought it. This feature is available with Netbeans from Oracle, at work I have to use Dreamweaver CS3 but I download Netbeans for better and faster coding. It has the power of Dreamweaver and the cool features of Notepad++.

Dreamweaver has visual aid for some basic html things but for server script coding functions and all that it's not. Netbeans also include in the visual aids the functions and classes you create, downside doesn't have visual editor... All coding.

raphie 3 Light Poster

Try to use instead of id="myusername" use name="myusername", depending how you processing the form and the server you are using, sometimes cause problems. $_POST is normally set by the name of the input not the id. In some systems a nameless input is considered disabled an pass no values.

You can try seeing what's the post with:

print_r($_POST)
raphie 3 Light Poster

OK, this is it:

This is a example, I will not use any of your names. When the file returns to the page you need to check the data base for today's date. If a row is found then the class recorded is going to be echoed.

<?php
//your php code for your db connection goes here
mysql_connect('host','user','password') or die('Unable to connect!');
mysql_select_db('your_database');

$sql = "SELECT `id_field` FROM `your_table` WHERE `date` = ".date('Y/m/d')." AND `name` = '".$_SESSION['name']."';";
$qry = mysql_query($sql) or die('Unable to get information');
$res = mysql_num_rows($qry);

$class = ($res > 0)? 'class="recorded"' : '';
?>
<!DOCTYPE html>
<head>
<style>
   .recorded{
        border:2px white solid;
        border-radius:5px; //round corner for modern browsers
        -moz-border-radius:5px; //round corner for old mozilla
        -webkit-border-radius:5px; //round corner for old Chrome or Safari
        background: red;
        box-shadow: 0 2px 4px black; //shadow for modern browsers
        -moz-box-shadow: 0 2px 4px black; //shadow for old mozilla
        -webkit-box-shadow: 0 2px 4px black; //shadow for old Chrome or Safari
        font:italic bold 12px/14px sans-serif;
        text-align:center;
   }
</style>
</head>
<body>
   <form>
       <label>Name: <input name="name" value="" /></label>
       <input <?php echo $class; ?> type="submit" name="submit" value="Submit" />
   </form
</body>
</html>

That's all. When the page is loaded will fetch your database for any info on the current day, date format 2011/11/25. Set depending your code. If a record is found will echo the class recorded for the button. I added a sample for the css. Remember that the css has to be linked by an external css file or between the head of the page.

raphie 3 Light Poster

Yes.. you didn't have a connection inside the function, Any connection outside a function does not affect the function itself, the function has to have it same connection.

The best thing I suggest you to create a class with the connection then call the class whenever you need it instead of coding connection all the time.

raphie 3 Light Poster

The error at line 47 is a missing } that's on your get categories, is all wrong... follow the code I post before this one.

raphie 3 Light Poster

Sorry.. you need to put the code I suggest inside the function after your $query, you can only use else with an if statement.

function get_categories($id = null){
        //YOU NEED A CONNECTION CODE HERE AS MENTIONED BY cereal
        $con = mysql_connect("localhost","user","password");
        mysql_select_db('your_database')
        or die("There was an error connecting to the table");
	
        $categories = array();
	
	$query = mysql_query("SELECT `id`, `name` FROM `categories`");
	
        if(is_resource($query)){
	     while( $row = mysql_fetch_assoc($query)) {
		     $categories[] = $row;
	     }
	
	     return $categories;
       } else {
	     die(mysql_error());
       }

}
raphie 3 Light Poster

use..

if(is_resource($query)){
	while( $row = mysql_fetch_assoc($query)) {
		$categories = array('id'=>$row['id'],'name'=>$row['name']);
	}
        return $categories;
} else {
        die(mysql_error());
}

To see what happens!

raphie 3 Light Poster

OK, the problem here is that is not clear what you're trying to accomplish..

You had 1 form in layout.php and you want the button change base on the current day right. But then you want to display a list of all the records saved for the week or the month?

In that case the code I wrote is what you need, just change title to name. The color is changed by a CSS...

for example you have class="recorded", then you program the css this way, either in an external css file or between a <style> tag in the head of the page.

<style>
    .recorded {
         background:red;
    }
</style>

but you only apply the recorded class if the record is found.

The code has to be entered in the layout.php, But that was a sample made out of nothing, I didn't have all the info.

raphie 3 Light Poster

I guess the information is stored in a database right?

If so query the database and if record is true echo a different state of the button:

<?php
include_once your_connection_page.php
mysql_select_db(yourdatabase);

$q = mysql_query("SELECT `id`,`title`,`date` FROM `your_db_name` WHERE `user` = `".$_SESSION['user']."`;") or die('Error retrieving info!');
$r = mysql_num_rows($q);

if($r > 0){
echo '<ul>';
while($a = mysql_fetch_object($q)){
    echo '<li><form method="get" action="?edit='.$a->id.'">Record "'.$a->title.'" Saved on '.$a->date.'! <input class="recorded" name="submit" type="submit" value="Edit"/></form></li>';
}
echo '</ul>';

}

//here your new record form

?>

This generate a list of all the records stored under the user, when click the button Edit will refresh the page then you have to have a code to receive the $_GET array to populate the form.

raphie 3 Light Poster

Looking good, Internet Explorer 9, Windows Vista Ultimate SP2, but I have a really slow connection and the slider blinks until all the images are completely loaded, you might considered to show an alternate static image then when the page is completely loaded then start the slider.

raphie 3 Light Poster

Yes I love FireBug but don't know why for some reason is staying behind all of Firefox latest updates and Firefox disable it for few days until a new update is made to FireBug, so I'm using Chrome developers tool that is a copy of IE developer tools but with the new HTML5 capabilities. Then at last I filter everything out with IE to see all the errors that the other browsers didn't find...;)

raphie 3 Light Poster

OK, this is what I found...

As Dandello said you have to many unnecessary div that you're actually using to hack the browsers. For example you have a div with class clear with a margin-top set to -530px over your problematic div sub_right_column_container. This force the problematic div to be move to the right of the div class container_padding.

Here is the problem, sometimes IE does not set any height or width to empty div's as well firefox, but from time to time firefox fix the problem. Google and any Webkit browser accept any pre-configuration made by the css even if the div is empty.

Because your div's are overlapping one above the other, they do not align side by side even if you set the display to inline-block. What I did in the developer tool was delete every empty div class clear remove the right padding of the child div from the div that's supposed to be on the left, and set the width of the sub_right_column_container to 700px; a Voilá, the div align side by side.

Now, Internet Explorer, because is doesn't giving any property to the div class clear before the sub_right_column_container div, then the margin-top set to -530px to the div class clear is pulling your div sub_right_column_container bellow the presentation. Because the presentation is set by JavaScript the HTML DOM understand that the last element entered is the slider and appear above your columns.

Hope this help a little, the …

raphie 3 Light Poster

There's another solution that you might want to look at in the browsers discrepancies that might suit you better, I just find it and is quite interesting.

Check this! Using the same conditional in a more elegant manner.

raphie 3 Light Poster

I think is wrong in css

The technique you use to manipulate your page is not an issue of wrong or right. There are standards for CSS3 that Internet Explorer hasn't updated while the rest of the browsers have.

Even Microsoft is forcing their customer to buy the new operating system if they want to have support.

This technique is widely use in web design. As I said, is not a matter of rigth or wrong is a matter of browsers incompatibility.

raphie 3 Light Poster

The tag used in the el object is a div, sure you can set up the widht and the height, the thing is not the width... width is adjusted properly, the problem is the height...

Even though you force to add a height with JavaScript, FF doesn't like it either with 'px' or without.

I used to feel uncomfortable using a framework like jQuery but since I save like 700 lines of codes with it in one of my projects I forgot that. They handle the DOM elements like everybody else, targeting a browser, who ever return true that good and then a method for that browser is used.

raphie 3 Light Poster

I tried it an won't work... Then I tried it using jQuery and it works:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>

function resize(){

	var bodyWidth = $(document).width();
	var bodyHeight = $(document).height();
	var bodySize = $(document.body);
	var el = $('#elm2');
	
	if( bodyWidth < 1000){
		el.css('min-width', '1000px');
		bodySize.width(1000);
	} else {
		el.css('width','100%');
		bodySize.width(bodyWidth);
	}
	if( bodyHeight < 600){
		el.css('min-height', '600px');
		bodySize.width(600);	
	} else {
		el.css('height','100%');
		bodySize.height(bodyHeight);
	}

}
</script>
</head>
<body id="elm1" onResize="resize();" style="height:100%" >
<div id="elm2" style="border:1px solid black; width:100px; height:100px;"></div>
</body>
</html>

Also notice that I added the style height 100% inline in the body tag.

raphie 3 Light Poster

try:

<!DOCTYPE html>
<html>
<head>
<script>

function resize(){

var bodyWidth = document.body.offsetWidth;
var bodyHeight = document.body.offsetHeight;
var el = document.getElementById('elm2').style;

if( bodyWidth < 1000){
	el.width='1000px';	
} else {
	el.width='100%';
}
if( bodyHeight < 600){
	el.height='600px';	
} else {
	el.height='100%';
}

}
</script>
</head>
<body onResize="resize();">
<div id="elm2"></div>
</body>
</html>

In firefox if you set the element to 100% height tend to display the scrollbar so probably you should use like 98%

raphie 3 Light Poster

Glad to help.... Good luck with PHP, is the best web language and powerful.

raphie 3 Light Poster

Ay Chihuahua!!! Let me see what's wrong!

Ok, the only thing I can see is this... in line 42 the if statement has

if( isset($_POST['submit']) && $_POST['submit']){

Change it to:

if( isset($_POST['submit']) && $_POST['submit'] == 'Update'){
raphie 3 Light Poster

OK, here it is, I hope:

<?php
include("admin_header.php"); 

$id = isset($_GET['artist_id']) ? $_GET['artist_id'] : null;

$connect = mysql_connect ("localhost","root","") or die("Unable to connect to mysql database server");
mysql_select_db("gallery");

if(isset($id)){
    $query = "SELECT * FROM `artist` WHERE `artist_id` = ".$id.";";
    $result=mysql_query($query) or die(mysql_error()); 
    $num=mysql_num_rows($result); //changed

    echo $result;
    echo $num;

    // Changed code
    if($num > 0){
        while ($a = mysql_fetch_object($result)){

            $firstname=$a->firstname;
            $surname=$a->surname;
            $bibliography=$a->bibliography;
            $phone=$a->phone;
            $email=$a->email;

            echo '<form action="admin_artist_edit.php" method="post">
            <td align="center"><input name="edit_id" type="hidden" value="'.$id.'"></td></br>
            <strong>First Name:</strong><td align="center"><input name="edit_firstname" type="text" value="'.$firstname.'"></td></br>
            <strong>Surname:</strong><td align="center"><input name="edit_surname" type="text" value="'.$surname.'"></td></br>
            <strong>Bibliography:</strong><td align="center"><input name="edit_bibliography" type="text" value="'.$bibliography.'"></td></br>
            <strong>Phone:</strong><td align="center"><input name="phone" type="text" value="'.$phone.'"></td></br>
            <strong>Email:</strong><td align="center"><input name="email" type="text" value="'.$email.'"></td></br>
            <input type="submit" value="Update">
            </form>';
        }
    }
} // this little guy cause the error


if( isset($_POST['submit']) && $_POST['submit']){
    // Because the field names are the same as the variable names you can to this instead
    foreach($_POST as $k=>$v){
            ${$k} = $v;	//Dynamic Variables;
    }

    $query=mysql_query("UPDATE `artist` SET `firstname`='".$edit_firstname."', `surname`='".$edit_surname."', `bibliography`='".$edit_bibliography."', `phone`='".$edit_phone."', `email`='".$edit_email."' WHERE `artist_id`='".$edit_id."';");
    $review_update = mysql_affected_rows(); //Added
    if($review_update > 0){
    echo 'Record Updated';
    } else {
    echo 'Unable to Update';
    } 
}


mysql_close();
?>

The error was a curly bracket in the if statement I create, also I remove the else that echo Provide ID, because we're using the same PHP code to process the edit form and the update form. Also I simplify the code a little bit as follow:

The original code was:

if( isset($_POST['submit']) && $_POST['submit'])
{ 
$edit_id = ($_POST['edit_id']);
$edit_firstname=$_POST['edit_firstname'];
$edit_surname=$_POST['edit_surname'];
$edit_bibliography=$_POST['edit_bibliography'];
$edit_phone=$_POST['edit_phone'];
$edit_email=$_POST['edit_email'];
}

Because the fields and variables has the same name and post …

raphie 3 Light Poster

That's good your not getting the MySQL error... the rest is just little typos in the code let me see what's wrong and I post the code.

raphie 3 Light Poster

Yes I see, my mistake... sorry I need my coffee :)
Try this:

<?php
include("admin_header.php"); 

$id = isset($_GET['artist_id']) ? $_GET['artist_id'] : null;

$connect = mysql_connect ("localhost","root","") or die("Unable to connect to mysql database server");
mysql_select_db("gallery");

if(isset($id)){
$query = "SELECT * FROM `artist` WHERE `artist_id` = ".$id.";";
$result=mysql_query($query) or die(mysql_error()); 
$num=mysql_num_rows($result); //changed

echo $result;
echo $num;

// Changed code
if($num > 0){
	while ($a = mysql_fetch_object($result)){
		
		$firstname=$a->firstname;
		$surname=$a->surname;
		$bibliography=$a->bibliography;
		$phone=$a->phone;
		$email=$a->email;
		
		echo '<form action="admin_artist_edit.php" method="post">
		<td align="center"><input name="edit_id" type="hidden" value="'.$id.'"></td></br>
		<strong>First Name:</strong><td align="center"><input name="edit_firstname" type="text" value="'.$firstname.'"></td></br>
		<strong>Surname:</strong><td align="center"><input name="edit_surname" type="text" value="'.$surname.'"></td></br>
		<strong>Bibliography:</strong><td align="center"><input name="edit_bibliography" type="text" value="'.$bibliography.'"></td></br>
		<strong>Phone:</strong><td align="center"><input name="phone" type="text" value="'.$phone.'"></td></br>
		<strong>Email:</strong><td align="center"><input name="email" type="text" value="'.$email.'"></td></br>
		<input type="submit" value="Update">
		</form>';
	}
} else {
	echo '<h1>Provide Id</h1>';
}


if( isset($_POST['submit']) && $_POST['submit'])
{ 
$edit_id = ($_POST['edit_id']);
$edit_firstname=$_POST['edit_firstname'];
$edit_surname=$_POST['edit_surname'];
$edit_bibliography=$_POST['edit_bibliography'];
$edit_phone=$_POST['edit_phone'];
$edit_email=$_POST['edit_email'];
}

if (isset($_POST['submit']) && $_POST['submit'])
{
$query=mysql_query("UPDATE `artist` SET `firstname`='".$edit_firstname."', `surname`='".$edit_surname."', `bibliography`='".$edit_bibliography."', `phone`='".$edit_phone."', `email`='".$edit_email."' WHERE `artist_id`='".$edit_id."';");
$review_update = mysql_affected_rows(); //Added
if($review_update > 0){
echo 'Record Updated';
} else {
echo 'Unable to Update';
}
 
}


mysql_close();
?>

forgot to remove the first mysql_error(); in line 13 and forgot one open { curly bracket in the if statement... Let me do my coffee. keep me posted!

raphie 3 Light Poster

What an Idiot am I! gosh... Sorry I didn't catch this before.

Are you receiving the error when selecting the artist to edit or when updating the information?

The first query is always running even if $id is not set.

Try this!

<?php
include("admin_header.php"); 

$id = isset($_GET['artist_id']) ? $_GET['artist_id'] : null;

$connect = mysql_connect ("localhost","root","") or die("Unable to connect to mysql database server");
mysql_select_db("gallery");

if(isset($id)){
$query = "SELECT * FROM `artist` WHERE `artist_id` = ".$id.";";
$result=mysql_query($query) or die(mysql_error()); 
$num=mysql_num_rows($result); //changed
mysql_close();

echo $result;
echo $num;

// Changed code
if($num > 0)
	while ($a = mysql_fetch_object($result)){
		
		$firstname=$a->firstname;
		$surname=$a->surname;
		$bibliography=$a->bibliography;
		$phone=$a->phone;
		$email=$a->email;
		
		echo '<form action="admin_artist_edit.php" method="post">
		<td align="center"><input name="edit_id" type="hidden" value="'.$id.'"></td></br>
		<strong>First Name:</strong><td align="center"><input name="edit_firstname" type="text" value="'.$firstname.'"></td></br>
		<strong>Surname:</strong><td align="center"><input name="edit_surname" type="text" value="'.$surname.'"></td></br>
		<strong>Bibliography:</strong><td align="center"><input name="edit_bibliography" type="text" value="'.$bibliography.'"></td></br>
		<strong>Phone:</strong><td align="center"><input name="phone" type="text" value="'.$phone.'"></td></br>
		<strong>Email:</strong><td align="center"><input name="email" type="text" value="'.$email.'"></td></br>
		<input type="submit" value="Update">
		</form>';
	}
}
} else {
	echo '<h1>Provide Id</h1>';
}


if( isset($_POST['submit']) && $_POST['submit'])
{ 
$edit_id = ($_POST['edit_id']);
$edit_firstname=$_POST['edit_firstname'];
$edit_surname=$_POST['edit_surname'];
$edit_bibliography=$_POST['edit_bibliography'];
$edit_phone=$_POST['edit_phone'];
$edit_email=$_POST['edit_email'];
}

if (isset($_POST['submit']) && $_POST['submit'])
{
$query=mysql_query("UPDATE `artist` SET `firstname`='".$edit_firstname."', `surname`='".$edit_surname."', `bibliography`='".$edit_bibliography."', `phone`='".$edit_phone."', `email`='".$edit_email."' WHERE `artist_id`='".$edit_id."';");
$review_update = mysql_affected_rows(); //Added
if($review_update > 0){
echo 'Record Updated';
} else {
echo 'Unable to Update';
}
 
}

mysql_close();
?>

The selecting should not be process if $id is null. So is running even when you're updating the information, but because we close the mysql connection the second query will not be processed because you need to open the connection again, so I delete the first mysql_close(); and enclosed …

raphie 3 Light Poster

I made some changes to the code... see if it works

<?php
include("admin_header.php"); 

$id = isset($_GET['artist_id']) ? $_GET['artist_id'] : null;

$connect = mysql_connect ("localhost","root","") or die("Unable to connect to mysql database server");
mysql_select_db("gallery") or die ("Couldnt find database");

$query = "SELECT * FROM `artist` WHERE `artist_id` = ".$id.";";
$result=mysql_query($query) or die(mysql_error()); 
$num=mysql_num_rows($result); //changed
mysql_close();

echo $result;
echo $num;

// Changed code
if($num > 0)
	while ($a = mysql_fetch_object($result)){
		
		$firstname=$a->firstname;
		$surname=$a->surname;
		$bibliography=$a->bibliography;
		$phone=$a->phone;
		$email=$a->email;
		
		echo '<form action="admin_artist_edit.php" method="post">
		<td align="center"><input name="edit_id" type="hidden" value="'; echo $id; echo '"></td></br>
		<strong>First Name:</strong><td align="center"><input name="edit_firstname" type="text" value="'; echo $firstname; echo '"></td></br>
		<strong>Surname:</strong><td align="center"><input name="edit_surname" type="text" value="'; echo $surname; echo '"></td></br>
		<strong>Bibliography:</strong><td align="center"><input name="edit_bibliography" type="text" value="'; echo $bibliography; echo '"></td></br>
		<strong>Phone:</strong><td align="center"><input name="phone" type="text" value="'; echo $phone; echo '"></td></br>
		<strong>Email:</strong><td align="center"><input name="email" type="text" value="'; echo $email; echo '"></td></br>
		<input type="submit" value="Update">
		</form>';
	}
}
mysql_close(); //moved after results


if( isset($_POST['submit']) && $_POST['submit'])
{ 
$edit_id = ($_POST['edit_id']);
$edit_firstname=$_POST['edit_firstname'];
$edit_surname=$_POST['edit_surname'];
$edit_bibliography=$_POST['edit_bibliography'];
$edit_phone=$_POST['edit_phone'];
$edit_email=$_POST['edit_email'];
}

if (isset($_POST['submit']) && $_POST['submit'])
{
$query=mysql_query("UPDATE `artist` SET `firstname`='$edit_firstname', `surname`='$edit_surname', `bibliography`='$edit_bibliography', `phone`='$edit_phone', `email`='$edit_email' WHERE `artist_id`='$edit_id';");
$review_update = mysql_affected_rows(); //Added
if($review_update > 0){
echo 'Record Updated';
} else {
echo 'Unable to Update';
}
 
mysql_close();
}


?>

I just changed the mysql_close in the Select query to after the result displayed, remove one or die() after the mysql_num_rows that's not needed. Then change the while statement a little bit.

raphie 3 Light Poster

I've changed the code like this... see if it's work!

//Getting the artist where the id match
$query = "SELECT * FROM artist WHERE artist_id = ".$id.";";
$result=mysql_query($query) or die(mysql_error());
$num=mysql_num_rows($result);

//creating an edit form

// Changed code
if($num > 0)
	while ($a = mysql_fetch_object($result)){
		
		$firstname=$a->firstname;
		$surname=$a->surname;
		$bibliography=$a->bibliography;
		$phone=$a->phone;
		$email=$a->email;
		
		echo '<form action="admin_artist_edit.php" method="post">
		<td align="center"><input name="edit_id" type="hidden" value="'; echo $id; echo '"></td></br>
		<strong>First Name:</strong><td align="center"><input name="edit_firstname" type="text" value="'; echo $firstname; echo '"></td></br>
		<strong>Surname:</strong><td align="center"><input name="edit_surname" type="text" value="'; echo $surname; echo '"></td></br>
		<strong>Bibliography:</strong><td align="center"><input name="edit_bibliography" type="text" value="'; echo $bibliography; echo '"></td></br>
		<strong>Phone:</strong><td align="center"><input name="phone" type="text" value="'; echo $phone; echo '"></td></br>
		<strong>Email:</strong><td align="center"><input name="email" type="text" value="'; echo $email; echo '"></td></br>
		<input type="submit" value="Update">
		</form>';
	
	}
}
mysql_close();

Just change the mysql_close(); after the result. I always use mysql_fetch_object() as my preference.

raphie 3 Light Poster

The error is displayed after the echo?

If so, did the first post has a submit button named 'submit'?

Then if so, is trying to run both queries at the same time... because the if statement at line 36 suggest that the condition is to $_POST be true.

But this is my other question.

I don't see an 'or die()' function in either queries, at least not in the first post. Then how can you get an error echoed? I just see an 'or die()' function in the database connection function only.

raphie 3 Light Poster

I thought the problem was the update...

Sometimes I get that error when the variable is inside quotes... don't know why?

try changing to:

$query = "SELECT * FROM artist WHERE artist_id = ".$id.";";

to see what happens..

raphie 3 Light Poster

There are two query requests, one in line 49 and one in line 50, delete line 50 to see what happens!

Also I suggest to add:

$review_update = mysql_affected_rows(); //after update query

if($review_update > 0){
 echo 'Record Updated';
} else {
 echo 'Unable to Update';
}

mysql_close();

otherwise will say Record Updated even if record is not!

raphie 3 Light Poster

The other error I noticed is that the form method is post and your requesting the $_GET and should be $_POST;

Never mind, $_GET is for the edit.

raphie 3 Light Poster

I want to check whether the username(here email)exists or not.

I kind of lost here, you want to process the information, if the username is in the database then you want to return the result to the jQuery?

if so then you need to add a line to the last part of the code in the success function:

$.get("db.php", { username: $('#username').val();},
   function(data){
     alert("Username: " + data);
   });

in other worlds you need to do an additional ajax request as far as jQuery that I know of. But the php sample you gave is right.

You can find more information in here:

jQuery.get();
jQuery.load();

raphie 3 Light Poster

To validate empty values in jQuery you can use:

emailVal = $('#email').val();

if(emailVal.length == 0){
    alert('Email value is empty');
    error = 1;
}

This validation has to be done before any other process so you need to close your code among:

if(error == 0){
   //The code to execute if validation is true;
}

Also you can create a function to validate the form if the function return true then execute the jQuery function. Example:

function validateFields(formName){
    //get the elements of the form
    form = document.form[formName].elements;
    lenght = form.length;
    for(i=0;i<length;i++){
       fieldname = form[i].name;
       value = form[i].value;
       if(fieldname.indexOf('email') > 0 && value == ''){
           alert(fieldName+' is empty!');
           return false;
           break;
       }
    }
    return true;
}

Then you can make a list of fields to validate in the function.

Hope this helps!

raphie 3 Light Poster

You might need to create and CSS specially for IE and added in the source code... example:

<!--[if IE]>
<style>
#sub_right_column_container {
    margin-top:80px;
}
<!-- or external link -->
</style>
<link type="txt/css" href="/css/ie_hacks.css" rel="stylesheet" media="all" />
<![endif]-->

Between the <head> tags.

It happens to me in a page I designed with Wordpress, any browser view it in a way and IE other way. rodolfofont.com

raphie 3 Light Poster

As dandello said, you need to use UBB code...

If you're using jQuery look for the cleditor plug-in or the UBB editor plug-in here.

If adding the code option is what you really need try this one in corpocrat.com .

raphie 3 Light Poster

I used to face that problem but was such a long time I don't even use Wordpress so often, but there's a page that normally has an empty space bellow the line code

?>

When you remove that space this fix the problem in some cases. Also check if the line 934 has a setcookie() function, this also cause this problem in some servers, don't know why.

Check wp-settings.php or wp-config.php, I think the problem was an empty line after the code. But as I said, it's being a long time. I found the solution in the Wordpress page at wordpress.org.

Also, if you made an upgrade would've be nice to reload the old Wordpress files if you backed up the database before installing the new version.

raphie 3 Light Poster

Every time you use JavaScript to pass information to a PHP page you need to make sure to encode the strings. And also to add slashes before sending to Database.

Normally the problem relies in JavaScript handling string information. If the string includes and &(ampersand) will break the string into two different variables. The same if the string has quotes or single quotes.

If you're not receiving and error from the mysql_error() then the problem is in the JavaScript not the PHP.

raphie 3 Light Poster

Try to encode the string. JavaScript doesn't like quotes, ampersand or others alpha numeric characters that are use to suggest the closing of a variable or a function in JavaScript.

escape($('#desc').val());

Then when you retrieve the strings in the addpg.php make sure to use

stripslashes($_POST['desc']);

if you want to echo the information back, but you can leave it like that to send it to the database, if you use addslashes() will add double slashes. I least by my experience with the same problem.

Hope this help!

raphie 3 Light Poster

I think you're needing Regular Expressions methods look into the PHP Manual you might find what you're looking for!

For example:

preg_match('/'.$space.'/g',$search);

or

preg_match('/(hello|world)/g',$search);

This will match all the occurrences in a string that matches whatever is in the $space variable or by the worlds between the parenthesis separated by the column (I don't remember exactly how that symbol is called, sorry!)

raphie 3 Light Poster

You need javascript or jQuery. Everything to be requested on the user side has to be handle by javascript, now, if you just want to refresh the page and then retrieve the information you need to use ardav solution as well, for example with a GET method the form attribute should look like this:

<form name="nameOfForm" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
$years = array();
for ($i = 1900; $i < 2026; $i++)
{
  $years[] = $i;
} 
echo "<select name='Year'>";
foreach($years as $option){
	echo "<option value='{$option}'>{$option}</option>";	
}
echo "</select>";
?>
<input type="submit" name="submit" value="Save Year" />
</form>
<?php
if($_GET){
   echo 'The year selected is '.$_GET['Year'];
}

// also you can retrieve all the elements of the form creating dynamic variables like this

if($_GET){
  foreach($_GET as $k=>$v){

     ${$k}=$v;

  }
}
?>

In the action of the for I'm using $_SERVER which is the same page the form is, when form is submitted then the form is processed in the same page.

If you retrieving all the elements as an array the variables will be named after the field names example:

<select name="Year"> will be the variable $Year and <input name="submit"> will be variable $submit.

Hope this help.

Behseini commented: Perfect Reply +3
raphie 3 Light Poster

OK, this is the code to print a PDF file using JavaScript/PHP cross browser... well I just test it in Firefox and IE, but I use a code for Safari, so I guess it works in Safari at least MacOS

<?php

$browser_ver = get_browser(null,true);
//echo $browser_ver['browser'];

if($browser_ver['browser'] == 'IE') {
?>

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pdf print test</title>
<style>
html { height:100%; }
</style>
<script>
function printIt(id){
var pdf = document.getElementById("samplePDF");
pdf.click();
pdf.setActive();
pdf.focus();
pdf.print();
}
</script>
</head>

<body style="margin:0; height:100%;">

<embed id="samplePDF" type="application/pdf" src="/pdfs/2010/dash_fdm350.pdf" width="100%" height="100%" />
<button onClick="printIt('samplePDF')">Print</button>


</body>
</html>

<?php
} else {
?>
<HTML>
<script Language="javascript">

function printfile(id)
{ 
window.frames[id].focus();
window.frames[id].print();
} 

</script>
<BODY marginheight="0" marginwidth="0">

<iframe src="/pdfs/2010/dash_fdm350.pdf" id="objAdobePrint" name="objAdobePrint" height="95%" width="100%" frameborder=0></iframe><br>

<input type="button" value="Print" onclick="javascript: printfile('objAdobePrint');">

</BODY>
</HTML>
<?php
}
?>

base on this code I think a can generate a loop to print, the obstacle now is that the customer has to click print for each page... but with the use of FPDF with FPDI I can create a PDF file extracting pages from the requested PDF files then set print true in the PDF JavaScript as indicated in the API Reference guide from Adobe Acrobat 8.

As I was reading in the FPDF manual you can embed javascript into a PDF file. Now I only need to figure out how to do this dynamically with PHP and Javascript.

But for the moment I think this will help some …

raphie 3 Light Poster

Sound like a great solution, but as you said is the command line utility that needs to be processed to install it in the server, which is not possible for me until the customer finish the process of installing it's own hosting server. Still is discussion, :(

But I found some classes and functions that might help in the meantime, at least to create and print PDF files from a web page.

FPDF seems to be a quick solution, I bump into it today...http://http://www.fpdf.org/ and it has a automatic print solution too in the following link http://www.fpdf.org/en/script/script36.php.

Apparently these functions allow developers to generate a workaround with this situation.

I tried some codes posted in other forums like:

<embed id="samplePDF" src="mypdf.pdf" type="application/pdf"></embed>
<script>
var pdf = document.getElementById('samplePDF');
pdf.print();
</script>

But sincerely it doesn't work for me at all, at least not in Firefox browser, I didn't test it for IE. Nope, I just try it and didn't work either, at least with IE8 in XP.

I will test this FPDF to see how it works a let you know about it!

Or my other workaround would be talking to Bizland to see if they run the command line for me...??? dream on!

Thanks for the suggestion, I will try it though in my local server at home.

raphie 3 Light Poster

Thanks for the advice, I will look into it... I might probably will have to see into JavaScript as you mentioned or I could use ajax to request a PHP loop to print an array created by the selection boxes. That just a crazy idea that hit me while reading your suggestion. What do you think?

For example, I could send the file list into an array hold in the values of the selection boxes. Then use a <pre>foreach()</pre> loop to print each file. Actually I don't need Ajax, I can submit the form then execute a print selection function in the application page. In the control panel then use JavaScript to let the customer preview a thumbnail of the file to be print.

I will try to look information for PDF handling function with JavaScript, when I get the code I publish it here as a thank you.

raphie 3 Light Poster

I would like to add an advanced print form into a customer web site. They have an online web form but they also want to have the form break apart into sections as PDF files so it's distributor print out only the sections they need. The full order form is about 15 pages, but sometimes distributors only use 2 to 4 pages to order.

My propose is to have a web-gadget with a list of all the pdf's with selection boxes, then the distributor check the box and press print and will automatically print just the selected documents.

I'm using PHP/Javascript. Is there any function to print an unopened document such as Word or PDF's files?

raphie 3 Light Poster

As stymiee said... CSS is the best option... example

@media print{
    #div_not_to_print{
        display:none;
    }

    #div_to_print{
        display:inline-block;
    }
}

If every element in your HTML has id or class declare not to print the desired id or class, so when they print the page only print the desire area only, even if JavaScript is turned off. It works with all the browser I used like IE, Safari, Firefox, Chrome, Opera and any Geiko Browser like Firefox.

raphie 3 Light Poster

if you create a form to submit with all the fields need it the code you need for php to communicate with the db and insert the info is...

Need to create a variable to enclosed the query... and set all the columns you want to insert data and use global variable populated by the form...Important!... the form method should be set to 'GET'

$insert_info_sql = "
INSERT INTO `table-name` SET `artist` = '".$_GET['artist']."';
";

Next is the php function to execute the query...

mysql_query($insert_info_sql) or die ('Error Message');

As you notice the mysql_query function enclosed in parenthesis the varible created.. that holds the query to be executed.

That's it... just remember to separate each column with a comma in the query...

Example:

SET `artist` = '".$_GET['artist']."', `lyrics` = '".$_GET['lyrics']."',

I would like to help you with this but I have to leave my office for a week and I don't think you can wait that long...

hopefully this help...

Sorry I forgot the HTML form code... is this one..

<?php
//enclose here the code I mentioned before
?>

<form method="get" name="lyric_submit" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<!-- for each column you will do the same as follow -->
<input name="artist" value="" />
<!-- for the text area for the lyrics -->
<textarea name="lyrics" cols="60" rows="25">
</textarea>
</form>

<!-- Just remember to match the name for the inputs and textareas with the globals $_GET[''] -->

I hope this works for you.