This series of the videos explains how to create Photo Gallery using PHP, MySQL, ImageMagic and jQuery. Using PHP you will be able to add, modify and populate data stored on the MySQL Database and display records of all images on the page. ImageMagic will help us to resize and crop images to the relevant dimentions, while jQuery will provide the support in the presentation of the gallery. The last two chapters are dedicated to adding the earlier created gallery to our Content Management System. Over 4 hours of videos!!!

Dreamweaver tutorials

 
  • Link Exchange System with Dreamweaver CS3
  • Edit Link Page

To create Edit Link page first open links_edit.php file from admin directory.
Go to the Code view and select the entire content by pressing Ctrl+A on your keyboard. Now hit Delete button to remove everything.

Now apply templates by going to Modify > Templates > Apply Template to Page from the Select Template window choose admin_temp and click Select. Save the file.

Go to the Code view and remove <p>Content Placeholder</p>.
Rename Title Placeholder to Edit Link and create a new line underneath (Fig. 111).

Rename paragraph
Fig. 111

Go to Design view and create a new recordset by pressing + sign in the Server Behaviors tab of the Application pane.
In the new window type the following:
Name rsLink
for Connection choose conndb
select All for Columns
for Filter choose linkid then =, URL Parameter and type id in the last field.
Leave Sort as None and click OK to create a recordset (Fig. 112).

Create recordset using Dreamweaver CS3
Fig. 112

We also need to create a recordset to populate all available categories from the database.
Click + button in Server Behaviours and choose Recordset again.
This time fill it in as follow (Fig. 113):
Name rsCategories
Connection conndb
Table tbl_categories
Columns All
Filter None
Sort catname, Ascending

Click OK and save file.

Record Update Form Wizard
Fig. 113

Ensure that your cursor is under the Edit Link paragraph and from the Data tab of the Insert panel choose Record Update Form Wizard (Fig. 114).

Record Update Form Wizard
Fig. 114

In the new window choose the following:
Connection: conndb
Table to update: tbl_links
Select record from: rsLink
Unique key column: linkid
check the Numeric checkbox
After updating, go to: browse for links_updated.php.

In the Form fields select linkid and press - button at the top to remove this entry (Fig. 115). This is because we will not be updating this field manually. As you may recall from the section in which we build our database, we have set up linkid as Auto Increment which means this field will automatically get it's value which will be one higher than the last one in the database.
Scroll down and do the same with linkdate.

Remove form fields in Dreamweaver CS3
Fig. 115

Now select linktitle and in the Label field type Link title: then press TAB (Fig. 116).

Form field rename
Fig. 116

Do the same with the rest by giving them the following names:
linkurl URL:
linkrecip Reciprocal:
linkemail Email:
for linkapproved type Approved?:. From the Display as: dropdown menu choose Menu and click Menu Properties button.
In the new window select Manually for Populate menu items, in the Label field type Yes and for Value type y. Then click + button at the top and type No for Label and n for Value (Fig. 117).

Populate menu items
Fig. 117

Click OK.

For linkcat type Category:, from the Display as dropdown menu choose Menu and click Menu Properties button (Fig. 118).

Drop down menu
Fig. 118

Select From database radio button and choose:
Recordset rsCategories
Get labels from catname
Get values from catid
Leave the last field as default and click OK (Fig. 119).

Setting up dropdown menu in Dreamweaver CS3
Fig. 119

For the last field linkdescr type Description: and from the Display as dropdown menu choose Text area (Fig. 120).

Record update form wizard in Dreamweaver CS3
Fig. 120

Now use the arrows in the top right corner to rearrange the order of the fields as follow:
Email
Category
Link title
URL
Reciprocal
Description
Approved? (Fig. 121)

Update record server behavior in Dreamweaver CS3
Fig. 121

Click OK to insert record update form.
Your page in Design view should now look like in Fig. 122.

Rearange fields
Fig. 122

Now we need to tidy up our table a little bit.
First place your cursor anywhere within the table and press the <table> tag selector in the bottom part of the window to select the entire table (Fig. 123).

