Jump to content

hane

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Everything posted by hane

  1. Thanks works great. This is just for my own use but will remember for next time. I know, but this wasn't supposed to have been a date field because is just the publication month. But I have learned my lesson and when ever I will have to use a date like field again I will use date
  2. I'm wondering if there is away to do it with php date format M. I dont seem to find anything. That's why I'm posting here
  3. I have a mysql table ads that has the following structure. The table is for display purposes only <table border="1"> <tr> <th>adid - int(11)</th> <th>month - varchar(255)</th> <th>size - varchar(255)</th> <th>amount - varchar(255)</th> <th>companyid - int(11)</th> <th>price - varchar(255)</th> <th>description - varchar(255)</th> <th>year - varchar(225)</th> <th>paid - date</th> <th>cpaid - date</th> <th>done - int(11)</th> </tr> <tr> <td>1</td> <td>Jan</td> <td>1/2 Page</td> <td>1</td> <td>1</td> <td>3950</td> <td>Ad in dropbox</td> <td>2012</td> <td>2012-03-06</td> <td>2012-04-30</td> <td>1</td> </tr> <tr> <td>2</td> <td>Feb</td> <td>1/2 Page</td> <td>1</td> <td>1</td> <td>3950</td> <td>Ad in dropbox</td> <td>2012</td> <td>0000-00-00</td> <td>0000-00-00</td> <td>1</td> </tr> </table> I have the following query $query_ads = "SELECT * FROM ads INNER JOIN company ON company.companyid=ads.companyid WHERE paid='0000-00-00' AND ads.year = YEAR(CURRENT_DATE) ORDER BY FIELD(month,'Jan','Feb','March','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'), name "; I want to limit the the results to all the records form the beginning of the year to the current month. Is it possible with the structure as is or would I have to change month to a date value Any help would be appreciated. Thanks Hanè
  4. Think I found a better way: $n= $row_ads['name']; $na= preg_replace('/\s*/m','',$n); $vExcelFileName= $na ."-ad-description-" . $row_ads['month'] . "-10" . ".doc";
  5. Please tell me if there is a better way
  6. I fixed it with urlencode.
  7. the easies would be to show you Go to http://www.hefty.co.za/agrisales/ Select Excaload from drop down submit then select PDF to see working example Select AIP Africa from drop down submit then select PDF to see problem
  8. remember i call the info from my mysql database so I select AIP Africa from drop down then I select export and it exports all the info to a .doc file with the name populated with my the script in question
  9. When I run the code for Company lets say AIP Africa for June the file name is supposed to be: aipafrica-ad-description-jun-10.doc what I get is AIP
  10. I have checked the code and it works, but when a name has spaces it falls apart how can I fix that Here is the problem: $vExcelFileName=$row_ads['name'] . "ad-description-" . $row_ads['month'] ."-10" . ".doc";
  11. Hi for some reason I just cant get my code to work. Please take a look and help me in the right direction. Here is my header builder for my export doc, $vExcelFileName is my problem: <?php require_once('includes/connect.php'); $adid=$_GET['adid']; mysql_select_db($database_A, $A); $query_ads = "SELECT * FROM ads JOIN company ON ads.companyid=company.companyid JOIN contact ON contact.companyid=ads.companyid WHERE adid=$adid"; $ads = mysql_query($query_ads, $A) or die(mysql_error()); $row_ads = mysql_fetch_assoc($ads); $totalRows_ads = mysql_num_rows($ads); $vExcelFileName=$row_ads['name'] . "ad-description-" . $row_ads['month'] ."-10" . ".doc"; header("Content-type: application/x-ms-download"); //#-- build header to download the excel file header("Content-Disposition: attachment; filename=$vExcelFileName"); header('Cache-Control: public'); ?> I'm sure its something silly that I'm not seeing and just need someone else to point it out
  12. OK found the problem. IE doesn't like having no background specified in the css. Sure there is a better way to solve it but hi its working.
  13. I need some help please. I dont know Jscript, and I cant seem to figure out how to fix my problem. I have a dropdown that works in Firefox. In IE when I move between the dropdown options the menu goes out. Here you can look at the website http://www.africanskyjewellery.co.za/ Here is my code ....... <script type="text/javascript"> startList = function() { if (document.all&&document.getElementById) { navRoot = document.getElementById("nav"); for (i=0; i<navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName=="LI") { node.onmouseover=function() { this.className+=" over"; } node.onmouseout=function() { this.className=this.className.replace(" over", ""); } } } } } window.onload=startList; </script> ..... ..... <ul id="nav"> <li><a href="index.php"><img src="images/home.gif" alt=""></a> <ul> <li><a href="about_us.php"><img src="images/about_us.gif" alt="about us"></a></li> <li><a href="contact_us.php"><img src="images/contact_us.gif" alt="contact us"></a></li> <li><a href="friends.php"><img src="images/friends.gif" alt="contact us"></a></li> </ul> </li> <li><a href=""><img src="images/jewellery.gif" alt=""></a> <ul> <li><a href="jewellery.php?cat=1"><img src="images/rings.gif" alt="rings"></a></li> <li><a href="jewellery.php?cat=2"><img src="images/bracelets.gif" alt="bracelets"></a></li> <li><a href="jewellery.php?cat=3"><img src="images/earrings.gif" alt="earrings"></a></li> <li><a href="jewellery.php?cat=4"><img src="images/pendants.gif" alt="pendants"></a></li> <li><a href="jewellery.php?cat=5"><img src="images/mens_rings.gif" alt="mens rings"></a></li> <li><a href="jewellery.php?cat=6"><img src="images/exclusive_designs.gif" alt="exclusive design"></a></li> </ul> </li> <li><a href="birth_stone.php?month=3"><img src="images/birth_stone.gif" alt=""></a></li> <li><a href=""><img src="images/special_occasion.gif"></a> <ul> <li><a href="occasion.php?cat=1"><img src="images/weddings.gif" alt=""></a></li> <li><a href="occasion.php?cat=2"><img src="images/anniversaries.gif" alt=""></a></li> <li><a href="occasion.php?cat=3"><img src="images/gifts.gif" alt=""></a></li> </ul> </li> <li><a href="specials.php"><img src="images/specials.gif" alt=""></a></li> <li><a href=""><img src="images/news.gif" alt=""></a> <ul> <li><a href="subscribe.php"><img src="images/newsletter.gif" alt="newsletter"></a></li> <li><a href="events.php"><img src="images/evets.gif" alt="events"></a></li> </ul> </li> </ul> ...... Please help
  14. I got it, thanks for your help. The $id wat empty as I wasnt posting it from my form. Thanks again
  15. It doenst upload the filename to the database and it doesnt give me an error
  16. the file name must be there because after the upload it must show me the image by using the $filename and it does. And also it works on my local host
  17. Nope not working
  18. the file gets loaded, the name just isn't being written to the database
  19. Hi I need some help please I got an image upload code that loads the image to the folder and stores the filename in a mysql database. Now it works 100% when I run the code locally with XAMPP but it doesnt update the record in mysql when I do it on my webserver. Here is my action code: <?php $uploadDir = '../excaload/foto/'; $id=$_POST["id"]; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } $con = mysql_connect("xxxxxxx","xxxxxxx","xxxxxx"); if (!$con) { die('Error connecting to database'); } mysql_select_db("xxxxx", $con); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } mysql_query("UPDATE c_listing SET image ='" . "$fileName" . "' WHERE c_listing_id ='" . "$id" . "' "); mysql_close($con); echo "<img src='../excaload/foto/" . "$fileName" . "' alt='' width='300'/>"; } ?> I just need someone else to look at the code because I've been going through it over and over and I'm missing it. All the rest of my insert and update statements on the website work. Thanks for having a look
  20. I've got it here is the code <?php //set the number of columns $columns = 3; $query = "SELECT * FROM africanskyjewellery_items"; $result = mysql_query($query); //we add this line because we need to know the number of rows $num_rows = mysql_num_rows($result); echo "<table summary='' border='0' width='100%'>\n"; //changed this to a for loop so we can use the number of rows for($i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_array($result); if($i % $columns == 0) { //if there is no remainder, we want to start a new row echo "<tr>\n"; } echo "<td colspan='2'>"; echo "<img src='images/" . $row['africanskyjewellery_items_ref'] . ".jpg' width='150'></a><br />"; echo "<b>Ref:</b>". $row['africanskyjewellery_items_ref'] ."<br />"; echo "<b>Price:</b>R" . $row['africanskyjewellery_items_price'] . "<br />"; echo "</td>\n"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) { //if there is a remainder of 1, end the row //or if there is nothing left in our result set, end the row echo "</tr>\n"; } } echo "</table>\n"; ?>
  21. Attached is an eg. of how I want to display info that i get from my mysql database. If you can just point me in the right direction I would really appreciated it. [attachment deleted by admin]
  22. Sorry I just neded $start=$_GET['start']; // To take care global variable if OFF if(!($start > 0)) { // This variable is set to zero for the first page $start = 0; }
  23. Can someone please look at my code. The paging code does break the records up in 5 per page and it does show me that I have 2 pages when there is 10 records but when I click on page 2 it just shows me page 1 again. <?php // Categories $dat=$_GET['dat']; $cat=$_GET['cat']; $subcat=$_GET['subcat']; $area=$_GET['area']; ?> <?php //Sort BY $selected = array(); $orderby = $_GET[orderby]; if(!$orderby) { $orderby = 'sort'; } if($orderby == 'price_asc') { $orderby_query = "order by c_item_price ASC"; } else if($orderby == 'price_desc') { $orderby_query = "order by c_item_price DESC"; } else { unset($orderby); } // If $orderby was valid set the selected sort option for the form. if($orderby) { $selected[$orderby] = 'selected'; } ?> <?php //Page Limits $eu = ($start - 0); if(!$limit > 0 ){ // if limit value is not available then let us use a default value $limit = 5; // No of records to be shown per page by default. } $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; ?> <?php //Number of records if ($subcat != "1") { $query4="SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE c_subcategory_id=$subcat AND area_id=$area $orderby_query"; $result4=mysql_query($query4); echo mysql_error(); $nume=mysql_num_rows($result4); if ($area !="1") { $query4="SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area $orderby_query"; $result4=mysql_query($query4); echo mysql_error(); $nume=mysql_num_rows($result4); } else { $query4="SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE c_subcategory_id=$subcat $orderby_query"; $result4=mysql_query($query4); echo mysql_error(); $nume=mysql_num_rows($result4); } } else { $query4="SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area $orderby_query"; $result4=mysql_query($query4); echo mysql_error(); $nume=mysql_num_rows($result4); if ($area !="1") { $query4="SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area $orderby_query"; $result4=mysql_query($query4); echo mysql_error(); $nume=mysql_num_rows($result4); } else { $query4="SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id INNER JOIN c_subcategory ON c_listing.c_subcategory_id = c_subcategory.c_subcategory_id WHERE c_category_id=$cat $orderby_query"; $result4=mysql_query($query4); echo mysql_error(); $nume=mysql_num_rows($result4); } } ?> <?php //Query if ($subcat != "1") { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE c_subcategory_id=$subcat AND area_id=$area $orderby_query limit $eu, $limit"); if ($area !="1") { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area $orderby_query limit $eu, $limit"); } else { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE c_subcategory_id=$subcat $orderby_query limit $eu, $limit"); } } else { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area $orderby_query limit $eu, $limit"); if ($area !="1") { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id WHERE area_id=$area $orderby_query limit $eu, $limit"); } else { $result = mysql_query("SELECT * FROM c_listing INNER JOIN c_company ON c_listing.c_company_id = c_company.c_company_id INNER JOIN c_subcategory ON c_listing.c_subcategory_id = c_subcategory.c_subcategory_id WHERE c_category_id=$cat $orderby_query limit $eu, $limit"); } } ?> <?php //Display Results $count=0; while($row = mysql_fetch_array($result)) { echo "<table border='0' width='100%'> "; echo "<tr>"; echo "<td rowspan='4'>"; echo "<a href='classifieds/" . $row['c_item_ref'] . ".jpg'><img src='classifieds/" . $row['c_item_ref'] . ".jpg' width='150'></a>"; echo "</td>"; echo "<th>Description</th>"; echo "<th align='right'>Price: R " . $row['c_item_price'] . "</th>"; echo "<tr>"; echo "<td colspan='2'>" . $row['c_item_description'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'><b>Contact:</b> " . $row['c_company_contact_detail'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'>"; echo "<b>Email: </b>"; echo "<a href='mailto:" . $row['c_company_email'] . "?subject=Listing on Hefty Description: " . $row['c_item_description'] . " Price: R " . $row['c_item_price'] . "'>" . $row['c_company_email'] . "</a></td>"; echo "</tr>"; echo "<tr><td colspan='3' id='break'> </td></tr>"; $count++; } if ($count==0) { echo 'Sorry no record was found.Please search again'; } echo "</table>"; ?> <?php //Paging Numbers echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>"; //// if our variable $back is equal to 0 or more then only we will display the link to move back //////// if($back >=0) { print "<a href='$page_name?cat=$cat&subcat=$subcat&area=$area&start=$back&limit=$limit'><font face='Verdana' size='2'>PREV</font></a>"; } //////////////// Let us display the page links at center. We will not display the current page as a link /////////// echo "</td><td align=center width='30%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href='$page_name?cat=$cat&subcat=$subcat&area=$area&start=$i&limit=$limit'><font face='Verdana' size='2'>$l</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red $l=$l+1; } echo "</td><td align='right' width='30%'>"; ///////////// If we are not in the last page then Next link will be displayed. Here we check that ///// if($this1 < $nume) { print "<a href='$page_name?cat=$cat&subcat=$subcat&area=$area&start=$next&limit=$limit'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td></tr></table>"; mysql_close($con); ?> Thanks very much
  24. Thanks I just came to let you know that I changed the $_POST to $_GET and I'm now just sorting out the kinks
×
×
  • 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.