Jump to content

jvance38

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jvance38's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a mysql database where users enter their data using a form that includes a rundate input field that generates a calendar date in this type of format: xx/xx/xxxx into a mysql database field called rundate. I would like to query the database to search a string of dates that are in the database, such as 01/01/2011, 01/02/2011, 01/03/2011 but I'm not sure on how to code this into my search.php. I have attached the search page to this post. Any suggestions would be greatly appreciate, and if you need me to be more expanded on my explanation, just let me know....i try to keep it very simplistic. [attachment deleted by admin]
  2. Cool, thank you so much. Well, there is some progress!! I placed the <?php $id = $_GET['record']; ?> on the update_budget.php page but it is not populating the update form page fields. When I hover over the EDIT link, it is pointing to the correct id number for that record. I developed this update page by copying the Insert_budget.php page that users fill in and submit data to database and then adding an update record server behavior to that page. I am placing that code from the update page to this post to see if you can tell me where that particular $id=$_GET['record'] needs to be place. <?php $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE daily_budget SET rundate=%s, `section`=%s, slug=%s, reporter=%s, budgetInfo=%s, notes=%s, deadline=%s, pickup=%s, sidebar=%s, sBudget=%s WHERE id=%s", GetSQLValueString($_POST['rundate'], "text"), GetSQLValueString($_POST['section'], "text"), GetSQLValueString($_POST['slug'], "text"), GetSQLValueString($_POST['reporter'], "text"), GetSQLValueString($_POST['budgetInfo'], "text"), GetSQLValueString($_POST['notes'], "text"), GetSQLValueString($_POST['deadline'], "text"), GetSQLValueString($_POST['pickup'], "text"), GetSQLValueString($_POST['sidebar'], "text"), GetSQLValueString($_POST['sBudget'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_connAdmin, $connAdmin); $Result1 = mysql_query($updateSQL, $connAdmin) or die(mysql_error()); $updateGoTo = "manage_budgets.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } $colname_getBudget = "-1"; if (isset($_GET['id'])) { $colname_getBudget = $_GET['id']; } mysql_select_db($database_connAdmin, $connAdmin); $query_getBudget = sprintf("SELECT id, rundate, slug, reporter, budgetInfo, notes, `section`, deadline, sidebar, sBudget, pickup FROM daily_budget WHERE id = %s", GetSQLValueString($colname_getBudget, "int")); $getBudget = mysql_query($query_getBudget, $connAdmin) or die(mysql_error()); $row_getBudget = mysql_fetch_assoc($getBudget); $totalRows_getBudget = mysql_num_rows($getBudget); ?> <style type="text/css"> <!-- body { font: 12px Verdana, Arial, Helvetica, sans-serif; background: #DFFFF8; margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ color: #000000; } .oneColFixCtrHdr #container { width: 780px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */ background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: 1px solid #000000; text-align: left; /* this overrides the text-align: center on the body element. */ } .oneColFixCtrHdr #header { background: #FFF; padding: 0 10px 0 20px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */ text-align: right; } .oneColFixCtrHdr #header h1 { margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */ padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */ } .oneColFixCtrHdr #mainContent { background: #DFFFF8; width: 780px; padding-top: 0; padding-right: 20px; padding-bottom: 0; padding-left: 20px; } .oneColFixCtrHdr #footer { padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */ background:#DDDDDD; } .oneColFixCtrHdr #footer p { margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */ padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */ } .oneColFixCtrHdr #container #header table tr .logout strong .logout { text-align: right; } .oneColFixCtrHdr #container #header table tr .logout strong { text-align: right; } .oneColFixCtrHdr #container #header table tr td p strong a { text-align: left; } .oneColFixCtrHdr #container #header table tr td h2 { } .lftfloat { text-align: left; float: left; } .oneColFixCtrHdr #container #header table tr .logout { float: right; } .oneColFixCtrHdr #container #header table tr .logout strong { float: right; } .oneColFixCtrHdr #container #header table tr .logout .logout strong { float: right; } .oneColFixCtrHdr #container #header table tr td p strong { float: left; } .oneColFixCtrHdr #container #header table tr td h2 { float: left; } .oneColFixCtrHdr #container #header table tr td strong { float: left; } --> </style> <!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"> <script src="/new_budget/SpryAssets/SpryValidationSelect.js" type="text/javascript"></script> <link href="/new_budget/SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" /> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Budget Record</title> <script src="/budgets/jquery.ui-1.5.2/jquery-1.2.6.js" type="text/javascript"></script> <script src="/budgets/jquery.ui-1.5.2/ui/ui.datepicker.js" type="text/javascript"></script> <link href="/budgets/jquery.ui-1.5.2/themes/ui.datepicker.css" rel="stylesheet" type="text/css" /> </head> <body> <p> </p> <center> <table width="80%" border="0" cellspacing="0" cellpadding="3"> <tr> <th scope="row"><p><a href="/new_budget/forms/Welcome.php">Return to Welcome Screen</a></p></th> <th scope="row"><p><a href="/new_budget/forms/report2.php">View Budget Report</a></p></th> <th scope="row"><p><a href="/new_budget/admin/manage_budgets.php">Edit budgets</a></p></th> <th scope="row"><span class="logout"><a href="<?php echo $logoutAction ?>">Log out</a></span></th></tr> </table></center><BR/> <center><h2>Insert Daily Budget </h2></center> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center" bgcolor="#FFFFFF" border="1"> <tr valign="baseline"> <td width="167" align="right" nowrap="nowrap"><strong>Rundate:</strong></td> <td width="854"><input type="text" name="rundate" value="<?php echo htmlentities($row_getBudget['rundate'], ENT_COMPAT, 'utf-8'); ?>" size="65" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Section:</strong></td> <td><input type="text" name="section" value="<?php echo htmlentities($row_getBudget['section'], ENT_COMPAT, 'utf-8'); ?>" size="65" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Slug:</strong></td> <td><input type="text" name="slug" value="<?php echo htmlentities($row_getBudget['slug'], ENT_COMPAT, 'utf-8'); ?>" size="65" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Reporter:</strong></td> <td><input type="text" name="reporter" value="<?php echo htmlentities($row_getBudget['reporter'], ENT_COMPAT, 'utf-8'); ?>" size="65" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Budget Information:</strong></td> <td><textarea name="budgetInfo" cols="65" rows="3"><?php echo htmlentities($row_getBudget['budgetInfo'], ENT_COMPAT, 'utf-8'); ?></textarea></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Notes:</strong></td> <td><input type="text" name="notes" value="<?php echo htmlentities($row_getBudget['notes'], ENT_COMPAT, 'utf-8'); ?>" size="65" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Deadline:</strong></td> <td><input type="text" name="deadline" value="<?php echo htmlentities($row_getBudget['deadline'], ENT_COMPAT, 'utf-8'); ?>" size="65" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Art:</strong></td> <td valign="baseline"><table> <tr> <td><input type="radio" name="pickup" value="F" <?php if (!(strcmp(htmlentities($row_getBudget['pickup'], ENT_COMPAT, 'utf-8'),"F"))) {echo "checked=\"checked\"";} ?> /> Factbox</td> </tr> <tr> <td><input type="radio" name="pickup" value="G" <?php if (!(strcmp(htmlentities($row_getBudget['pickup'], ENT_COMPAT, 'utf-8'),"G"))) {echo "checked=\"checked\"";} ?> /> Graphic</td> </tr> <tr> <td><input type="radio" name="pickup" value="P" <?php if (!(strcmp(htmlentities($row_getBudget['pickup'], ENT_COMPAT, 'utf-8'),"P"))) {echo "checked=\"checked\"";} ?> /> Photo</td> </tr> <tr> <td><input type="radio" name="pickup" value="V" <?php if (!(strcmp(htmlentities($row_getBudget['pickup'], ENT_COMPAT, 'utf-8'),"V"))) {echo "checked=\"checked\"";} ?> /> Video</td> </tr> </table></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Sidebar:</strong></td> <td valign="baseline"><table> <tr> <td><input type="radio" name="sidebar" value="y" <?php if (!(strcmp(htmlentities($row_getBudget['sidebar'], ENT_COMPAT, 'utf-8'),"y"))) {echo "checked=\"checked\"";} ?> /> Yes</td> </tr> <tr> <td><input type="radio" name="sidebar" value="n" <?php if (!(strcmp(htmlentities($row_getBudget['sidebar'], ENT_COMPAT, 'utf-8'),"n"))) {echo "checked=\"checked\"";} ?> /> No</td> </tr> </table></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Sidebar Budget:</strong></td> <td><textarea name="sBudget" cols="65" rows="3"><?php echo htmlentities($row_getBudget['sBudget'], ENT_COMPAT, 'utf-8'); ?></textarea></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Update record" /></td> </tr> </table> <input type="hidden" name="MM_update" value="form1" /> <input type="hidden" name="id" value="<?php echo $row_getBudget['id']; ?>" /> </form> ?>
  3. Thank you for your reply, it kind of makes sense but I want to be sure of what you are telling me. I already have the two pages developed for editing and deleting. When you say to use the line $id = $_GET['record']; where does that get placed, in the following code? <a href="dbEdit.php?record='.$result['id'].'"> EDIT</a> | <a href="dbDelete.php?record='.$result['id'].'">DELETE</a> <br>';
  4. Thank you for explaining the posting requirements. I was under the impression that only the php needed to be in php tags. Anyways, these are the fields that my table consists of with id being the primary key. id, rundate, slug, reporter, budgetInfo, notes, `section`, deadline, sidebar, sBudget
  5. Sorry, i am new to this forum. How or what php code tags are required for posting code?
  6. Hello. I hope someone out there can help me with this as I have been trying all different ways to make this work but to no avail. I have a report.php page that allows a user to search 3 particular fields in a database to retrieve search results that displays itself on the same page. What I am looking to do is have both an EDIT and DELETE button/link for each queried result that is retrieved allowing the user to edit or delete the search result of their choice. Or, how to implement some inline editing on the results that are retrieved by the search query. Here is the code I have so far with the EDIT or DELETE options feature that I am wanting to utilize. <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Budgets Report</title> </head> <body class="oneColFixCtr"> <div id="container"> <h2>Budget Report</h2> <form name="search" method="post" style="background-color:#FFF" action="<?php $PHP_SELF?>"> <span id="search">Search for</span>: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="rundate">rundate</option> <Option VALUE="section">section</option> <Option VALUE="reporter">reporter</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <?php // check to see if anything is posted if (isset($_POST['find'])) {$find = $_POST['find'];} if (isset($_POST['searching'])) {$searching = $_POST['searching'];} if (isset($_POST['field'])) {$field = $_POST['field'];} //This is only displayed if they have submitted the form if (isset($searching) && $searching=="yes") { echo "<h2>Results</h2><p>"; // If they did not enter a search term we give them an error if (empty($find)) { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("budgets") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); // Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM daily_budget WHERE upper($field) LIKE'%$find%' ORDER BY section ASC"); // And we display the results while($result = mysql_fetch_array( $data )) { echo "<strong>Section:$nbsp</strong>"; echo " ";echo $result['section']; echo "<br>"; echo $result['slug']; echo " "; echo ":"; echo " "; echo $result['budgetInfo']; echo " "; echo "/"; echo " "; echo $result['reporter']; echo " "; echo $result['notes']; echo " "; echo $result['art_photos']; echo " "; echo $result['artDesc']; echo " "; echo $result['multimedia']; echo " "; echo $result['multimediaDesc']; echo "<br>"; echo "Pickup"; echo " "; echo ":"; echo " "; echo $result['pickup']; echo "<br>"; echo "Sidebar"; echo " "; echo ":"; echo " "; echo $result['sidebar']; echo "<br> "; echo $result['sSlug']; echo " "; echo $result['sBudget']; echo " "; echo $result['sArt']; echo " "; echo "EDIT"; echo " "; echo "| "; echo " ";echo "DELETE"; echo " "; echo "<br>"; echo "<hr>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> </div> </div> </body> </html>
  7. Sorry, but I'm new to this forum. I will remember to do so next time.
  8. So I've spent 2 days now searching the web on how to make my checkbox array on my form insert the value selected by the user into my database. Here is the code that I've written. All fields except for the checkbox array works fine. <?php virtual('/budgets/Connections/connAdmin.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if (isset($_POST['submit'])) { $workStyle = $_POST['art_photos']; // Setting up a blank variable to be used in the coming loop. $allStyles = ""; // For every checkbox value sent to the form. foreach ($workStyle as $style) { // Append a string called $allStyles with the current array element, and then add a comma and a space at the end. $allStyles .= $style . ", "; } // Delete the last two characters from the string. $allStyles = substr($allStyles, 0, -2); echo "<p>The resulting string is: <strong>$allStyles</strong></p>\r\n"; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO daily_budget (rundate, slug, reporter, budgetInfo, notes, `section`, deadline, art_photos sidebar, sBudget) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['rundate'], "text"), GetSQLValueString($_POST['slug'], "text"), GetSQLValueString($_POST['reporter'], "text"), GetSQLValueString($_POST['budgetInfo'], "text"), GetSQLValueString($_POST['notes'], "text"), GetSQLValueString($_POST['section'], "text"), GetSQLValueString($_POST['deadline'], "text"), GetSQLValueString($_POST['art_photos'], "text"), GetSQLValueString($_POST['sidebar'], "text"), GetSQLValueString($_POST['sBudget'], "text")); mysql_select_db($database_connAdmin, $connAdmin); $Result1 = mysql_query($insertSQL, $connAdmin) or die(mysql_error()); } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Budget Record</title> </head> <body> <?php if (isset($error)) { echo '<ul>'; foreach($error as $alert) { echo "<li class='warning'>$alert</li>\n"; } echo '</ul>'; } ?> <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1"> <table align="center" width="60%" border="2" bgcolor="#FFFFFF"> <tr valign="baseline"> <td width="14%" align="right" nowrap="nowrap"><STRONG>Rundate:</STRONG></td> <td width="86%"> <input type="text" name="rundate" size="30" value="" id="jQueryUICalendar2"/> <script type="text/javascript"> // BeginWebWidget jQuery_UI_Calendar: jQueryUICalendar2 jQuery("#jQueryUICalendar2").datepicker(); // EndWebWidget jQuery_UI_Calendar: jQueryUICalendar2 </script></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><STRONG>Section:</STRONG></td> <td> <select name="section"> <option value=""></option> <option value="A1">A1</option> <option value="Pickup All">Pickup All</option> <option value="Region">Region</option> <option value="Atlantic">Atlantic</option> <option value="Business">Business</option> <option value="Features">Features</option> <option value="Sports">Sports</option> </select> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Slug:</strong></td> <td><span id="sprytextfield2"> <input type="text" name="slug" value="" size="32" /> <span class="textfieldRequiredMsg">REQUIRED</span></span><span style="color: #F00; font-weight: bold; font-size: 10px;"></span></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Budget Information:</strong></td> <td><span id="sprytextarea1"> <textarea name="budgetInfo" cols="50" rows="4"></textarea> <span class="textareaRequiredMsg">Required.</span></span><span style="color: #F00; font-weight: bold; font-size: 11px;"></span></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Notes:</strong></td> <td><input type="text" name="notes" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Reporter:</strong></td> <td><span id="sprytextfield3"> <input type="text" name="reporter" value="" size="32" /> <span class="textfieldRequiredMsg">Required.</span></span><span style="color: #F00; font-weight: bold; font-size: 10px;"></span></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Deadline:</strong></td> <td><input type="text" name="deadline" size="30" value="Enter date" id="jQueryUICalendar1"/><script type="text/javascript"> // BeginWebWidget jQuery_UI_Calendar: jQueryUICalendar2 jQuery("#jQueryUICalendar1").datepicker(); // EndWebWidget jQuery_UI_Calendar: jQueryUICalendar2 </script> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Artwork:</strong></td> <td><label> <input type="checkbox" name="art_photos[]" value="factbox" id="art_photos_0" /> Factbox</label> <label> <input type="checkbox" name="art_photos[]" value="graphic" id="art_photos_1" /> Graphic</label> <label> <input type="checkbox" name="art_photos[]" value="photo" id="art_photos_2" /> Photo</label> <label> <input type="checkbox" name="art_photos[]" value="video" id="art_photos_3" /> Video</label> <br /></td> </tr> <tr> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> <strong>Sidebar:</strong></td> <td valign="baseline"><span id="spryradio2"> <label> <input type="radio" name="sidebar" value="y" id="sidebar_0" /> Yes</label> <br /> <label> <input type="radio" name="sidebar" value="n" id="sidebar_1" /> No</label> <br /> <span class="radioRequiredMsg"><strong style="font-size: 11px">REQUIRED.</strong></span></span> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Sidebar Information:</strong></td> <td><input type="text" name="sBudget" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insert record" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p> <h3><a href="/new_budget/admin/manage_budgets.php"><strong>View your budget entry, make changes or delete your budget.</strong></a></h3> <script type="text/javascript"> <!-- jQuery("#jQueryUICalendar1").datepicker(); jQuery("#jQueryUICalendar2").datepicker(); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {maxChars:15, validateOn:["change"]}); var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["change"]}); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var spryradio2 = new Spry.Widget.ValidationRadio("spryradio2"); //--> </script> </body> </html>
×
×
  • 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.