Results 1 to 6 of 6

Thread: Data from one table to another

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Data from one table to another

    Well just stumbled upon this forum after looking for soem information and thought you lot may be able to help

    Wel the scenario is:

    I'm a student for a university and currently doing my project (which is about complete) the project is marked on documentation rather then the program actually working xD but i would like to get it working for future referance.

    Now the program so far submits data from a php form to a SQL DB. This DB is called upon the admin page which i done in a loop to display it. Now the admin has to approve or deny each one of them and they get moved to another table depending on if it was approved or not.

    I.E

    User submits idea
    Idea goes to db table idea
    Admin sees idea on php page that calls the DB
    -
    Admin apporves/ denys idea
    idea gets deleted from idea table
    idea get moved to accepted/denied table (contains same fields)

    Now i was thinking this could be done by checkboxes some how or even buttons but not sure where to start.

    So can anyone point me in the correct direction

    Kind regards
    Mrmoomoo

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Data from one table to another

    an alternate way would be to have a boolean field called "approved" and if it is new (false) then it would be listed in the admin page. if it is approved (true) then it will show on the student page
    My usual boring signature: Something

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Data from one table to another

    dclamp is right. If you find yourself needing to move data from one table to another it would seem that your schema is badly designed.

    I suggest you study the principles of database normalisation as these are very valuable to know.

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Re: Data from one table to another

    @dclamp

    using a boolean field is a good way, the problem is when its displayed on the admin page how to you make the button / checkbox link to the query display. beneath is the way im displaying it.

    Code:
    <?php
    		include("dbinfo.inc.php");
    		
    		mysql_connect($host,$username,$password);
    		@mysql_select_db($db_name) or die( "Unable to select database");
    		$query="SELECT * FROM idea_sheet";
    		$result=mysql_query($query);
    
    		$num=mysql_numrows($result);
    
    		mysql_close();
    
    		echo "<b><center>Ideas Submitted</center></b><br><br>";
    
    		$i=0;
    		while ($i < $num) {
    
    		$name=mysql_result($result,$i,"name");
    		$idea=mysql_result($result,$i,"idea");
    		$date=mysql_result($result,$i,"date");
    
    		echo "<b>Name:</b> $name<br>
    		<b>idea:</b> $idea<br>
    		<b>Date:</b> $date<br><hr><br>";
    
    		$i++;
    		}
    
    		?>

    @penagate

    Can you point me in the direction of that but based upon what dc said i think i willredo it with the boolen field and then have a query that displays all true when a button etc is click.

  5. #5
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Data from one table to another

    You are going to want to have an array of checkboxes and when the form is submitted loop through the array for check boxes with the CHECKED property set to TRUE. In the loop, have it UPDATE the database.
    My usual boring signature: Something

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    3

    Re: Data from one table to another

    Thanks will have a play around with it this week see what else i can come up with

    Kind regards
    mrmoomoo

Posting Permissions

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



Click Here to Expand Forum to Full Width