Select table using tag selector
Fig. 123

With the table selected go to the Properties panel in the bottom part of the screen.
From the Table Id dropdown menu choose tblinsert, for Align choose Default and type 0 for CellPad, CellSpace and Border. Save the file (Fig. 124).

Table properties
Fig. 124

Select the Update record button and press Ctrl+T on your keyboard.
Move cursor after value="Update record" and type id="button" (Fig. 125).
Press Enter and save the file.

Table properties
Fig. 125

Place cursor in the first left cell in the top row and press Ctrl+T twice.
Replace td nowrap="nowrap" align="right" with th and press Enter twice.
Do the same with all cells in the left column (Fig. 126).

Convert table cell into table row
Fig. 126

Go to the Code view and identify the line which says <th>Email:</th>.
Place your cursor after the <th> tag and type <label for="linkemail">. Now move your cursor after Link title: and on your keyboard press Shift+< then / - this will automatically place a closing </label> tag (Fig. 127).

Apply label tag
Fig. 127

As you can see I have assigned the same value to the for attribute as the name of the input field to which this label is referring.
Now we just need to add id="linkemail" to the input field (Fig. 128).

Adding id to the input field
Fig. 128

Now do the same with the remaining cells - assigning the relevant for labels and id's to the input fields.
Once you have done this the only last thing we will need to do is to apply some validation to the form fields.
To do this identify the line which says:

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

Place your cursor at the end of this line and press Enter to create a new line.
Now type or copy and paste the following:

if ($_POST['linkcat'] == "" || $_POST['linktitle'] == "" || $_POST['linkurl'] == "" || $_POST['linkdescr'] == "") {

if ($_POST['linkcat'] == "") {
$mess = "<p>Please choose category</p>";
}
if ($_POST['linktitle'] == "") {
$mess .= "<p>Please provide link title</p>";
}
if ($_POST['linkurl'] == "") {
$mess .= "<p>Please provide link URL</p>";
}
if ($_POST['linkdescr'] == "") {
$mess .= "<p>Please provide description.</p>";
}

} else {

Identify the line which says:

header(sprintf("Location: %s", $updateGoTo));
}

and place a closing curly bracket at the end:

}

Scroll down to the line:

<table border="0" cellpadding="0" cellspacing="0" id="tblinsert">

Place your cursor at the end of this line and press Enter to create a new line.
Type <caption>Edit link</caption> and press Enter to create another new line.
Now type:

<?php if (isset($mess)) { ?>
<tr>
<td colspan="2" class="messagebox"><?php echo $mess; ?></td>
</tr>
<?php } ?>

What this code does is it checks if variable $mess exists (it will only exist if any of the form fields to which validation applies were missing content) and if so then it will display an extra table row with the error message informing which fields needs to be filled in.

Also what you might do is to open links_updated.php page, apply template to it and change:

<p id="ptitle">Title Placeholder</p>
<p>Content Placeholder</p>

to:

<p id="ptitle">Link updated</p>
<p>Your link has been successfully updated.<br />
<a href="links_list.php" id="listoflinks">Go back to the list of links</a>.</p>

Identify the line which reads:

<!-- InstanceBeginEditable name="head" -->

and right after this, on the new line type:

<script type="text/javascript">
<!--
onload=
function getFocus()
{
var toFocus = document.getElementById("listoflinks");
toFocus.focus();
}
//-->
</script>

Now it's time to test your page.
If everything works fine you can move to the next chapter where I will be expalining how to create an Add Link page.

<< Create Search Engine | Add Link Page >>

 
  • Thank you for subscribing to our newsletter.
  • To complete registration please click on the link in the email which has been sent to you.
  • Invalid first name
  • Invalid last name
  • Invalid email address

Website Design Company | Website Design Company Sussex | Website Design Company Chichester | Website Design Packages | Tutorials Resources | Articles | Contact
© Web Design Tutorials – Sebastian Sulinski