Jump to content

Interista

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by Interista

  1. Your PHP comparison will not work because gmdate and date or any other get date/time function will always return a string. In order to actually compare them with >'s or <'s you would have to use strtotime() to convert it to an integer. Nonetheless, you can accomplish this much easier in SQL, as I have pointed out in my last post.

     

    I have tried ur way , it works but the only problem with time like that .

    if the restaurant open from 10:00:00 AM to the next day 03:00:00 AM .. :(

  2. :psychic: Give us an example of how you are doing it now...

     

     

    global $currentTime;
    $currentTime = gmdate('G:i:s', time() + (3 * 3600));
    $restTime    = mysql_query("SELECT `r_ofrom` , `r_oto` , `rid` , `r_status` FROM `restaurant` ");
    while ($get_times = mysql_fetch_array($restTime)) {
       $openFrom   = $get_times['r_ofrom'];
       $openTo     = $get_times['r_oto'];
       $restID     = $get_times['rid'];
       $restStatus = $get_times['r_status'];
       if ($currentTime > $openFrom && $currentTime < $openTo) {
           if ($restStatus == 'C')
               mysql_query("update restaurant SET r_status='O' where rid='$restID'");
    
       } else {
           if ($restStatus == 'O')
               mysql_query("update restaurant SET r_status='C' where rid='$restID'");
    
       }
    }

     

    Are you storing the time as VARCHAR instead of TIME fields ?

     

    No not as VARCHAR , I 'm storing the time as TIME . ex 20:00:00

  3. Hello,

     

    I have a restaurants opening times hours stored in MySQL DB for each restaurant as Time . ex 10:00:00 - 22:00:00

    the problem is when I compare 7:30 with 22:30 , 7:30 would be more than 22:30 !

     

    So I want to get current time and compare it with the stored one .

  4. Sorry for not being clear , But the problems that I face is hard to do it in the query for me .

    because I want to sort result after filter it according to category type .

    so as example if I have a 5 rows , and filter it using category type it will be like 3 rows as example .

    How I can sort only the 3 rows not the whole result of the first query .

     

    I hope it's a clear now :$

  5. Hello,

    How I can sort MySQL result .

     

    I have to two selects box , Sort by alphabetical and sort by the categories , the two selects box in the same page .

    How I can filter the result according of the sort type . Like sort the result by specific category and in the same time sort it from Z to A . / DESC

  6. Hello ,

    I got error that said , I got this error only in the first set session , after that the error disappear .

    So as example i send ( cart.php?add=302 ) in URL , And this is what I got :

    Undefined index: cart_302 in C:\wamp\www\cart.php on line [i]9[/i]

     

     

    I'm using session for store my cart info , this is my session create code :

     

     

    if (isset($_GET['add'])){
    $_SESSION['cart_'.$_GET['add']]+='1';
    }
    

  7. That question cannot be answered. The appropriate number of "queries" (or what I think you mean is how much data should be stored) is completely dependent upon the needs of the application. If the needs of the application requires 5 queries or 500 queries then that is what it takes.

     

    To address your specific need, you are wanting to store a user's cart. There are a few different solutions and which one you choose can depend on many factors.

     

    You can use sessions, but they will only persist for the user's session (obviously). This is pretty easy to manager.

     

    You can store the info in cookies, which will persist across sessions. But, if a user saves a cart it would only be available to them on that same pc.

     

    If you want carts to persist across sessions and PCs then you will want to store them in the DB and ties to a user login.

     

    There is no right or wrong method - it depends on which one meets your specific needs. Many sites use several methods.

    Oh OK , great info that will help me for sure .

    Thanks for help :)

  8. Hello ,

    I'm a newbie in PHP but I have tried so much but nth work !

    I want to print out products into categories like this way :

     

    Category 1 :

    1. product 1
       
    2. product 2
       
    3. product 3

    Category 2:

    1. product 5
       
    2. product 7

    and so on ..

     

    This is my code which I'm using :

     

     

    $get_products = mysql_query("select * from ((product join category on cid = p_cid) join restaurant on rid = c_rid) join restaurant_type on rtid = r_rtid
    where rid = '$rest_id' order by rid, c_sortval, p_sortval");
    
    while ($get_productsrows = mysql_fetch_assoc($get_products)) {
    
    
    echo ' <div class="product-box" id="products-box">
    
    <table width="100%;">';
    
    echo '<tr id="'.$get_productsrows['pid'].'" rel="desc" title="' . $get_productsrows['p_desc'] . '" >
    <td style="font-weight: bold;font-size:13px;" ><span class="name">' . $get_productsrows['p_name'] . '</span></td>
    <td style="text-align:center;font-size:11px;" >JD <span class="price">' . $get_productsrows['p_price'] . '+</span></td>
    <td style="text-align:center;"><input type="submit" value="Add" class="btn-add"></td>
    </tr>
    
    
    </table></div>';

     

    This is only print out the all products for all categories for the restaurant ID .

  9. Then you should store the cart info in the database or in SESSION data. But, to answer your question directly you can pass variables from the client to the server using Javascript by performing an AJAX request - which I wouldn't suggest for cart info.

    Hello ,

    I think it's not good to store the cart info in a database ! so much quires .

    is that bad in PHP have much quires ?

     

    Thank u :)

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