Jump to content

Help!


harkly

Recommended Posts

I have 2 tables - images & movements, they are connected with the medID field. I have an update page so I can add info to the image table. (question)What I would like is to be able to do is pull the medID info from movements and update the same field for the images table. Can anyone help me with that?

 

   echo "<tr><td colspan=2><h5>Movement --</td></tr><tr><td><input type='text' name='movid' value='$movid'></td></tr>\n";

 

      <br><br><br><h5>Movement Choices<br><br>
<?php
    $result = mysql_query("SELECT * FROM movement order by movName") or die(mysql_error());
    $num_rows=mysql_num_rows($result);
      if ($num_rows != "0")
        {
                echo "<form method='post' action='updateArtist.php'>";
                echo "<select name='movement'>";
            while ($r=mysql_fetch_array($result))
              {	
                $movName=$r["movName"];
                echo "<option value='$movid_1' selected>$movName</option>";
              }
                echo "</select>";
                echo "<input type='hidden'>";
                echo "</form>";
        }
?>

Link to comment
Share on other sites

I probably didn't do a very good job in my explanation. Basically what I want to do is display information from my movement table in my imageUpdate form and then have that field update in my images table. Can anyone send me in a good direction?

 

images

imgID (primary)

name

movid

 

movements

movid (primary)

name

 

I have a form that makes updates to the images table, this is working fine. What I want to do is to be able to have a drop down box for the movID, pulling that info from the movements table and updating into the mov_# fields in the images table.

 

Right now I have the form on one side and the drop downs on the other side of the web page so I don't have to toggle back & forth.

 

Code:

 

<?php
session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
     <link href="stylesheet.css" rel="stylesheet" type="text/css">
     <link rel="stylesheet" media="print" type="text/css" href="../print.css" />
<title>The Art Database - Admin Console</title>
</head>

<body>

<?php
   include("../library/login.php");
   login();
?>

<table width="900" border="0" cellpadding="2" cellspacing="0" align="center">
  <tr>
    <td align=center colspan=6><h3>The Backend</h3></td></tr>
  <tr>
    <td align=center colspan=6><h3><img src=../image/smLine.gif></h3></td></tr>
  <tr>
    <td id="nav" width="600" valign="top" colspan=5><?php include('adminnav.inc.php'); ?></td><td id="status" width="300" valign="top" rowspan=4><?php include('adminstatus.inc.php'); ?>

      <br><br><br><h5>Movement Choices<br><br>
<?php
    $result = mysql_query("SELECT * FROM movement order by movName") or die(mysql_error());
    $num_rows=mysql_num_rows($result);
      if ($num_rows != "0")
        {
                echo "<form method='post' action='updateArtist.php'>";
                echo "<select name='movement'>";
            while ($r=mysql_fetch_array($result))
              { 
                $movid=$r["movid"];
                $movName=$r["movName"];
                echo "<option value='$movid_1' selected>$movName - $movid</option>";
              }
                echo "</select>";
                echo "<input type='hidden'>";
                echo "</form>";
        }
?>

      <br><h5>Medium Choices<br><br>
<?php
    $result = mysql_query("SELECT * FROM medium ORDER BY medName") or die(mysql_error());
    $num_rows=mysql_num_rows($result);
      if ($num_rows != "0")
        {
                echo "<form method='post' action='updateArtist.php'>";
                echo "<select name='medium'>";
            while ($r=mysql_fetch_array($result))
              { 
                $medName=$r["medName"];
                $medid=$r["medid"];
                   echo "<option value='$medid_1' selected>$medName - $medid</option>";
              }
                echo "</select>";
                echo "<input type='hidden'>";
                echo "</form>";
        }




?> 
      <br><h5>Genre Choices<br><br>
<?php
    $result = mysql_query("SELECT * FROM genre order by genName") or die(mysql_error());
    $num_rows=mysql_num_rows($result);
      if ($num_rows != "0")
        {
                echo "<form method='post' action='updateArtist.php'>";
                echo "<select name='genre'>";
            while ($r=mysql_fetch_array($result))
              { 
                $genid=$r["genid"];
                $genName=$r["genName"];
                echo "<option value='$genid_1' selected>$genName - $genid</option>";
              }
                echo "</select>";
                echo "<input type='hidden'>";
                echo "</form>";
        }

?> 
      <br><h5>Periods Choices<br><br>
<?php
    $result = mysql_query("SELECT * FROM period order by perName") or die(mysql_error());
    $num_rows=mysql_num_rows($result);
      if ($num_rows != "0")
        {
                echo "<form method='post' action='updateArtist.php'>";
                echo "<select name='period'>";
            while ($r=mysql_fetch_array($result))
              { 
                $perid=$r["perid"];
                $perName=$r["perName"];
                echo "<option value='$perid_1' selected>$perName - $perid</option>";
              }
                echo "</select>";
                echo "<input type='hidden'>";
                echo "</form>";
        }
?> 

      <br><h5>Museum Choices<br><br>
<?php
    $result = mysql_query("SELECT * FROM museum ORDER BY musName") or die(mysql_error());
    $num_rows=mysql_num_rows($result);
      if ($num_rows != "0")
        {
                echo "<form method='post' action='updateArtist.php'>";
                echo "<select name='museum'>";
            while ($r=mysql_fetch_array($result))
              { 
                $musName=$r["musName"];
                $musid=$r["musid"];
                   echo "<option value='$musName' selected>$musName - $musid</option>";
              }
                echo "</select>";
                echo "<input type='hidden'>";
                echo "</form>";
        }


