Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. You can't figure out why?..... just look your $info variable and the what is printing.... what do you think is happening?

    Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.

    Staying true to your signature I see

     

    Back on the topic...

    Take a look at

    $info = "this is a "testing" comment";

     

    the quotations in "testing" are closing the original quotations around the string and so only "this is a " is being echoed

     

    check out this tutorial

    and then look at this

  2. are the services, about us and contact buttons echoed?

     

    It seems your for loop is not executing, try putting this and see if any errors are echoed.

    $h1 = mysqli_query($cxn, "SELECT areaID, area FROM area ORDER BY areaID") OR die(mysqli_error($cxn));
    

     

  3. you'll have to play around with it yourself, this is the basic fundamentals though you'll need to modify it all to fit your database setup etc.

    if (isset($_POST['imageSearch']))
    {
    $searchTerm = $_POST['imageSearch'];
    
    $sql = @mysql_query("SELECT imageTitle, description, filename FROM images WHERE imageTitle LIKE '%$searchTerm%' OR description LIKE '%$searchTerm%'");
    
    while ($row = mysql_fetch_array($sql))
    {
    echo "<p><a href='imagesLocation/{$row['imageLocation']}'>{$row['imageTitle']}</a></p>";
    }
    }
    

  4. I would steer clear of your current code, looks like quite a convoluted solution.

     

    It isn't a complex problem, re-write that block of code with time stored as unix timecodes and strtotime. Much easier to use unix timecodes when dealing with times, then you can have something along the lines of

    echo date("g:i a", $unixTimeCode);
    

    which will echo hours:minutes AM/PM

  5. I'm assuming this function you're calling returns true or false depending if login credentials correct / incorrect.

    You should set the username into the session if this login attempt is successful

     

    //in your first file
    
    // Did the user enter a password/username and click submit?
    if($_POST && !empty($_POST['username']) && !empty($_POST['pwd'])) {
       $response = $membership->validate_User($_POST['username'], $_POST['pwd']);
    
    if ($response == true)
    {
    $_SESSION['username'] = $_POST['username'];
    }
    }
    

  6. You should have an image filename stored in the database, in the same row that has the image descriptions, image name, image title and other details.

    Then when a user searches for a image, you have a situation like so:

     

    1. Set up database so rows store imagename, image description, image title and most importantly FILENAME.

    2. You create a HTML search page which posts to a PHP page, with search box input named "imageSearch"

    3. The PHP page is set up something like so

    if (isset($_POST['imageSearch']))
    {
    $searchTerm = $_POST['imageSearch'];
    
    $sql = @mysql_query("SELECT imageTitle, description, filename FROM images WHERE imageTitle LIKE '%$searchTerm%' OR description LIKE '%$searchTerm'");
    
    while ($row = mysql_fetch_array($sql))
    {
    echo "<p><h1>{$row['imageTitle']}</h1><br/>
    {$row['description']}<br/>
    <img src='imagesFolder/{$row['filename']' />
    </p>"
    }
    }
    

     

    You can modify it if you want it to return thumbnails, links to the photos etc. That is the basic fundamentals though, you would be able to adapt the PHP Freaks tutorial you mentioned earlier to suit your needs also.

  7. are your images stored as files or as binary data in the database?

    you can use a similar search which searches through the image data in the database, i.e. keywords, tags, descriptions regarding the images.

  8. /* and // are to comment out text in a PHP file, commenting out in PHP and HTML files is completely different.

    the commenting out you posted was correct for html:

    <!-- IF not S_DISPLAY_RECENT -->
        <!-- INCLUDE portal/block/recent.html -->
    <!-- ENDIF -->

     

    Although I don't see what you're trying to do? HTML hasn't the ability to process IF and INCLUDE statements...

  9. Because you are putting the variables inside SINGLE quotes and it is taking those values as text, not a reference to a variable

    $array = array('$test', '$salt_string');

     

    Remove the quotes around the variables.

  10. hmm, this is true.

    you'll have to leave the zipcode class as it was, with the distances.

    Then use a foreach loop to create the SQL IN part,

    And then since the zip field type in your database is Varchar, you should have this set to integer. an sql statement where the field is varchar will look for an exact match, and your zipclass adds a 0 infront of any zips which are less than 5 characters in length. If the field is of integer type it will ignore this 0 as 0120 is the same as 120, although a string "0120" is not the same as "120", hence if you leave the field type as varchar the sql query will not pick up zip code 1343 being IN (01343). The other option is to turn off the padding in the zipClass, I'd recommend you change your zip code field type for your table to Integer.

    
    $z = new zipcode_class;
    //this will sort zips by distance, ascending.
    $zips = $z->get_zips_in_range($zip, 10, 1, true);
    
    //for sql, implode with ', ' to seperate zips.
    
    $sqlZIPS = '';
    foreach ($zips as $key => $value) {
          //SQL STRING YOU CAN REMOVE single quote around $value if values are all numbers
    $sqlZIPS .= "$key, ";
       }
    
    //now do search with that
    mysql_select_db($database_connDB2, $connDB2);
    exit("SELECT subcategories.subcategory, subcategories.cat_id, advertisers.adv_id, advertisers.zip_code, couponinfo.coupon_id FROM subcategories, advertisers, couponinfo WHERE (subcategories.subcat_id = advertisers.subcat_id OR subcategories.subcat_id = advertisers.subcat_id2) AND (advertisers.adv_id = couponinfo.adv_id) AND (advertisers.zip_code IN ($sqlZIPS)) ORDER BY subcategories.subcategory");
    
    

  11. ok, ensure $return is '$return[] = $row[0]:", the other array is filled with distances.

    And as you can see, they are sorted by distance, ascending.

     

    Now this isn't returning any results in your query? what field type is the column storing the zips in the advertisers table?

  12. hmm

    try this, and tell me what is echoed.

    $z = new zipcode_class;
    //this will sort zips by distance, ascending.
    $zips = $z->get_zips_in_range($zip, 10, 1, true);
    
    //for sql, implode with ', ' to seperate zips.
    $sqlZIPS = implode(", ", $zips);
    
    print_r($zips);
    echo "<br/><br/>" . $sqlZIPS . "<br/><br/>";
    
    //now do search with that
    mysql_select_db($database_connDB2, $connDB2);
    exit("SELECT subcategories.subcategory, subcategories.cat_id, advertisers.adv_id, advertisers.zip_code, couponinfo.coupon_id FROM subcategories, advertisers, couponinfo WHERE (subcategories.subcat_id = advertisers.subcat_id OR subcategories.subcat_id = advertisers.subcat_id2) AND (advertisers.adv_id = couponinfo.adv_id) AND (advertisers.zip_code IN ($sqlZIPS)) ORDER BY subcategories.subcategory");
    

  13. hmm that would mean the function is no longer passing back an array because I didn't look at the function carefully enough and was trying to pass a constant to the function instead of an integer

    I had another look at and the zipclass defines some constants for sorting, and you have to call a constant in the function by using the respective value / integer.

    i.e.

    // constants for passing $sort to get_zips_in_range()
    define('_ZIPS_SORT_BY_DISTANCE_ASC', 1);
    define('_ZIPS_SORT_BY_DISTANCE_DESC', 2);
    define('_ZIPS_SORT_BY_ZIP_ASC', 3);
    define('_ZIPS_SORT_BY_ZIP_DESC', 4);
    

     

    $zips = $z->get_zips_in_range($zip, 10, 1, true); would be sort by distance, ascending.

    $zips = $z->get_zips_in_range($zip, 10, 2, true); would be sort by distance descending,

    $zips = $z->get_zips_in_range($zip, 10, 3, true); would be sort by zip ascending

    $zips = $z->get_zips_in_range($zip, 10, 4, true); would be sort by zip descending

     

    $z = new zipcode_class;
    //this will sort zips by distance, ascending.
    $zips = $z->get_zips_in_range($zip, 10, 1, true);
    
    //for sql, implode with ', ' to seperate zips.
    $sqlZIPS = implode(", ", $zips);
    
    //now do search with that
    mysql_select_db($database_connDB2, $connDB2);
    $query_getCat = ("SELECT subcategories.subcategory, subcategories.cat_id, advertisers.adv_id, advertisers.zip_code, couponinfo.coupon_id FROM subcategories, advertisers, couponinfo WHERE (subcategories.subcat_id = advertisers.subcat_id OR subcategories.subcat_id = advertisers.subcat_id2) AND (advertisers.adv_id = couponinfo.adv_id) AND (advertisers.zip_code IN ($sqlZIPS)) ORDER BY subcategories.subcategory");
    $getCat = mysql_query($query_getCat, $connDB2) or die(mysql_error());
    

  14. use the sort function

     

    $z = new zipcode_class;
    $zips = $z->get_zips_in_range($zip, 10, _ZIPS_SORT_BY_DISTANCE_ASC, true);
    
    //sort the array
    sort($zips);
    
    //for sql, implode with ', ' to seperate zips.
    $sqlZIPS = implode(", ", $zips);
    
    //now do search with that
    mysql_select_db($database_connDB2, $connDB2);
    $query_getCat = ("SELECT subcategories.subcategory, subcategories.cat_id, advertisers.adv_id, advertisers.zip_code, couponinfo.coupon_id FROM subcategories, advertisers, couponinfo WHERE (subcategories.subcat_id = advertisers.subcat_id OR subcategories.subcat_id = advertisers.subcat_id2) AND (advertisers.adv_id = couponinfo.adv_id) AND (advertisers.zip_code IN ($sqlZIPS)) ORDER BY subcategories.subcategory");
    $getCat = mysql_query($query_getCat, $connDB2) or die(mysql_error());
    

  15. yes I looked at the zipcode class file,

     

    In the file, the line which structures the details returned is

    $return[str_pad($row[0], 5, "0", STR_PAD_LEFT)] = round($dist, $this->decimals);

    in the "function get_zips_in_range(".

     

    It is returning an array with an index of the zip with "0" added infront. i.e. 2343 would be $array[02343], and then the distance as the value.

     

    If you just want the zips and not the distance, I would change this to

    $return[] = $row[0];

    Then the function will return an array with all your zips in range, then to use it in mysql you will have to implode that array like so

    $z = new zipcode_class;
    $zips = $z->get_zips_in_range($zip, 10, _ZIPS_SORT_BY_DISTANCE_ASC, true);
    
    //for sql, implode with ', ' to seperate zips.
    $sqlZIPS = implode(", ", $zips);
    
    //now do search with that
    mysql_select_db($database_connDB2, $connDB2);
    $query_getCat = ("SELECT subcategories.subcategory, subcategories.cat_id, advertisers.adv_id, advertisers.zip_code, couponinfo.coupon_id FROM subcategories, advertisers, couponinfo WHERE (subcategories.subcat_id = advertisers.subcat_id OR subcategories.subcat_id = advertisers.subcat_id2) AND (advertisers.adv_id = couponinfo.adv_id) AND (advertisers.zip_code IN ($sqlZIPS)) ORDER BY subcategories.subcategory");
    $getCat = mysql_query($query_getCat, $connDB2) or die(mysql_error());
    

  16. did you edit that code to do something with the database query results... at the end where I wrote "now do something with the query."?

     

    You can put this at the end and echo all the results, it will only echo all the rows returned from the database, what you do with the information returned from database is up to you.

    $i = 0;
    while ($row=mysql_fetch_array($getCat))
    {
    echo "<b>Row $i.</b><br/>";
    $i++;
    print_r($row);
    }
    

  17. thats because you have no PHP code triggered if act = editdo, and so it is triggering the default "else" statement which is the team names "Click Team Names to view players" etc etc.

     

    You need to add a block of code which handles your editdo function and updates the database.

    you'll need to add an if statement

    i.e. insert another elseif before the last else.

    etc
    etc
    etc
    } else if ($act == 'editdo') {
    exit("EDIT DO, rara, get posted values and update database etc etc. You'll have to code this part to perform the function you want.");
    } else {
    echo ("Click Team Names to view players<br><br>");
    etc
    etc
    etc
    

    the etc etc etc signifies other blocks of your code.

×
×
  • 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.