teemflmngo Posted December 10, 2012 Share Posted December 10, 2012 I think that this should be easy, but I'm pulling my hair out. I am trying to build a page that pulls a bunch of info from a mySQL database and displays it as a table for someone else to review. I am showing art images and information so a juror can select pieces for a show. What I want to do is give the juror a simple tool to use to color code images as she rejects them. I thought that I could use a form with radio buttons that would send a hexidecimal code back to the database, and then that code is used to fill a cell background with either red (out), yellow (maybe), or green (in). I am able to color the background if I enter the code into the database using phpMyAdmin, but I cannot get the form to send a simple string back to the server. My code is probably completely convoluted by now, but as of the last attempt, I've been trying to adapt a tutorial that uses a text field to send a string back to the database. I am attaching the entire file, but the form in question begins on line 158 and continues through line 173. Any help or suggestions are greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/271806-sending-a-string-to-a-database-with-a-form/ Share on other sites More sharing options...
Christian F. Posted December 10, 2012 Share Posted December 10, 2012 Post your code, and we'll have a look at it. Quote Link to comment https://forums.phpfreaks.com/topic/271806-sending-a-string-to-a-database-with-a-form/#findComment-1398486 Share on other sites More sharing options...
teemflmngo Posted December 10, 2012 Author Share Posted December 10, 2012 (edited) I'm sorry, I thought that I had attached it. It's been that kind of weekend ... The form is inserted into a column of the table, and is found near the end of the code. <?php $dbcnx = @mysql_connect('localhost', 'sculptevv', '13468022'); if (!$dbcnx) { exit('<p>Unable to connect to the database server at this time.</p>'); } if (!@mysql_select_db('sculptevv_evv')) { exit('<p>Unable to locate the database at this time.</p>'); } echo '<p>Here are all the entries in our database:</p>'; $artlist = @mysql_query('SELECT tblEntries.id, tblUser.id, artid, userid, title, medium, completed, height, width, depth, weight, price, description, site1, site2, site3, locationreason, installation, equipment, manhours, maintainance, availability, accepted, fname, lname, statement, cv FROM tblEntries, tblUser WHERE tblEntries.userid=tblUser.id AND tblEntries.id>100'); if (!$artlist) { exit('<p>Error perfoming query: ' . mysql_error() . '</p>'); } echo '<table border="1" cellpadding="6" cellspacing="0"> <tr bgcolor="#dedede"><td width="25"></td><td width="100">Artist</td><td width="100">Statement</td><td width="50">CV</td><td width="250">title</td><td width="100">medium</td><td width="100">Date Completed</td><td width="100">Dimensions<br />Weight</td><td width="100">Price</td><td width="100">Description</td><td width="100">Site Selection</td><td width="100">Site Reason</td><td width="100">Installation</td><td width="100">Equipment</td><td width="100">Man hours</td><td width="100">Maintainance</td><td width="100">Availability</td><td width="50">In/Out</td></tr>'; $artnumber = 1; while ($art = mysql_fetch_array($artlist)) { /* $forsale = $art['forsale']; If ($forsale == 0) { $value = nfs; } else { $price = $art['value']; $value = "$$price.00"; } */ $id = $art['id']; $artid = $art['artid']; $arttitle = $art['title']; $artmedium = $art['medium']; $completed = $art['completed']; $height = $art['height']; $width = $art['width']; $depth = $art['depth']; $weight = $art['weight']; $price = $art['price']; $description = $art['description']; $site1 = $art['site1']; $site2 = $art['site2']; $site3 = $art['site3']; $locationreason = $art['locationreason']; $installation = $art['installation']; $equipment = $art['equipment']; $manhours = $art['manhours']; $maintainance = $art['maintainance']; $availability = $art['availability']; $accepted = $art['accepted']; $fname = $art['fname']; $lname = $art['lname']; $statement = $art['statement']; $cv = $art['cv']; echo "<tr><td bgcolor='$accepted'>$artnumber</td> <td>$fname $lname</td> <td><a href='upload/$id/statement/$statement'>Artist's Statement</a></td> <td><a href='upload/$id/cv/$cv'>CV</a></td> <td><i>$arttitle</i><br />"; $url='upload/' . $id . '/entries/' . $artid . '/views'; $dir = opendir($url); $fcount = 0; //List files in images directory while (($file = readdir($dir)) !== false) { if (eregi("\.jpg",$file)) { $imgurl = $url . '/' . $file; if ($fcount <1) { echo "<a href='$url/$file' rel='lightbox[$id$artid]'><img src='$url/$file' width='90' /></a>"; $fcount ++; } else { echo "<a href='$url/$file' rel='lightbox[$id$artid]'></a>"; } } } closedir($dir); echo "<br /><br />Details:"; $url='upload/' . $id . '/entries/' . $artid . '/details'; $dir = opendir($url); $fcount = 0; //List files in images directory while (($file = readdir($dir)) !== false) { if (eregi("\.jpg",$file)) { $imgurl = $url . '/' . $file; if ($fcount <1) { echo "<a href='$url/$file' rel='lightbox[d$id$artid]'><img src='$url/$file' width='90' /></a>"; $fcount ++; } else { echo "<a href='$url/$file' rel='lightbox[d$id$artid]'></a>"; } } } closedir($dir); echo "</td> <td>$artmedium</td> <td>$completed</td> <td>$height x $width x $depth<br />$weight</td> <td>$price</td> <td>$description</td> <td>First Choice: $site1<br />Second Choice: $site2<br />Third Choice: $site3</td> <td>$locationreason</td> <td>$installation<br />"; $url='upload/' . $id . '/entries/' . $artid . '/installation'; $dir = opendir($url); $fcount = 0; //List files in images directory while (($file = readdir($dir)) !== false) { if (eregi("\.jpg",$file)) { $imgurl = $url . '/' . $file; if ($fcount <1) { echo "<a href='$url/$file' rel='lightbox[i$id$artid]'><img src='$url/$file' width='90' /></a>"; $fcount ++; } else { echo "<a href='$url/$file' rel='lightbox[i$id$artid]'></a>"; } } } closedir($dir); echo "</td> <td>$equipment</td> <td>$manhours</td> <td>$maintainance</td> <td>$availability</td> <td> <form action='"; $_SERVER['PHP_SELF']; echo"' method='post'> <label>Yes or No:<br /> <textarea name='accepted' rows='1' cols='20'> </textarea></label><br /> <input type='submit' value='SUBMIT' /> </form>"; if (isset($_POST['accepted'])) { $accepted = $_POST['accepted']; $sql = "INSERT INTO tblEntries SET accepted='$accepted'"; if (@mysql_query($sql)) { echo '<p>Your joke has been added.</p>'; } else { echo '<p>Error adding submitted joke: ' . mysql_error() . '</p>'; } } echo "</td></tr>"; $artnumber ++; } echo '</table>'; ?> Edited December 10, 2012 by teemflmngo Quote Link to comment https://forums.phpfreaks.com/topic/271806-sending-a-string-to-a-database-with-a-form/#findComment-1398511 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.