Jump to content

asanti

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by asanti

  1. his is my code for a simple catalog store (no cart and checkout), a listing page that will change the items depending on the category (or subcategory). This is my db structure:
     
    prod_id   Primary   bigint(20) AUTO_INCREMENT   
    user_id   int(11)               
    cat_id    int(11)       
    subcat_id   int(11)     
    prod_titulo   varchar(250)  
    prod_descripcion   varchar(250)

    The file that is currently listing all the products (store.php) has this script:

    $(document).ready(function(){
        $('#listing_store').empty();
            $.ajax({
                url: 'store-app/db_query.php',
                type: 'GET',
                dataType: 'json',
                //data: ,
                success: function(data){
                    for (var i = 0; i < data.length; i++) {
                          var dataHtml = ''
                          + '<div class="col-xs-6 col-md-4 column productbox">'
                                + '<a href="detail.php#' +  + data[i].id +'">'
                                + '</a>'
                                + '<div class="product-info">'
                                + ' <div class="product-title"><a href="detalle_producto.php#' +  + data[i].id +'">' + data[i].titulo + '</a></div>'
                                + '<div class="product-price">'
                                + '<div class="pull-right"><a href="detalle_producto.php#' +  + data[i].id +'" class="btn btn-info btn-sm" role="button">Ver</a></div>'
                                + '<div class="pricetext">$'+ data[i].precio + '</div></div>'
                                + '</div>'
                          + '</div>'
                        $('#listing_store').append(dataHtml);
                    }
                }
            });
    });

    As a result i have the product listed in the listing page. the anchor link for the products to the detail page (detail.php):

    <a href="detail.php#' +  + data[i].id +'"></a>

    This is the script i have in the detail.php page:

    $(document).ready(function() {
        if(window.location.hash){
            var id = window.location.hash.substring(1);
            $('#title').html('cargando...');
            $('#desc').html('cargando...');
        }
        LoadProduct(id);
    });
    function LoadProduct(id){
        $.ajax({
            url: 'store-app/db_query.php',
            type: 'POST',
            dataType: 'json',
            data: {
                "q": id,
            },  
        }).done(function(aviso){
            var id = aviso.id;
            $('#title').html(aviso.titulo);
            $('#desc').html(aviso.descripcion);
        });
    }
    }); 
    The product loads ok but the url is
    mysite/detail.php#1 -> prod_id

    Finally, the db query file (db_query.php):

    $sql = mysqli_query($dbc, "SELECT * FROM tienda_prod WHERE prod_activo ='1' ORDER BY prod_fechacreado DESC");
    $results = array();
    while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ 
        $results[] = array(
            'id' => $row["prod_id"], // or smth like $row["video_title"] for title
            'user' => $row["user_id"],
            'categoria' => $row["cat_id"],
            'subcategoria' => $row["subcat_id"],
            'titulo' => $row["prod_titulo"],
            'descripcion' => $row["prod_descripcion"],
        );    
    }
    header('Content-Type: application/json');
    if (isset($_REQUEST["q"])) {
        $busqueda = $_REQUEST["q"];
        $clave = array_search( $busqueda , array_column($results, 'id') );
        echo json_encode( $results[ $clave ] );
    
    } else {
        echo json_encode( $results );
    
    }
    What can i do to change product url's to be more friendly/clean:
    mystore.com/detail.php#1

    to

    mystore.com/(category or subcategory name)/(product title + id)
    Ex. mystore.com/electric-guitars/fender-telecaster-1
    Aclaration: I have other two tables in the db for subcategories and categorias, both with id and name, the product table has both category and subcategory id.
  2. I'm currently runing an classifieds ads site, Php + Mysql (no frameworks) Basically i have the ads listing page (ads.php) and the ads details page (ad_detail.php)


    This is my current .htaccess:



    # disable directory browsing
    Options All -Indexes

    ErrorDocument 400 /error.php
    ErrorDocument 401 /error.php
    ErrorDocument 403 /error.php
    ErrorDocument 404 /error.php
    ErrorDocument 500 /error.php
    ErrorDocument 502 /error.php
    ErrorDocument 504 /error.php

    RewriteEngine on

    RewriteRule ^(.*)-da([0-9]+)$ ad_detail.php?ad=$2
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC,L]

    RewriteRule ^([^\.]+)$ $1.php [NC,L]

    The final result is something like this:


    www.mysite.com/this-is-the-ad-detail-da50555 (the number is the ad id)


     


    What i need is to get this:


    www.mysite.com/ads/another-ad-detail-da50777


    +


    What can i do in others urls to show like www.mysite.com/about/ instead of www.mysite.com/about (without the /)


     


     


    I already tried this but doesn't work:



    RewriteEngine on
    RewriteBase /

    RewriteRule -da([0-9]+)/?$ ad_detail.php?ad=$1 [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
    RewriteRule ^(.+?)/?$ $1.php [L]
  3. I'm currently have this code (part of code):

    if (strlen($trimmed['title']) > 3 && strlen($trimmed['title']) < 200) {
            $title = mysqli_real_escape_string($dbc, $trimmed['title']);
        } else {
            echo '<div class="alert alert-danger" id="alerta3">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <center><p>Error</p></center>
                     </div>';
            $errors=true;
        }
    
        
        if (strlen($trimmed['description']) > 3 && strlen($trimmed['description']) < 4000) {
            $description = mysqli_real_escape_string($dbc, $trimmed['description']);
        } else {
            echo '<div class="alert alert-danger" id="alerta4">
                    <button type="button" class="close" data-dismiss="alert">×</button>
                    <center><p>Error</p></center>
                     </div>';
            $errors=true;
        }
    

    What should i modify to avoid texts with /n/r?

    Thanks

  4. Hi,

    I want to use an external rss in my site but the problem is that i only want to grab feeds that contain certain keywords in the title,

     

    This is what i got so far to display the feed:

    <?php
    
    $html = "";
    $url = "http://www.feedsite.com/conv-rss.asp";
    $xml = simplexml_load_file($url);
    
    for($i = 0; $i < 5; $i++){
    
    	$title = $xml->channel->item[$i]->title;
    	$link = $xml->channel->item[$i]->link;
    	$description = $xml->channel->item[$i]->description;
    	$pubDate = $xml->channel->item[$i]->pubDate;
    
    	$html .= "<a href='$link'><h3>$title</h3></a>";
    	$html .= "$description";
    	$html .= "<br />$pubDate<hr />";
    
    }
    echo $html;
    ?>
    

    The feed is a classified jobs but i only need the jobs listed for musicians, keywords could be: bassist, singer, drummer, musician, etc.. 

     

    Thanks

  5. I'm currently running a classified ads site and planning to display my own content from database combined with and external site rss. So here is what i got right now after the db query for the jobs ads (procedural php),



    while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){


    echo '<div class="media margin-none">
    <a class="pull-left bg-inverse innerAll text-center" href="#"><img src="'.$foto.'" share_alt="" width="100" height="100"></a>
    <div class="media-body innerAll">
    <h4 class="media-heading innerT">
    <a href="' . $row['title'] .'-da' . $row['id_ad'] . '" class="text-inverse">'. $remuneracion .'   ' . substr(ucfirst(strtolower($row['title'])), 0, 53) . '</a> <small class="pull-right label label-default"><i class="fa fa-fw fa-calendar-o"></i> ' . $row['date_created'] . '</small></h4>
    <p>' . substr(ucfirst(strtolower($row['description'])), 0, 80) . ' ...</p>';

    echo '</div>
    </div>
    <div class="col-separator-h"></div>';
    }

    echo pagination($statement,$per_page,$page, $url_filtros, $filtros);
    ?>

    it is the while loop that i use to display ads from my database, what could be the best way to display (in this same loop?) other site's rss feed so i can show my content combined with the external rss?


    Thanks


  6. Also, depending on the number of users you want to send emails to, you should check the possibility to use an external newsletter service. You'll need to pay for it, but it will be more reliable. If you send a lot of email from a single web mail server, you could get 'banned' from gmail, yahoo, etc... And some of your emails could end up in the spam directory more easily than if you use a mailing service. Just my 2 cents ;)

     

    I was going to ask about that :tease-03: , i currently have 2600 users, what service do you recommend me? or by doing what requinix shares its ok?

  7. I have jobs portal where registered users posts new jobs searches

    This weekly newsletter will send all the jobs posted in the site (in a week) to the registered users but in a more personalized way: For example, posted jobs looking for designers should be sent to users registered as designers.

    what is the best way to do this? any recommendations? Thanks in advance.

     

  8. I have this 3 tables


    • users (id_user)
    • music_styles (id_style, style) ex. (1) - (Blues)
    • user_styles (id_user, id_style)

    I'm trying to create a form in which the user ($user = $_SESSION['id_user']) chooses through a multiple select the styles of preference to store them in the database using mysqli statements.


    If the styles prefered are selected they should be displayed in the select input later, how can i accomplish 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.