Jump to content

Populating a text area


Chubichan

Recommended Posts

Am I doing this correctly? I am using a cms to update a client's web site. I want the database to populate the cms text boxes so that I can quickly see and update the website content quickly and easily. The client will also be using this cms to do so herself. From what I have researched on the internet this is supposedly the correct way to accomplish this. Please anyone take a look and help me if you can. The text boxes are still blank and there is data in the database that it should be pulling into the textareas.

 

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dr. Michael D. Doyle | Payment Information</title>

<LINK REL=StyleSheet HREF="content_management.css" TYPE="text/css" />

</head>

<body>

<div id="container">

    <h3>Michael D. Doyle Content Management System</h3>
        
        <div id="form_wrapper">         
                <form method="post" action="put.php">
                <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div>
                <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div>
                <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div>
                <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div>
                <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div>
                <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div>
                <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div>
                <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div>          
                <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div>
                </form>            
        </div>
</div>
</body>
</html>

Link to comment
Share on other sites

An example of what? Where is your code for defining the variables such as $home? I have no clue as to your datasse structure or design. Assuming these values are contained within a table with a single record (each column in the table represents a different value above). And, I will assume that the column (field) names in the table are exactly the same as the variable names above.

 

<?php

//Connect to the database server
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

//Select the database
mysql_select_db("my_db", $link) or die('Could not connect to db: ' . mysql_error());

//Query the database
$query = "SELECT * FROM `table'";
$result = mysql_query($query) or die('Error running query: ' . mysql_error());

//Get the results
$record = mysql_fetch_assoc($result);
//Puts the result values into variables with same names as the field names
ectract($record);

?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dr. Michael D. Doyle | Payment Information</title>

<link rel="stylesheet" href="content_management.css" TYPE="text/css" />

</head>

<body>

<div id="container">

    <h3>Michael D. Doyle Content Management System</h3>
        
        <div id="form_wrapper">         
                <form method="post" action="put.php">
                <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div>
                <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div>
                <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div>
                <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div>
                <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div>
                <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div>
                <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div>
                <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div>          
                <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div>
                </form>            
        </div>
</div>
</body>
</html>

Link to comment
Share on other sites

An example of what? Where is your code for defining the variables such as $home? I have no clue as to your datasse structure or design. Assuming these values are contained within a table with a single record (each column in the table represents a different value above). And, I will assume that the column (field) names in the table are exactly the same as the variable names above.

 

<?php

//Connect to the database server
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

//Select the database
mysql_select_db("my_db", $link) or die('Could not connect to db: ' . mysql_error());

//Query the database
$query = "SELECT * FROM `table'";
$result = mysql_query($query) or die('Error running query: ' . mysql_error());

//Get the results
$record = mysql_fetch_assoc($result);
//Puts the result values into variables with same names as the field names
ectract($record);

?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dr. Michael D. Doyle | Payment Information</title>

<link rel="stylesheet" href="content_management.css" TYPE="text/css" />

</head>

<body>

<div id="container">

    <h3>Michael D. Doyle Content Management System</h3>
        
        <div id="form_wrapper">         
                <form method="post" action="put.php">
                <div><label for="index">Homepage</label><textarea name="home" rows="15" cols="70" ><?php echo $home ?> </textarea></div>
                <div><label for="mot">Meet Our Team</label><textarea name="mot" rows="15" cols="70" ><?php echo $mot ?> </textarea></div>
                <div><label for="pf">Patient Forms</label><textarea name="pf" rows="15" cols="70" ><?php echo $pf ?> </textarea></div>
                <div><label for="fi">Financial Information</label><textarea name="fi" rows="15" cols="70" ><?php echo $fi ?> </textarea></div>
                <div><label for="loc">Locations</label><textarea name="loc" rows="15" cols="70" ><?php echo $loc ?> </textarea></div>
                <div><label for="con">Contact</label><textarea name="con" rows="15" cols="70"><?php echo $con ?> </textarea></div>
                <div><label for="ms">Mission Statement</label><textarea name="ms" rows="15" cols="70" ><?php echo $ms ?> </textarea></div>
                <div><label for="dis">Disclaimer</label><textarea name="dis" rows="15" cols="70" ><?php echo $dis ?> </textarea></div>          
                <div class="actions"><input type="submit" name="submit" value="Submit Content" class="submit"/></div>
                </form>            
        </div>
</div>
</body>
</html>

 

Thanks for the help, like I said I am building my first cms. I am just going by books I have purchased and tutorials at the moment.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.