Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    page edit user interface (php/MySQL)

    hello.

    i have the section on my site where each page (php) displays the content from a single cell on my DB as the body. i then wanted my admins to be able to edit the content in this table. rather than teaching them how to use MySQL i just thought i'd set up a page which stores and retrievs data. the code i wrote is as follows:

    Code:
    <?
    
    $DBHost="myhost";
    $DBUser="myuser";
    $DBPass="mypassword";
    $DBName="mydatabase";
    
    mysql_connect("$DBHost","$DBUser","$DBPass");
    mysql_select_db("$DBName");
    
    $query  = "SELECT * FROM pageSHOW WHERE num='123'";
    $result = mysql_query($query);
    
    while ($row  =  mysql_fetch_row($result)) {
    	$num = $row[0];
    	$Home = $row[1];
    	$Audition = $row[2];
    	$CallBacks = $row[3];
    	$Rehearsal = $row[4];
    	$MIDI = $row[5];
    	$MP3 = $row[6];
    	$Support = $row[7];
    }
    
    
    /////////////////Page Views//////////////////
    if ($page=="") {
    	echo "Select a page from above to edit.";
    } 
    
    if ($page=="home") {
    $editbox="home";
    
        echo "$Home";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=home'>
        <textarea name='$editbox' cols='75' rows='7'>$Home</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    if ($page=="requirements") {
    
    
    
        echo "$Audition";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=requirements'>
        <textarea name='$editbox' cols='75' rows='7'>$Audition</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    if ($page=="callbacks") {
    $editbox="callbacks";
    
    
    
        echo "$CallBacks";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=home'>
        <textarea name='$editbox' cols='75' rows='7'>$CallBacks</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    if ($page=="rehearsal") {
    $editbox="rehearsal";
    
    
    
        echo "$Rehearsal";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=rehearsal'>
        <textarea name='$editbox' cols='75' rows='7'>$Rehearsal</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    /////////////////Page Submits//////////////////
    
    if ($sub=="home") {
    
    
       $home = $_POST['Home'];
       
          $result=mysql_query("UPDATE pageSHOW SET Home='$editbox' WHERE num='123'");
    	  
    	echo "$Home";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=home'>
        <textarea name='$editbox' cols='75' rows='7'>$Home</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    if ($sub=="requirements") {
    
    
       $home = $_POST['Audition'];
       
          $result=mysql_query("UPDATE pageSHOW SET Audition='$editbox' WHERE num='123'");
    	  
    	echo "$Audition";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=requirements'>
        <textarea name='$editbox' cols='75' rows='7'>$Audition</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    if ($sub=="callbacks") {
    
    
       $home = $_POST['CallBacks'];
       
          $result=mysql_query("UPDATE pageSHOW SET CallBacks='$editbox' WHERE num='123'");
    	  
    	echo "<p align='center'>$CallBacks</p>";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=callbacks'>
        <textarea name='$editbox' cols='75' rows='7'>$CallBacks</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    if ($sub=="rehearsal") {
    
    
       $home = $_POST['Rehearsal'];
       
          $result=mysql_query("UPDATE pageSHOW SET Rehearsal='$editbox' WHERE num='123'");
    	  
    	echo "$Rehearsal";
    	echo "<br><hr><br>";
    	
    	echo "<p align='center'>
    	<form name='form1' method='post' action='?sub=rehearsal'>
        <textarea name='$editbox' cols='75' rows='7'>$Rehearsal</textarea>
    	<input type='submit' name='Submit' value='Save'>
    	</form></p>";
    
    } else {echo "";}
    
    ///////
    
    
    ?>
    after they select a link from the first page like <*a href="?page=home">Home<*/a>, they will be taken to the edit screen which shows the current value in html and then a textbox with the value in text. the form actions are listed also.

    the problem is that when i click save all the data gets erased and the cell is left blank. this is the most code i have ever written from scratch and i am having dificulty troubleshooting. thanks sooooo much for any help.

  • #2
    New Coder
    Join Date
    Mar 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry if this counts as spam, but i wouldn't want my problem to get lost.

    so....

    *BUMP*

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,147
    Thanks
    2
    Thanked 333 Times in 325 Posts
    So have you traced through this code to see what path it takes and at what point it does not work? Can you tell us the major steps it goes through so that we can know where to look for the problem?

    Have you echoed out variables (or echo out the query string) at the point they would be placed into the database to make sure they contain the expected content?

    The reason I ask so many questions is you are the author of the code and are familiar with it. No one here has seen this code before. Expecting someone in a Forum to take "when i click save all the data gets erased and the cell is left blank" and find the area causing this in 180+ lines of code is expecting more than what Forum based help can do for you.
    Last edited by CFMaBiSmAd; 12-04-2006 at 03:42 AM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by utinaeniduin View Post
    this is the most code i have ever written from scratch and i am having dificulty troubleshooting.
    thanks for the tip.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •