Solved

PHP mySQL rollup problem

Posted on 2004-03-31
4
430 Views
Last Modified: 2012-08-13
Ok I have a problem that I cant seem to wrap my head around.  I have a page http://www.generalstorecafe.com/band_next_month.php that needs to be a little different.  Im not sure even how to approach the problem.  They want to be able to always show the current info.  i thought about setting up the page to display the top 15 rows in the db.  Problem with that is how would you setup the input page so that they could make changes after updateing the page.  this is the update page I use now:  ANy thoughts on how this can be accomplished?  It has to be simple for the client.  I was thinking about having  seperate pages for this week/this month/next month then find a command that will copy the data from tableA to tableB.  That way they would at least only have to enter data once.  At the end of the month they just use the copy function and then add new info to the current month.

Ok lets here some feed back ;-)
This is probably going to be a long thread with double points  

<?
include("../db.php"); // setup connection to mysql
if($_POST["submit"]) { // if form submitted
  $query = "UPDATE band2 SET
month = '" . $_POST["month"] . "',
date1 = '" . $_POST["date1"] . "',
date2 = '" . $_POST["date2"] . "',
date3 = '" . $_POST["date3"] . "',
date4 = '" . $_POST["date4"] . "',
date5 = '" . $_POST["date5"] . "',
date6 = '" . $_POST["date6"] . "',
date7 = '" . $_POST["date7"] . "',
date8 = '" . $_POST["date8"] . "',
date9 = '" . $_POST["date9"] . "',
date10 = '" . $_POST["date10"] . "',
date11 = '" . $_POST["date11"] . "',
date12 = '" . $_POST["date12"] . "',
date13 = '" . $_POST["date13"] . "',
date14 = '" . $_POST["date14"] . "',
date15 = '" . $_POST["date15"] . "',
date16 = '" . $_POST["date16"] . "',
date17 = '" . $_POST["date17"] . "',
date18 = '" . $_POST["date18"] . "',
date19 = '" . $_POST["date19"] . "',
date20 = '" . $_POST["date20"] . "',
image1 = '" . $_POST["image1"] . "',
image2 = '" . $_POST["image2"] . "',
image3 = '" . $_POST["image3"] . "',
image4 = '" . $_POST["image4"] . "',
image5 = '" . $_POST["image5"] . "',
image6 = '" . $_POST["image6"] . "',
image7 = '" . $_POST["image7"] . "',
image8 = '" . $_POST["image8"] . "',
image9 = '" . $_POST["image9"] . "',
image10 = '" . $_POST["image10"] . "',
image11 = '" . $_POST["image11"] . "',
image12 = '" . $_POST["image12"] . "',
image13 = '" . $_POST["image13"] . "',
image14 = '" . $_POST["image14"] . "',
image15 = '" . $_POST["image15"] . "',
image16 = '" . $_POST["image16"] . "',
image17 = '" . $_POST["image17"] . "',
image18 = '" . $_POST["image18"] . "',
image19 = '" . $_POST["image19"] . "',
image20 = '" . $_POST["image20"] . "',
band1 = '" . $_POST["band1"] . "',
band2 = '" . $_POST["band2"] . "',
band3 = '" . $_POST["band3"] . "',
band4 = '" . $_POST["band4"] . "',
band5 = '" . $_POST["band5"] . "',
band6 = '" . $_POST["band6"] . "',
band7 = '" . $_POST["band7"] . "',
band8 = '" . $_POST["band8"] . "',
band9 = '" . $_POST["band9"] . "',
band10 = '" . $_POST["band10"] . "',
band11 = '" . $_POST["band11"] . "',
band12 = '" . $_POST["band12"] . "',
band13 = '" . $_POST["band13"] . "',
band14 = '" . $_POST["band14"] . "',
band15 = '" . $_POST["band15"] . "',
band16 = '" . $_POST["band16"] . "',
band17 = '" . $_POST["band17"] . "',
band18 = '" . $_POST["band18"] . "',
band19 = '" . $_POST["band19"] . "',
band20 = '" . $_POST["band20"] . "',
link1 = '" . $_POST["link1"] . "',
link2 = '" . $_POST["link2"] . "',
link3 = '" . $_POST["link3"] . "',
link4 = '" . $_POST["link4"] . "',
link5 = '" . $_POST["link5"] . "',
link6 = '" . $_POST["link6"] . "',
link7 = '" . $_POST["link7"] . "',
link8 = '" . $_POST["link8"] . "',
link9 = '" . $_POST["link9"] . "',
link10 = '" . $_POST["link10"] . "',
link11 = '" . $_POST["link11"] . "',
link12 = '" . $_POST["link12"] . "',
link13 = '" . $_POST["link13"] . "',
link14 = '" . $_POST["link14"] . "',
link15 = '" . $_POST["link15"] . "',
link16 = '" . $_POST["link16"] . "',
link17 = '" . $_POST["link17"] . "',
link18 = '" . $_POST["link18"] . "',
link19 = '" . $_POST["link19"] . "',
link20 = '" . $_POST["link20"] . "',
desc1 = '" . $_POST["desc1"] . "',
desc2 = '" . $_POST["desc2"] . "',
desc3 = '" . $_POST["desc3"] . "',
desc4 = '" . $_POST["desc4"] . "',
desc5 = '" . $_POST["desc5"] . "',
desc6 = '" . $_POST["desc6"] . "',
desc7 = '" . $_POST["desc7"] . "',
desc8 = '" . $_POST["desc8"] . "',
desc9 = '" . $_POST["desc9"] . "',
desc10 = '" . $_POST["desc10"] . "',
desc11 = '" . $_POST["desc11"] . "',
desc12 = '" . $_POST["desc12"] . "',
desc13 = '" . $_POST["desc13"] . "',
desc14 = '" . $_POST["desc14"] . "',
desc15 = '" . $_POST["desc15"] . "',
desc16 = '" . $_POST["desc16"] . "',
desc17 = '" . $_POST["desc17"] . "',
desc18 = '" . $_POST["desc18"] . "',
desc19 = '" . $_POST["desc19"] . "',
desc20 = '" . $_POST["desc20"] . "'";

 // update your field in your table
  $result = mysql_query($query) or die(mysql_error()); // exec query
  print "Bands of the Month updated";
}
$q = "SELECT * FROM band2 LIMIT 1"; // get the current entry
$r = mysql_query($q) or die(mysql_error()); // exec
$row = mysql_fetch_assoc($r); // fetch the row

