Jump to content

garteth

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by garteth

  1. but I am already using sessions for my login script so how would i go about doing this? Could you give me an example of the code you would use.
  2. Sorry that is actually there i just cut off what was before it. So do you think that there is anyway that I can post the form details, print them to the page and then send the input field values to another page(now.php)?
  3. Ok I see your point on the separate tags. Below I have my form code: <form method="post" name="chooseDateForm" id="chooseDateForm" action="member-index-period.php"> <input type="hidden" name="MAX_FILE_SIZE" value="524288"> <fieldset> <legend>Test date picker form</legend> <ol> <li> <label for="startdate">Start date:</label> <input name="startdate" id="startdate" class="date-pick dp-applied"> </li> <li> <label for="enddate">End date:</label> <input name="enddate" id="enddate" class="date-pick dp-applied"> </li> <li> <input type="submit" name="Submit" id="Submit" value="Submit" /> </ol> </fieldset> <input type="hidden" name="submitted" value="TRUE" /> </form> Now here is the php code I use to display the results to the page: <?php require_once ('connect.php'); // Connect to the database. if (isset($_POST['submitted'])) { // Check if the form has been submitted. if (!empty($_POST['startdate'])) { $date = ($_POST['startdate']); } else { $date = FALSE; echo '<p><font color="red">Please enter the Course ID!</font></p>'; } if (!empty($_POST['enddate'])) { $date2 = ($_POST['enddate']); } else { $date2 = FALSE; echo '<p><font color="red">Please enter the Course ID!</font></p>'; } echo '<div id="pdfbutton" style="position: absolute; top:400px; right:200px;"> <img src="images/view_as_pdf.png"></div>'; $result = mysql_query("SELECT * FROM audit WHERE user = '" . $_SESSION['SESSUSER'] . "' AND date >= \"$date\" AND date <= \"$date2\""); echo "<table border='1'>"; echo "<tr> <th>Date</th> <th>Destination</th> <th>Reply</th> <th>Identifier</th> <th>IP Address</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . date("d-m-Y", strtotime($row["date"])) . "</td>"; echo "<td>" . $row['dest'] . "</td>"; echo "<td>" . $row['reply'] . "</td>"; echo "<td>" . $row['identifier'] . "</td>"; echo "<td>" . $row[origip'] . "</td>"; echo "<td>" . $row[text'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</br>";
  4. try this <h1>Welcome <?php echo $_SESSION['SESS_CUSTOMER_NAME'];?></h1> obviously where 'SESS_CUSTOMER_NAME' is the name of the session that you have created.
  5. Hi I did what you said and nothing appeared in the pop up boxes. I have taken out the pdf code and used the following for now.php in order to see if it will print the values. <?php require_once('auth.php'); ?> <?php require_once ('connect.php'); // Connect to the database. if (!empty($_GET['startdate'])) { $date = ($_GET['startdate']); } else { $date = FALSE; echo '<p><font color="red">Please enter the Course ID!</font></p>'; } if (!empty($_GET['enddate'])) { $date2 = ($_GET['enddate']); } else { $date2 = FALSE; echo '<p><font color="red">Please enter the Course ID!</font></p>'; } echo "$date"; echo "$date2"; Also I should mention that the link to the now.php is dynamic and is created once the query has run. If I click it once the query has run then the JavaScript does not do its job, but if I create the link as a static html link and then type in the two values and click the button the it works.
  6. They are input boxes. Its just like any normal HTML form that is posting data and querying a mysql database and returning the results, however after the results are displayed I want to grab the dates that were input
  7. Hi I am wanting to create a site that will allow a user to input to and from dates and then display the results onto a page using php and mysql. Once the results are on the page they can have the option of exporting the results to PDF. I am currently using dompdf to create the PDF however it seems as though once the submit button has been pressed the PHP grabs the values entered in the fields and turns them into variables. This is fine and is obviously what I need to happen in order to display the data onto the page. The only thing is that I want JavaScript to also grab the values if the export to pdf button is clicked and redirect to another page which creates the pdf. The code below is what I am using to do this: $('#pdfbutton').click(function() { var start = $('#startdate').val(); var end = $('#enddate').val(); window.location.replace("now.php?startdate=" + start + "&enddate=" + end); }); The only thing is when you click the button it redirects with no values in the URL. Does anyone have any ideas of how to get around this? Thanks
  8. Brilliant Thank you very much for your help.
  9. Hi I have a problem where I want to display all of the SMS messages a user has sent within this month, however the date format within mysql is YYYY-MM-DD. So I think what I would need is a way for the PHP query to get the current month and then select all entries within the DB that correspond to said month. Any ideas on how I would go about solving this issue? Thanks
  10. Hi I am currently working my way through this tutorial which will produce a pop up calendar. Something that is really annoying though is that where there should be a small calendar next to the textfield I have 2 small calendars. I have provided my code and an attached screenshot. Thanks !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>jQuery datePicker simple datePickerStartEnd demo</title> <!-- firebug lite --> <script type="text/javascript" src="firebug.js"></script> <!-- jQuery --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <!-- required plugins --> <script type="text/javascript" src="date.js"></script> <!--[if IE]><script type="text/javascript" src="scripts/jquery.bgiframe.min.js"></script><![endif]--> <!-- jquery.datePicker.js --> <script type="text/javascript" src="jquery.datePicker.js"></script> <!-- datePicker required styles --> <link rel="stylesheet" type="text/css" media="screen" href="datePicker.css"> <!-- page specific styles --> <link rel="stylesheet" type="text/css" media="screen" href="demo.css"> <!-- page specific scripts --> <script type="text/javascript" charset="utf-8"> $(function() { $('.date-pick').datePicker() $('#start-date').bind( 'dpClosed', function(e, selectedDates) { var d = selectedDates[0]; if (d) { d = new Date(d); $('#end-date').dpSetStartDate(d.addDays(1).asString()); } } ); $('#end-date').bind( 'dpClosed', function(e, selectedDates) { var d = selectedDates[0]; if (d) { d = new Date(d); $('#start-date').dpSetEndDate(d.addDays(-1).asString()); } } ); }); </script> </head> <body> <div id="container"> <h1>jquery.datePicker example: linked datePickers with start and end dates</h1> <p><a href="index.html">< date picker home</a></p> <p> The following example displays how you can synchronise two date pickers together. A common scenario for an online date picker is when booking flights or something where you need to input outbound and inbound dates. The start date must be before the end date and vice versa. We can enforce this rule with a very simple little bit of script. </p> <form name="chooseDateForm" id="chooseDateForm" action="#"> <fieldset> <legend>Test date picker form</legend> <ol> <li> <label for="start-date">Start date:</label> <input name="start-date" id="start-date" class="date-pick dp-applied"><a href="#" class="dp-choose-date" title="Choose date">Choose date</a> </li> <li> <label for="end-date">End date:</label> <input name="end-date" id="end-date" class="date-pick dp-applied"><a href="#" class="dp-choose-date" title="Choose date">Choose date</a> </li> <li> <label for="test-select">Test select:</label> <select name="test-select" id="test-select" style="width: 170px"> <option value="1">Test SELECT </option> <option value="2">Doesn't shine through</option> <option value="3">Even in IE</option> <option value="4">Yay!</option> </select> </li> </ol> </fieldset> </form> </body> </html> [attachment deleted by admin]
  11. That would be the right answer but I have realised that I left out a few details. What I really have is the following value in a field within my database: 20110523094726.BmmW The first part is the year/month/day hh:mm:ss I want to be able to strip the .BmmW off of the end and then print the date and time as follows: 09:47:26 23/05/2011 Do you know of any way that I can accomplish this? Would I need to do it before calling: echo "<td>" . $row['smsident'] . "</td>"; *smsident is the field containing the value. Thanks
  12. Ironmask you were 100% correct, cannot believe that I did not see that. Thanks very much for everyone's help
  13. Really because when I write include ('connect.php'); at the top I get this message: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
  14. Can anyone tell me how I would need to change my query so that I can use require_once('mysql_connect.php'); instead of having to write my database details into the php file. $result = mysql_query("SELECT * FROM smsaudit WHERE smsuser = '" . $_SESSION['SESS_SMS_USER'] . "'"); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . strrev($row['smsident']). "</td>"; echo "<td>" . $row['smsuser'] . "</td>"; echo "<td>" . $row['smsdest'] . "</td>"; echo "<td>" . $row['smsreply'] . "</td>"; echo "<td>" . $row['smsidentifier'] . "</td>"; echo "<td>" . $row['smsorigip'] . "</td>"; echo "<td>" . $row['smstext'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</br>"; ?> currently I am connecting like so: mysql_connect ("#####", "#####","######") or die (mysql_error()); mysql_select_db("#####");
  15. Just realised that the string reversal was not completely successful. I have a date format which I wanted altered 20110523 This reversed as 32501102 but what I wanted was 23052011 I have read about the explode() function and the ability to separate a string into parts and then echo them into the right order, but is there a way of doing this for what I want to accomplish? Can I use the explode function and say characters 1-4 will be named part1, characters 5-6 will be part2, and characters 7-8 will be part3?
  16. That's brilliant thank. If I wanted to strip off the first 5 characters how would I do that? I tried this but it didn't work: echo "<td>" . strrev(substr($row['smsident' ,1,8])). "</td>"; Any ideas?
  17. I know about the function strrev but could you tell me how I would use it with my coding? I tried . $row strrev['smsident'] but it didnt work.
  18. Hi I have the following code: $result = mysql_query("SELECT * FROM smsaudit WHERE smsuser = '" . $_SESSION['SESS_SMS_USER'] . "'"); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['smsident'] . "</td>"; echo "<td>" . $row['smsdest'] . "</td>"; echo "<td>" . $row['smsreply'] . "</td>"; echo "<td>" . $row['smsidentifier'] . "</td>"; echo "<td>" . $row['smsorigip'] . "</td>"; echo "<td>" . $row['smstext'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</br>"; ?><br /> What I would like to do is have the output of 'smsident' to be reversed when it appears in the table. Is there any way that I can do this or a much simpler piece of coding that will do the same as t he above does? Please help!!!
  19. Ive tried that but I do not know what I am doing wrong with the loop. Is there a simpler way for a user to be able to search a database and display the results then the way that I am doing it?
  20. Hi The site is not live it is just a test site for my live one. Basically what I want is for someone to be able to search for information within the database based upon a chosen criteria e.g. I want to find someone using their IP Address so I put that into the IP Address field and click submit. So the php takes the value from the field and then queries the database and pulls out all of the information about that person and will display it into a table. What I dont want to have is a static table, I want it to create a new row each time an entry is pulled from the database and then close itself at the end and display on the webpage. I thought that this code would do the trick however it creates the first row but not the subsequent ones. Any ideas?
  21. Hi This may seem pretty standard to some of you but I am having a problem with tables. What I am trying to do is give the user 4 fields to choose from and depending upon which field they enter data into the php will query the mysql database and return all of the data related to that value and place it into a table. Seems fair enough however there could be multiple entries of that value and I want there to maybe be a loop that will check for the information and then when it is done complete the table. My code looks something like this: <html> <?php # Script 14.2 - course_form.php // This page allows the administrator to add a course (product). $con = mysql_connect("localhost","root","millennium"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Validate the print_name, image, artist (existing or first_name, last_name, middle_name), size, price, and description. // Check for a course id. if (!empty($_POST['IpAddress'])) { $ip = ($_POST['IpAddress']); } else { $ip = FALSE; } // Check for a course id. if (!empty($_POST['Identifier'])) { $id = ($_POST['Identifier']); } else { $id = FALSE; } // Check for a course id. if (!empty($_POST['Destination'])) { $de = ($_POST['Destination']); } else { $de = FALSE; } // Check for a course id. if (!empty($_POST['Reply'])) { $re = ($_POST['Reply']); } else { $re = FALSE; } // Add the course to the database. mysql_select_db("accs", $con); $result = mysql_query("SELECT * FROM smsaudit WHERE smsreply='$re' || smsorigip='$ip' || smsidentifier='$id' || smsdest='$de'"); $tdcount = 1; $numtd = 4; // number of cells per row echo "<table border='1'>"; while($row = mysql_fetch_array($result)) { if ($tdcount == 1) echo "<tr>"; echo "<td>IP Address: $ip </td>"; // display as you like echo "<td>Identifier: $id </td>"; echo "<td>Destination: $de </td>"; echo "<td>Reply: $re </td>"; if ($tdcount == $numtd) { echo "</tr>"; $tdcount = 1; } else { $tdcount++; } // time to close up our table if ($tdcount!= 1) { while ($tdcount <= $numtd) { echo "<td> </td>"; $tdcount++; } echo "</tr>"; } echo "</table>"; } echo "<br />"; $result2 = mysql_query("SELECT totalsms FROM smsaudit ORDER BY totalsms DESC LIMIT 1"); while($row = mysql_fetch_array($result2)) { echo 'You have used ' . $row['totalsms'] .' sms messages'; } } else { // Display the form. ?> <form action="form1.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288"> <p> </p> <table width="449" border="0"> <td><h1>SMS Information</h1></td> <td> </td> <td> </td> <td> </td> </tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td width="160"><strong>IP Address</strong></td> <td width="95"> </td> <td width="167"><strong>Identifier</strong></td> </tr> <tr> <td><input name="IpAddress" type="text" id="IpAddress" /></td> <td> </td> <td><input name="Identifier" type="text" id="Identifier" /></td> <td width="9"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><strong>Destination</strong></td> <td> </td> <td><strong>Reply</strong></td> <td> </td> </tr> <tr> <td><input name="Destination" type="text" id="Destination" /></td> <td> </td> <td><input name="Reply" type="text" id="Reply" /></td> <td> </td> </tr> <tr> <td><input type="submit" name="Submit" id="Submit" value="Submit" /></td> <td> </td> <td> </td> <td> </td> </tr> </table> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php } // End of main conditional. ?> </html> Can anyone please let me know of a way to achieve this? Thanks
×
×
  • 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.