Inserting class into database through PHP
<!DOCTYPE>
<html>
<head>
<meta charset=utf-8" />
<title> data input form </title>
<link rel="stylesheet" type="text/css" href="css/form.css"/>
</head>
<body>
<h1> Insert data here</h1>
<form method="get" action="insert-data.php">
<input type="hidden" name="submitted" value="true" />
<fieldset>
<ul>
<li><label> English Word <input type="text"
name="englishWord"/>
</label></li>
<li><label> Beginner German <input type="text"
name="beginnerGerman"/> </label></li>
</ul>
<input type="submit" value="add new record" />
</fieldset>
</form>
<? php
echo $newrecord;
?>
</body>
</html>
<?php
//connect to database
$host = "localhost";
$username = "root";
$password = "mypass";
$database = "dictionary";
$table = "engdic";
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$englishWord = $_GET['englishWord'];
$beginnerGerman=$_GET['beginnerGerman'];
$mysql = "INSERT INTO $table (englishWord,beginnerGerman) VALUES
('$englishWord','<div class='beginner_german'>$beginnerGerman</div>')";
if(!mysql_query($mysql))
die(mysql_error());
echo "data inserted";
mysql_close();
?>
//INSIDE DATABASE
<div class=`beginner_german`>Beginner German Word</div>
So I will have input form where user will add translation words in to
database, when user will add lets say word Apple, it will also add div
with css class to database.So that way when another user will search for
word Apple I can style it with css class. my problem is when I am trying
to add div with class="beginner_german" I am geting error in php, when I
am using clas='beginner_german' it inserts in database fine but when I
cant call the css class, because syntax must be class="beginner_german".
So what is the solution. Thank you for your time.
No comments:
Post a Comment