Jump to content

Help with Navigation


Unholy Prayer

Recommended Posts

Ok, I am trying to make my edit content page so you click on a looped link and the link takes you to a form where you can edit the table row for it.  I'm thinking it's my navigation page that isn't working.  I would greatly appreciate it if someone could help me.  Hint:  The code stops functioning the way I want it to towards the bottom at the if statement to start the edit page.  Here's my code:

<?php

require_once('config.php');

echo "<link rel=stylesheet href='style.css'>";

   echo "<table align='center' cellspacing='1' cellpadding='1' border='0'>
           <tr>
          <td align='center' colspan='4'>Ultimate Affiliates Manager v1.0 Administration Center</td>
           </tr><tr>
          <td class='button'><a href='admin.php?act=add'>Add</a></td>
          <td class='button'><a href='admin.php?act=edit'>Edit</a></td>
          <td class='button'><a href='admin.php?act=delete'>Delete</a></td>
          <td class='button'><a href='admin.php?act=view'>View</a></td>
           </tr><tr>
          <td align='center' colspan='4'><a href='admin.php'>Admin Index</a></td>
            </tr><tr>";

//What page should we be viewing?

$act = $_GET["act"];

//If the action is blank...
if($act == "")

{

  echo "<td colspan='4'><p align='center'><b>Welcome</b></p></td>
          </tr><tr>
        <td colspan='4' class='content' width='50%'>Welcome to the administration center of the Ultimate Affiliates Manager v1.0.  
From this area you can manage all of your affiliates.  You can add new sites, delete sites, or modify existing sites.  You can 
even view your existing affiliates.  Just use the navigation area at the top of your screen to work your way around the admin panel.</td>";

}

//If the action is "add"...
if($act == "add")

{

//If the form was submitted...
if($_POST['Submit'])
{

//Shorten up the variables to insert the information.
    $site_name = $_POST['site_name'];
    $description = $_POST['description'];
    $site_url = $_POST['site_url'];
    $banner_url = $_POST['banner_url'];

//Our handy database insertion code
    mysql_query("INSERT INTO affiliates (site_name,description,
         site_url,banner_url)
       values('$site_name', '$description', '$site_url', '$banner_url')");

    echo "<p align='center'>The site has been added to your affiliates.<br>Click <a href='add.php'>here</a> to return to the Add Affiliates page.</p>";

   }

   //If the form was not submitted...
   elseif(empty ($_POST['Submit']))

          {
   //Display our form.
   echo "<table align='center' cellspacing='1' cellpadding='1' border='0'>
       <tr>
          <td align='center' colspan='2'><p align='center'><b>Add an Affiliate<b></p></td>
       </tr><tr>
             <form action='add.php' method='POST'>
          <td align='right'>Site Name:</td>
          <td align='left'><input type='text' name='site_name' size='30'></td>
       </tr><tr>
          <td align='right'>Description:</td>
          <td align='left'><input type='text' name='description' size='30'></td>
       </tr><tr>
          <td align='right'>Site URL:<br><small>Must include http:// at the beginning.</small></td>
          <td align='left'><input type='text' name='site_url' size='30'></td>
       </tr><tr>
          <td align='right'>Banner URL:<br><small>Must include http:// at the beginning.</small></td>
          <td align='left'><input type='text' name='banner_url' size='30'></td>
       </tr><tr>
          <td align='center' colspan='2'><input type='submit' value='Submit' name='Submit'></td>
             </form>
       </tr>
          </table>";

          }
       }
  $aid = $_GET["id"];

if($act == "edit")

{
   $affiliates = mysql_query("SELECT * FROM affiliates");

   while($a=mysql_fetch_array($affiliates))
  
    {

       $id=$a["id"];
       $affiliate_name=$a["site_name"];
       $description=$a["description"];
       $site_url=$a["site_url"];
       $banner_url=$a["banner_url"];


       echo "<td align='center' colspan='4'><a href='$site_url' target='new'>$affiliate_name<br><img src='$banner_url'></a><a href='admin.php?act=edit&id=$id'>[X]</a></td>
               </tr><tr>";
  }

   if($aid == "$id")
  
       {

          $display = mysql_query("SELECT * FROM affiliates WHERE id = $aid");

            while($d=mysql_fetch_array($display))

              {

                 $affiliate_name2=$d["site_name"];
                 $description2=$d["description"];
                 $site_url2=$d["site_url"];
                 $banner_url2=$d["banner_url"];
           
              }

   if($_POST['Edit Affiliate'])

     {

          $affiliate_name3 = $_POST["site_name"];
          $description3 = $_POST["descriptoin"];
          $site_url3 = $_POST["site_url"];
          $banner_url3 = $_POST["banner_url"];

          mysql_query("UPDATE affiliates WHERE id = $aid(site_name,description,site_url,banner_url)
            values('$affiliate_name3', '$description3', '$site_url3', '$banner_url3')");

          echo "<td align='center' class='content'>The affiliate has been updated.</td>";

         }

    elseif(empty ($_POST['Edit Affiliate']))

       {
            
        echo "<table align='center' cellspacing='1' cellpadding='1' border='0' width='50%'>
                <tr>
                      <form action='admin.php?act=edit' method='POST'>
                   <td align='center' colspan='2'>Edit $affiliate_name2</td>
                </tr><tr>
                   <td align='right'>Site Name:</td>
                   <td align='left'><input type='text' name='site_name' value='$affiliate_name2' size='30'></td>
                </tr><tr>
                   <td align='right'>Description:</td>
                   <td align='left'><input type='text' name='description' value='$description2' size='30'></td>
                </tr><tr>
                   <td align='right'>Site URL:<br><small>Must begin with http://</small></td>
                   <td align='left'><input type='text' name='site_url' value='$site_url2' size='30'></td>
                </tr><tr>
                   <td align='right'>Banner URL:<br><small>Must begin with http://</small></td>
                   <td align='left'><input type='text' name='banner_url' value='$banner_url2' size='30'></td>
                </tr><tr>
                   <td align='center' colspan='2'><input type='submit' name='Edit Affiliate'></td>
                </tr>
              </table></form>";
     
          }

       }
           
       
}
?>
  

 

 

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.