?> 
     

</td>
  <tr>
    <td align=center colspan=5><h3><img src=../image/smLine.gif></h3></td></tr>
  <tr>
    <td id="main" width="500" valign="top">
      <?php

mysql_select_db("theartdb"); 

$search=$_GET["imgid"];


//pulls info for Image

$result = mysql_query("SELECT * FROM image WHERE imgid = '$search'");

  while ($r=mysql_fetch_array($result))
   {    

   $imgid=$r["imgid"];
   $artid=$r["artid"];
   $title=$r["title"];
   $dtxt_1 =$r["dtxt_1"];
   $dt=$r["dt"];
   $medid=$r["medid"];
   $size_inch=$r["size_inch"];
   $size_cm=$r["size_cm"];
   $musid=$r["musid"];
   $movid=$r["movid"];
   $genid=$r["genid"];
   $perid=$r["perid"];
   $bio=$r["bio"];
   $keywords=$r["keywords"];
   $notes=$r["notes"];
   $verified=$r["verified"];



//display the form

   echo "<table border=0 width=600 bgcolor=f4efd2>";
   echo "<tr><td><img src='../image/$artid/$imgid.jpg' border=0> <br><br></td></tr>\n";
   echo "<tr><td><form method='post' action='updateImage.php'></td></tr>\n";

   echo "<tr><td colspan=2><h5>Title --</td></tr><tr><td colspan=6><input type='text' size='70' name='title' value='$title'></td></tr>\n";

   echo "<tr><td><h5>Image Id</td><td><h5>Artist Id</td></td></tr>\n";
   echo "<tr><td><input type='text' name='imgid' value='$imgid'><td><input type='text' name='artid' value='$artid'></td></tr>\n";

   echo "<tr><td colspan=2><h5>Date Info --</td></tr>\n";
   echo "<tr><td>Date Extra</td><td>Date</td></tr>\n";
   echo "<tr><td><input type='text' name='dtxt_1' value='$dtxt_1'></td><td><input type='text' name='dt' value='$dt'></td></tr>\n";


   echo "<tr><td colspan=2><h5>Medium --</td></tr><tr><td><input type='text' name='medid' value='$medid'></td></tr>\n";

   echo "<tr><td colspan=2><h5>Size --</td></tr>\n";
   echo "<tr><td>Inches</td><td>Centimeters</td></tr>\n";
   echo "<tr><td><input type='text' name='size_inch' value='$size_inch'></td><td><input type='text' name='size_cm' value='$size_cm'></td></tr>\n";

   echo "<tr><td bgcolor=f2e9b8 colspan=2><h5>Location --</td></tr>\n";
   echo "<tr><td colspan=2>Museum</td></tr><tr><td><input type='text' name='musid' value='$musid'></td></tr>\n";

   echo "<tr><td colspan=2><h5>Movement --</td></tr><tr><td><input type='text' name='movid' value='$movid'></td></tr>\n";

echo "<tr><td colspan=2>

<label for='movement'>movement</label> 
  <select name='movement' id='movement'> 
   <?php while ( $r = mysql_fetsch_object( $results ) ) { 
    if ( $r->moveid == $movid_1 ) 
        $sel = ' selected=\'selected\''; 
    else 
        $sel = ''; 

    echo '<option value=\'{$r->moveid}\' $sel>{$r->movName}</option>\n'; 
} 

?> 
  </select> 

</td></tr>\n";

   echo "<tr><td colspan=2><h5>Genre --</td></tr><tr><td><input type='text' name='genid' value='$genid'></td></tr>\n";

   echo "<tr><td bgcolor=f2e9b8 colspan=2><h5>Period --</td></tr><tr><td><input type='text' name='perid' value='$perid'></td></tr>\n";

   echo "<tr><td colspan=2><h5>Art Work Info --</td></tr><tr><td colspan=3><textarea rows='5' cols='70' wrap='physical' name='bio' value='$bio'>$bio</textarea></td></tr>\n";
   echo "<tr><td colspan=2><h5>Keywords --</td><tr></tr><td colspan=3><textarea rows='5' cols='70' wrap='physical' name='keywords' value='$keywords'>$keywords</textarea></td></tr>\n";
   echo "<tr><td colspan=2><h5>Notes --</td><tr></tr><td colspan=3><textarea rows='5' cols='70' wrap='physical' name='notes' value='$notes'>$notes</textarea></td></tr>\n";

   if ($verified)
      echo "<tr><td colspan=2><h5>Verified  <input type='checkbox' name='verified' value='1' checked></td></tr>\n";
   else
      echo "<tr><td colspan=2><h5>Verified  <input type='checkbox' name='verified' value='1'></td></tr>\n";

   echo "<tr><td><input type='submit' name='button' value='Update'></td></tr>\n";
//   echo "<tr><td><input type='submit' name='button' value='Delete'></td></tr>\n";
   echo "</form>\n";


}


?>

 

My question is how do I go about displaying data from a table, selecting it and updating the related info in another table??

 

Any related sites that I can look at? I have googled but I don't think I am phrasing it right.

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.