?>
<html>
<head>
 <script language="JavaScript">
function popUp(URL) {
n=window.open(URL, 'popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=360,height=520');
n.focus();
if(!n.closed) n.focus();
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>General Store Cafe Next MOnths Band Listing Update Page</title></head>
<body>
<table width="765" border="15" align="center" bordercolor="#339933">
  <tr>
<td>

<div align="center">
        <p><font color="#FF00FF" size="4" face="Papyrus"><strong>Bands of the
          Month Update Page:</strong></font></p>
        <p><strong><font color="#FF00FF" size="4" face="Papyrus">This Month</font></strong></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">Click the Update
          button 1 time after filling in the blanks. If a field is left blank
          nothing will show up in that spot on the Bands Page. This will not cause
          the program to fail!! It will just leave a blank space on the page.</font><br>
        </p>
      </div>

<form action="<? print $_SERVER["../PHP_SELF"]; ?>" method="POST">
        <p>
          <input type="text" name="month" value="<? print $row["month"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Month<a href="JavaScript:popUp('band_pop_month.htm');">?Help?</a></font></p>
        <hr>
        <p>
          <input type="text" name="date1" value="<? print $row["date1"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date <a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image1" value="<? print $row["image1"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link1" type="text" id="link1" value="<? print $row["link1"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band1" value="<? print $row["band1"]; ?>">
          Band Name</font></p>
                     
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc1" cols="75" rows="5"><? print $row["desc1"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date2" value="<? print $row["date2"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image2" value="<? print $row["image2"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link2" type="text" id="link2" value="<? print $row["link2"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band2" value="<? print $row["band2"]; ?>">
          Band</font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc2" cols="75" rows="5"><? print $row["desc2"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date3" value="<? print $row["date3"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image3" value="<? print $row["image3"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link3" type="text" id="link3" value="<? print $row["link3"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band3" value="<? print $row["band3"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc3" cols="75" rows="5"><? print $row["desc3"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date4" value="<? print $row["date4"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date <a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image4" value="<? print $row["image4"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link4" type="text" value="<? print $row["link4"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band4" value="<? print $row["band4"]; ?>">
          Band Name</font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc4" cols="75" rows="5"><? print $row["desc4"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date5" value="<? print $row["date5"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image5" value="<? print $row["image5"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link5" type="text" value="<? print $row["link5"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band5" value="<? print $row["band5"]; ?>">
          Band</font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc5" cols="75" rows="5"><? print $row["desc5"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date6" value="<? print $row["date6"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image6" value="<? print $row["image6"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link6" type="text" value="<? print $row["link6"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band6" value="<? print $row["band6"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc6" cols="75" rows="5"><? print $row["desc6"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date7" value="<? print $row["date7"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date </font><font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image7" value="<? print $row["image7"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link7" type="text" value="<? print $row["link7"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band7" value="<? print $row["band7"]; ?>">
          Band Name</font></p>
                     
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc7" cols="75" rows="5"><? print $row["desc7"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date8" value="<? print $row["date8"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image8" value="<? print $row["image8"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link8" type="text" value="<? print $row["link8"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band8" value="<? print $row["band8"]; ?>">
          Band</font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc8" cols="75" rows="5"><? print $row["desc8"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date9" value="<? print $row["date9"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image9" value="<? print $row["image9"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link9" type="text" value="<? print $row["link9"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band9" value="<? print $row["band9"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc9" cols="75" rows="5"><? print $row["desc9"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date10" value="<? print $row["date10"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date <a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image10" value="<? print $row["image10"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link10" type="text" value="<? print $row["link10"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band10" value="<? print $row["band10"]; ?>">
          Band Name</font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc10" cols="75" rows="5"><? print $row["desc10"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date11" value="<? print $row["date11"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image11" value="<? print $row["image11"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link11" type="text" value="<? print $row["link11"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band11" value="<? print $row["band11"]; ?>">
          Band</font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc11" cols="75" rows="5"><? print $row["desc11"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date12" value="<? print $row["date12"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image12" value="<? print $row["image12"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link12" type="text" value="<? print $row["link12"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band12" value="<? print $row["band12"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc12" cols="75" rows="5"><? print $row["desc12"]; ?></textarea>
          Description </font></p>
        <p>
          <input type="text" name="date13" value="<? print $row["date13"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date </font><font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image13" value="<? print $row["image13"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link13" type="text" value="<? print $row["link13"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band13" value="<? print $row["band13"]; ?>">
          Band Name</font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc13" cols="75" rows="5"><? print $row["desc13"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date14" value="<? print $row["date14"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image14" value="<? print $row["image14"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link14" type="text" value="<? print $row["link14"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band14" value="<? print $row["band14"]; ?>">
          Band</font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc14" cols="75" rows="5"><? print $row["desc14"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date15" value="<? print $row["date15"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image15" value="<? print $row["image15"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link15" type="text" value="<? print $row["link15"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band15" value="<? print $row["band15"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc15" cols="75" rows="5"><? print $row["desc15"]; ?></textarea>
          Description </font></p>

        <hr>
        <p>
          <input type="text" name="date16" value="<? print $row["date16"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image16" value="<? print $row["image16"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link16" type="text" value="<? print $row["link16"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band16" value="<? print $row["band16"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc16" cols="75" rows="5"><? print $row["desc16"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date17" value="<? print $row["date17"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image17" value="<? print $row["image17"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link17" type="text" value="<? print $row["link17"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band17" value="<? print $row["band17"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc17" cols="75" rows="5"><? print $row["desc17"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date18" value="<? print $row["date18"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image18" value="<? print $row["image18"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link18" type="text" value="<? print $row["link18"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band18" value="<? print $row["band18"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc18" cols="75" rows="5"><? print $row["desc18"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date19" value="<? print $row["date19"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image19" value="<? print $row["image19"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link19" type="text" value="<? print $row["link19"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band19" value="<? print $row["band19"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc19" cols="75" rows="5"><? print $row["desc19"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>
          <input type="text" name="date20" value="<? print $row["date20"]; ?>">
          <font face="Geneva, Arial, Helvetica, sans-serif">Date</font> <font face="Geneva, Arial, Helvetica, sans-serif"><a href="JavaScript:popUp('band_pop_date.htm');">?Help?</a></font>
        </p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="image20" value="<? print $row["image20"]; ?>">
          Image URL <a href="JavaScript:popUp('band_image_pop.htm');">?Help?</a></font></p>
        <p><font face="Geneva, Arial, Helvetica, sans-serif">
          <input name="link20" type="text" value="<? print $row["link20"]; ?>">
          Link <a href ="JavaScript:popUp('band_pop_link.htm');">?Here?</a></font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <input type="text" name="band20" value="<? print $row["band20"]; ?>">
          Band </font></p>
        <p> <font face="Geneva, Arial, Helvetica, sans-serif">
          <textarea name="desc20" cols="75" rows="5"><? print $row["desc20"]; ?></textarea>
          Description </font></p>
        <hr>
        <p>&nbsp;</p>
        <p> </p>
        <p>&nbsp;</p>
        <p> <br />
          <input type="submit" name="submit" value="Update Bands of This Month">
          <input type="hidden" name="submit" value="Update Special Menu">
        </p>
        <p align="center"><a href="input_band_current.php">Band Current Week</a>
          <a href="input_band_next_month.php">Band Current Month</a> <a href="input_featured_art.php">Art</a>
          <a href="input_consignment.php">Consignment</a> <a href="input_special_menu.php">Specials</a>
          <a href="input_links.php">Links</a> <a href="input_specialevents.php">Special
          Events</a> <a href="input_fundraiser.php">Fundraisers</a></p>
  </form>
  </td></tr>
</table>
</body>
</html>
0
Comment
Question by:livegirllove
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
rlawley earned 250 total points
Comment Utility
I think you're going down the wrong track here.  You seem to have a table with a single row with loads of stuff in it - probably not the best idea.  You should start with a table which will have a single row for each event, e.g.

CREATE TABLE events (
    eventid int ID NOT NULL auto_increment PRIMARY KEY,
    eventdate date NOT NULL,
    starttime time,
    endtime time,
    title varchar(100) NOT NULL,
    description text,
    image varchar(100)
);

NB: Syntax not checked so maybe slight errors around!

You then need a set of pages - a display page which everyone sees, an editing index page which just the people who edit the page see, and an edit page for a single event.

The display page will basically show a subset of the events from the database.  You could populate this using a query such as
SELECT * FROM events WHERE eventdate BETWEEN '2004-04-01' AND -'2004-04-30'

The editing index page would probably just be a grid showing the date, times and title, with a link for edit and delete.  Delete removes the row (DELETE FROM events WHERE eventid = ...), and Edit will be a link to editevent.php?eventid=...

The editevent page would then be a single form with fields for title, date, start & end time, title, description and image.  It gets an eventid passed in, which is uses to populate the form.  If nothing was passed in, you could use it to add an event.

I think this way is nice and simple to use - I've used it myself to write a calendar for a website (http://www.wessexmotorclub.co.uk/calendar/).  What you see there is the display page, showing the next 6 month's worth of events.  If you're an admin you also see links to modify and delete events, which take you to a form for editing a single event.
0
 
LVL 1

Author Comment

by:livegirllove
Comment Utility
Can you show me what the admin page would look like?  Maybe a screen shot?  I think you may be onto something here.  Ill have more questions, then.  
0
 
LVL 26

Assisted Solution

by:skullnobrains
skullnobrains earned 250 total points
Comment Utility
$table="SET THE TABLE PLEASE";
$id_name="SET THE NAME OF THE FIELD WHICH CONTAINS THE PKVAL ( \"i'll use id_$table\" ) ";

$POST=$_POST;unset($POST['exe']);unset($POST['id']);$id=$_POST[id];$exe=$_POST['exe'];
switch ($exe):
case'':break;

//EXECUTION - INSERT
case 'insert':
if(!mysql_query("insert into $table '".implode("','",array_keys($POST))."' values '".implode("','",$POST)."'")
echo "unable to perform insertion<br>$req<br>".mysql_error();
else {$id=last_insert_id();$exe="update";
        echo"successfull insertion of new line id='$id'<br><pre>";print_r($POST);echo"</pre>";}
break;

//EXECUTION - UPDATE
case 'update':foreach($POST as $field=>$val)$req.=",$field='$val'";
if(!$id or !mysql_query("update $table set (".substr($req,1).") where PRIMARY_KEY='$id'"))
echo "unable to update for id '$id' (or id not present)";
else "update ok";
break;

//EXECUTION - DELETE
case"delete":
if($id and mysql_query("delete from $table where id='$id'") and mysql_affected_rows()==1){
echo "deletion of id '$id' OK";break;}
echo "deletion not done<br>id -> '$id' not present or already deleted, maybe checj the call to affected rows i'm not sure it will work properly in this context";$exe='insert';
break;
endswitch;

//JUST IN CASE
if($id)$exe='update';else $exe='insert';

//BEGIN FORM + BROWSING THROUGH
echo "GO <select name=\"$id_name\" onClick=\"javascript:submit();\">;
if($res=mysql_query("select $id_name from $table where 1")
while($line=mysql_fetch_row($res)){echo"<option";if($line[0]==$id)echo" selected";echo">$line[0]";}
echo"</select> - ";

//GET THE REST OF THE FORM + VALUES IF UPDATE MODE
if(($id and print("update mode <a href=\"$PHP_SELF?exe=delete&id=$id\">delete</a><br>") and $res=mysql_query("select * from $table where 1"))
or(!$id and print("insert mode<br>") and $res=mysql_query("select * from $table where 1 limit (0,1))
and mysql_num_rows()==1 and $line=mysql_fetch_array($res))
die("cannot read the table");
if($id and $line[$id_name]!=$id)die("something definitely wrong with the id in the previous if");
unset($line[$id_name]);
echo"<table>";
foreach($line as $var=>$val){echo"<tr><td>$var<td><input type=\"text\" name=\"$var\"";
                                           if($id)echo" value=\"$val\";echo">";}
echo"</table>";

//END OF FORM AND SUMBIT BTN
echo"<tr><td colspan=\"2\"><input type=\"submit\" value=\"$exe\"></form>";

wrote this in the box so u must check for commas and parenthesis but the idea will definitely be here assuming that u use a database with one line per event and whatever number and types of field, and of course that u set the two variables at the beginning (i recomend that the id field be auto-increment)
0
 
LVL 26

Expert Comment

by:skullnobrains
Comment Utility
euh, u had better copy-paste the code in some editor that will let u see the difference between a double-quote and two quotes to get it right. sorry i didn't know the output would be like that
my code must contain some bugs but they'll be quite easy to fix, assuming that u use mysql_error() to bebug querys
-- actually i just saw the parenthesis were missing in the insert query, should be (remove the Xs)
if(!mysql_query("insert into $table '".implode("','",array_keys($POST))."' values X(X'".implode("','",$POST)."'X)X")
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now