Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. SELECT DATE_FORMAT(`date`, '%b %Y'), COUNT(*) FROM customers_history WHERE status IN ('1', '2', '4') GROUP BY DATE_FORMAT(`date`, '%b %Y') ORDER BY DATE_FORMAT(`date`, '%b %Y') DESC LIMIT 12 will get the dates looking how you want. The rest of the formatiing is all to do with with your CSS and php. The "all in one line" issue is because the table isn't being generated properly, as I just copied and pasted your code I didn't check the output formating, here, have a go with this: $bg = '#ffffff'; //For Initial Row Color echo '<table border="1"> while ($row = mysql_fetch_array($result)){ $bg = ($bg=='#ffffff' ? '#e7e8e8' : '#ffffff'); //For Alternate Row Colors echo "<tr bgcolor='{$bg}'>"; echo "<td><span class='rowWidth1'>"; echo $row[0]; echo "</span></td>"; echo "<td><span class='rowWidth1'>"; echo $row[1]; echo "</span></td></tr>"; } echo '</table>'
  2. a book would be a big help, for refference if nothing else (even a cavant would have difficulty remembering everything about php) but if a form is involved you will POST the data from the form to your php. if the variable atributes are comming from an outside source (such as the URL header - most commonly) then you will need php to go GET the values. whatever method of transporting the values you choose to use, just remember that you have to use the same on both sides (only an issue with forms really) so if you are using 'method="POST" ' then you will use $_POST['varName'] to retieve the value likewise, if you use 'method="GET" ' then you will need to use $_GET['varName'] to retrieve it. Also, some hosting only allows one or another method of trasfering values between pages, so take that into account when you are making your pages (assuming you have access to that information at designe time).
  3. PHP5 yeah? I was having some massive headaches with PHP5 (that was one of them), finaly binned it and went back to 4. Search the PHP manual pages for the timezone settings, it's country specific (I get bonus points for stating the obvious ) so you'll need to find the value for your country there.
  4. if you are posting php, then use the php tags, general html/sql/css can live inside normal code tags. using the php tags highlights the code in a way that makes it much easier to read and debug then just posting the whole lot raw. <!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>'.$result['section'].'<br>'; echo $result['slug'].' : '.$result['budgetInfo'].' / '.$result['reporter'].' '.$result['notes'].' '.$result['art_photos'].' '.$result['artDesc'].' '.$result['multimedia'].' '.$result['multimediaDesc'].'<br>'; echo 'Pickup : '.$result['pickup'].'<br>'; echo 'Sidebar : '.$result['sidebar'].'<br>'; echo $result['sSlug'].' '.$result['sBudget'].' '.$result['sArt'].' <a href="dbEdit.php"> EDIT</a> | <a href="dbDelete.php">DELETE</a> <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> l;ooking through your code here (I tidied up your echo's a bit at the bottom) you are going to need to post your table structure so we can see what the primary key is.
  5. just code a search form into your pages <form action = "product_display.php" method ="POST"> <label>Search</label><input type = "text" name="search" value="" /><input type="submit" value="Search" /> </form> as long as your product display page knows to use $_POST['search'] to get it's result set it'll work from any page you include it on. that what your looking for?
  6. it's reffering to the timezone settings in your php.ini file. the defaults havn't been set properly. are you running this on a local server? Quick tags (<?) have been depreciated, so should be avoided.
  7. mysql_real_escape_string was invented for just such a problem
  8. I'm confuzzled what do you want to do?
  9. post your code inside the php code tags, then I'll actualy look at it.
  10. It's easy enough done with an array, but there are a few things you havn't told us, are you actualy going to be using 5 indipendant mail fields?, does it matter if the mail is sent out as a group mail, with each address visible to the others, or does it need to be addressed only to a single recipient?
  11. ok, we'll leave the if alone for the moment, let's clean up these short tags first of all, then we may want to have a look at dbconn.php incase the error is in there. change the end code to this: //print message echo (IsSet($msg)) ? "<div class=\"error\">$msg</div>" : ""; echo (IsSet($form_start)) ? $form_start : ""; echo '<input type ="hidden" name="id" value="'.$id.'" />'; echo (IsSet($table_row)) ? $table_row : ""; echo (IsSet($form_end)) ? $form_end : ""; ?> if this make no difference, post up your dbconn.php aswell.
  12. They are asking you where $id gets its value. if $id does not have a valid value your UPDATE will not work.
  13. that's what the type was for, I didn't know exactly what you would want to call the refference, so just went with something generic (shoulda cleared that up when I posted it) do please feel free to rename it whatever you wish.
  14. what's wrong with doing it in the SQL?
  15. you're still echoing $row['status'] when you don't actualy have a $row['status']. use this and see what happens: echo "<tr bgcolor='{$bg}'>"; echo "<td><span class='rowWidth1'>"; echo $row[0]; echo "</span></td>"; echo "<td><span class='rowWidth1'>"; echo $row[1]; echo "</span></td></tr>";
  16. I'm not sure what your asking with that. To list each fish on it's own line, with the checked image next to the ones that have true in the fresh field, you would do: $qry = 'SELECT fish, fresh FROM tableName'; $result = mysql_query($qry) or die ('Error querying the table : '.mysql_error()); while ($row = mysql_fetch_assoc($qry)){ echo $row['fish'].' '; if($row['fresh'] = 'true' { echo '<img src="checked.jpg">'; } echo'<br> } To limit the results to only showing a specific fish, you would change the string assigned to $qry to use a WHERE condition. Which are you looking to achieve?
  17. Your welcome (even though I did very little! you got there yourself in the end up), glad it worked out. You are 100% right to stick with what you know. If you need anything else you know where we are.
  18. what's this all about? //print message echo (IsSet($msg)) ? "<div class=\"error\">$msg</div>" : ""; ?> <? echo (IsSet($form_start)) ? $form_start : ""; ?> <input type ="hidden" name="id" value="<? echo $id ?>" /> <? echo (IsSet($table_row)) ? $table_row : ""; ?> <? echo (IsSet($form_end)) ? $form_end : ""; ?> why are you breaking out of PHP and then coming back in again on the next line using short tags? also, what are you doing here? if($_POST) {
  19. yet again I am bested by a comma stick a comma right after SET batting.runs = ((SELECT batting.runs) + '.$Runs.') Let us know what comes back after that's done.
  20. $fish is english? assuming your fresh column is populted by 'true' and 'false' then put this within the while loop of your database result call: echo $row['fish'].' '; if($row['fresh'] = 'true' { echo '<img src="checked.jpg">'; } echo'<br> of cource, you'll probably want to format it into a table or - even better - tag it with some css, but that's more about the layout than the results.
  21. sorry, I didn't mention, but did you change the execution of the queries to match the new variable? mysql_query($query) or die ('Error updating result: ' .mysql_error()); mysql_query($query2) or die ('Error updating result: ' .mysql_error()); should become mysql_query($qry) or die ('Error updating result: ' .mysql_error()); // mysql_query($query2) or die ('Error updating result: ' .mysql_error());
  22. Is there a reason you are assigning $to and then not using it?
  23. You have no row selected called status(and clearly no error reporting on either - which is never handy). you would need to echo $row['COUNT(*)']; instead.
  24. PFM' has covered why you are getting your errors. I personaly much preffer using . concat's, (although I think I am alone in this ) Try changing $query="UPDATE batting SET runs = ("'.$Runs.'"+runs) WHERE batsman = '$Batsman' " $query2="UPDATE bowling SET overs = ("'.$Overs.'"+overs) WHERE batsman = '$Batsman' " to $qry = 'UPDATE batting INNER JOIN bowling ON (batting.batsman = bowling.batsman) SET batting.runs = ((SELECT batting.runs) + '.$Runs.') bowling.overs = ((SELECT bowling.overs) + '.$Overs.') WHERE batting.batsman = \''.$Batsman.'\''; That should at the least get you a different error At best it should condense what you are doing into a single query.
×
×
  • 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.