Jump to content


Photo

Simple question about double quotes


  • Please log in to reply
3 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 17 October 2006 - 12:00 PM

Hi guys, hope you are doing well,
here is my simple query, but I want to add some mouse over on "<TR>" and could not figure out how to add double quotes to it:

echo "<table width='500' border='1' cellspacing='0' cellpadding='0'>"; 
while($row = mysql_fetch_array($sql)){ 
	echo "<tr bgcolor="#ffffff" onmouseover="this.style.backgroundColor='#f2f2f2';" onmouseout="this.style.backgroundColor='#ffffff';">";
	echo "<td>".$row['data']."</td>";
	echo "</tr>";
}
echo "</table>";


Thanks for reading and helping me  :)
George
I don't need your script, I'll try to write it myself

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 October 2006 - 12:02 PM

echo "<tr bgcolor=\"#ffffff\" onmouseover=\"this.style.backgroundColor='#f2f2f2';\" onmouseout=\"this.style.backgroundColor='#ffffff';\">";


#3 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 17 October 2006 - 12:05 PM

Thanks thorpe ;)
I don't understand how it works, so I'll go to read some manual on php.net

Regards,
George
I don't need your script, I'll try to write it myself

#4 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 17 October 2006 - 12:45 PM

I don't understand how it works, so I'll go to read some manual on php.net


george, basically, just remember that when you're within double quotes, if you don't want to end the string, you need to escape your double quotes with a backslash:
<?php
// wrong way:
$String = "I said, "Hi, how are you?"";

// right way:
$String = "I said, \"Hi, how are you?\"";
?>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users