Jump to content

shane85

Members
  • Posts

    128
  • Joined

  • Last visited

    Never

Everything posted by shane85

  1. sorry for all the posts today guys... I have a page where im editing a row (clients information) from my database I access it by edit_prospect?=prospect_id=5 (or whatever the prospect_id number is set in the database) I then have my text fields extra but I have values in them which would be the values that are pulled from the database, so that if need be it can be edited. I then setup my form to go to edit_prospect2.php, in which I have a query that im trying to update my database, but it keeps telling my query failed. I have tried 2 different querys...1 with SET and it gives me the same results...the ones I have been trying are $qry = "UPDATE prospects SET(representative, prospect_feeling, firstname, lastname) VALUES('$representative','$prospect', '$f_name', '$l_name')"; which doesnt work, as well as $qry = "UPDATE prospects (representative, prospect_feeling, firstname, lastname) VALUES('$representative','$prospect', '$f_name', '$l_name')"; what am I doing wrong ???
  2. hey guys I have a form that when submitted, I have 2 drop downs, and 1 text field the 2 drop downs are contacted_month contacted_day and the text field is contacted_year then I submit all this info to my database, however I store it into 1 field called last_contacted now im making a page so "edit client info", but am having a hard time figuring out how to edit this since I have the drop downs and text field and am trying to put a value in it which would be the date, but I need to seperate it into the 3 fields. I know I have to do an array of some sort, but how would it look? Also, would you recomend storing it as a timestamp in the database, an int, or just varChar??? sorry for the newbie question...still learning but appreciate all the help.
  3. ah...I just noticed it wasnt in my query....currently my query is set as $prospectEntries = mysql_query('SELECT * FROM prospects WHERE prospect_id="'.$_GET['prospect_id'].'"' ) or trigger_error(mysql_error()); it has to be like that because of the other functions I have on the page. I know I need to include UNIX_TIMESTAMP(tstamp) AS tstamp but how would I incorporate that in?? thanks
  4. hey guys in my mysql db I have a field tstamp...I have it so when the form is submitted and info is entered into the database, it ads the timestamp. Im trying to show the tstamp on my page, however its not displaying the same date thats in my database. In my database, I have one of the dates as 2010-04-01 12:23:15 im trying to access it by <?php echo date('M, d - Y', $arrEntry['tstamp']); ?> however, regardless of whats actually in the database, it is displaying Dec, 31 - 1969 why would this be??? Thanks in advance
  5. I just included a snipit of the code...before I had this exact same code but the <?php echo findColor($i++); ?> in the table rows and every table row switched colors.
  6. hey guys. So ive created a function that displays a table showing my database records. For every new row, it displays this table with various information. A member from the boards here was kind enough to create a function for me to switch the colors but initially he applied it to rows, I would like to apply it to the table so that for example, the first time the table is shown, for arguement sake the background color would be #FFFFFF and the 2nd time the table is shown, the background color to be #F8F8F8. How do I use this function correctly? Thanks in advance. I have pasted a snipit of the code below. Ive also edited it to what I thought would work, howver, every time the table is repeated it just shows the 1 color and doesnt switch to the next. function findColor($n) { return ($n % 2 == 0) ? '#FFFFFF' : '#F8F8F8'; } // Create function to display the news entries function print_prospectEntry($arrEntry) { // convert \n linebreaks to HTML formatted <br> breaks $arrEntry['comments'] = str_replace("\n", '<br>', $arrEntry['comments']); $i = 1; ?> <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:<?php echo findColor($i++); ?>"> <tr> <td width="10"></td> <td width="300">Representative:</td> <td style="padding: 5px;"> <?php echo $arrEntry['representative']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Company Name:</td> <td style="padding: 5px;"> <a href="prospect.php?prospect_id=<?php echo $arrEntry['prospect_id']; ?>"><?php echo $arrEntry['company_name']; ?></a> </td> </tr> <tr> <td width="10"></td> <td width="300">Phone Number:</td> <td style="padding: 5px;"> <?php echo $arrEntry['phone']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">First Name:</td> <td style="padding: 5px;"><?php echo $arrEntry['firstname']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Last Name:</td> <td style="padding: 5px;"> <?php echo $arrEntry['lastname']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Last Contacted:</td> <td style="padding: 5px;"> <?php echo $arrEntry['last_contact']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Comments:</td> <td style="padding: 5px;"> <?php echo $arrEntry['comments']; ?> </td> </tr> </table> <br> <br>
  7. JCBONES: perfect! you fixed my problem with the pages! However for the color thing what I was thinking of I want the whole table for the first record to be 1 color, then the next time it displays for the next record to be a different color. Not the rows. How do I accomplish this? Thanks in advance
  8. Andrew: when trying your code I get the following errors Notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$start, $limit' at line 1 in /home/content/view_prospect.php on line 198 aswell as Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/view_prospect.php on line 199 where as line 198 and 199 are as follows $prospectEntries = mysql_query('SELECT * FROM prospects ORDER BY prospect_id DESC LIMIT $start, $limit') or trigger_error(mysql_error()); while ($prospectEntry = mysql_fetch_array($prospectEntries))
  9. thanks for your responce Andrew however now it still doesnt print right - it just prints the product_id number 1 for the first few records, then 2 for the next few. I want it to print each records information (5 per page) in the table
  10. also, since I posted the whole code I might as well as my 2nd question that I will have once this problem gets fixed - as you can see I have my table which shows different info per row - I want it so that every 2nd row the table has a different color bg so its easy on the eyes - how is this accomplished?? thanks again
  11. hey guys....I have included my whole script below....what im trying to do is show 5 results per page. Ive created a function to display a table with information from my database. I have it so either a) it works but displays all the results from my database on the page or b) the pagination works, displays 5 results per page, however it only shows the last record in my database. I have included the full code, but will highlight the part that I think is causing the problem. Any help is much appreciated. Thanks in advance <html> <head> </head> <body> <?php // Define db details //db details mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or trigger_error(mysql_error()); mysql_select_db(DB_DATABASE) or trigger_error(mysql_error()); $tbl_name="prospects"; //your table name // How many adjacent pages should be shown on each side? $adjacents = 3; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "view_prospect.php"; //your file name (the name of this file) $limit = 5; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $sql = "SELECT prospect_id FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>"; else $pagination.= "<span class=\"disabled\">« previous</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next »</a>"; else $pagination.= "<span class=\"disabled\">next »</span>"; $pagination.= "</div>\n"; } // Create function to display the news entries function print_prospectEntry($arrEntry) { // convert \n linebreaks to HTML formatted <br> breaks $arrEntry['comments'] = str_replace("\n", '<br>', $arrEntry['comments']); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="10"></td> <td width="300">Representative:</td> <td style="padding: 5px;"> <?php echo $arrEntry['representative']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Company Name:</td> <td style="padding: 5px;"> <a href="prospect.php?prospect_id=<?php echo $arrEntry['prospect_id']; ?>"><?php echo $arrEntry['company_name']; ?></a> </td> </tr> <tr> <td width="10"></td> <td width="300">Phone Number:</td> <td style="padding: 5px;"> <?php echo $arrEntry['phone']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">First Name:</td> <td style="padding: 5px;"><?php echo $arrEntry['firstname']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Last Name:</td> <td style="padding: 5px;"> <?php echo $arrEntry['lastname']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Last Contacted:</td> <td style="padding: 5px;"> <?php echo $arrEntry['last_contact']; ?> </td> </tr> <tr> <td width="10"></td> <td width="300">Comments:</td> <td style="padding: 5px;"> <?php echo $arrEntry['comments']; ?> </td> </tr> </table> <br> <br> <?php } // Get all news entries $prospectEntries = mysql_query('SELECT * FROM prospects ORDER BY prospect_id DESC') or trigger_error(mysql_error()); while ($prospectEntry = mysql_fetch_array($prospectEntries)) { //print_prospectEntry($prospectEntry); when printing here it prints all the records while($row = mysql_fetch_array($result)) { // Your while loop here print_prospectEntry($prospectEntry); // when printing here, it does 5 results per page like I want, however it just prints the same record //echo $row; } } ?> <?=$pagination?> </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.