SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Senior Webdesigner koolbrian's Avatar
    Join Date
    Dec 2000
    Location
    Mauritius
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey,
    i have a site which i have to update. I've recently learned a bit of php. normally i must update it by putting a new script frequently. Have a look
    <!-- Code -->
    <SCRIPT>singleLeftLink(1555805,"areacool.vstorestuff.com");</SCRIPT>
    <!-- Code -->


    I have to change this code frequently to change products ID.To prevent me from re- and then re-uploda it, (time also), i would like to know if i could put an html code in a table. Would it be generated ???


    Brian
    BrianStudio - the webdesign company
    Professional & Affordable
    Brian Dove - Senior Graphic Designer
    Direct Hire: info@brianstudio.com

  2. #2
    Senior Webdesigner koolbrian's Avatar
    Join Date
    Dec 2000
    Location
    Mauritius
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey i just thought of something!,
    if i need to change only the product's ID. Can't it be with a relation with a variable and value?


    Brian
    BrianStudio - the webdesign company
    Professional & Affordable
    Brian Dove - Senior Graphic Designer
    Direct Hire: info@brianstudio.com

  3. #3
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    All you would need is the company ID number and their site address....

    You would dynamically generate it like so..

    PHP Code:
    <!-- Code --> 
    <SCRIPT>singleLeftLink(<? print $userId?>, "<?print $address?>");</SCRIPT> 
    <!-- Code -->

  4. #4
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the record there's no reason you can't store HTML code in a database - just stick the HTMl in a "text" field in mySQL.

  5. #5
    Senior Webdesigner koolbrian's Avatar
    Join Date
    Dec 2000
    Location
    Mauritius
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but where will the product Id (it's not userID) and companies address will come from?, from a url query string?, but where will the url query string come from???, also, can i put a dot (.) in a variable.Will it be acceptable as a character or something else? i also thought of something for automatically update it. Can't it have something in relation with the date?
    i've just tried this script out, just to have an idea of the stuff!,please CORRECT ME
    http://www.cool.com?polldate=(date for poll to update)02032001
    <?php
    $date= mysql_query("Curdate()")

    if ($date=$polldate) {
    echo ( "htmlcode of poll" );

    }


    If ($poll=$polldate + (day or month, is it possible to add a day?) 1) {

    echo ( "the html code for the other poll)

    ?>

    etc....



    sorry for the "bad" code, (i'm a newbie!),
    is that an idea that can work?

    Brian
    BrianStudio - the webdesign company
    Professional & Affordable
    Brian Dove - Senior Graphic Designer
    Direct Hire: info@brianstudio.com

  6. #6
    Senior Webdesigner koolbrian's Avatar
    Join Date
    Dec 2000
    Location
    Mauritius
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could someone please help me ?

    Brian
    BrianStudio - the webdesign company
    Professional & Affordable
    Brian Dove - Senior Graphic Designer
    Direct Hire: info@brianstudio.com

  7. #7
    SitePoint Zealot DarkMonkey's Avatar
    Join Date
    Apr 2001
    Location
    uk
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to display one product, you would surely want to let your users select a product from a list, that list would be links with each id in, if you wanted to force a page upon them... you could add it yourself I guess. If you wanted to display all the products at once, there would be no need for the unique id. At least on the page of them all, thus no need for any kind of variables in the url.

  8. #8
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Have a form where the user selects the company and then use a Query to go through a database to find the company that they want..... then output it

  9. #9
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The best place to start is in correcting the last bit of code you just posted. Hopefully this will help you with some of the principles of php.

    Firstly, it is always better to use a timestamp to compare between different dates. This is because it is easier to perform maths (such as working out if today is the same as the poll date plus one day). A timestamp is a number which represents the time and date as the number of seconds since midnight January 1, 1970. I will show some code below that demonstrates this. There are functions in PHP that will turn a timestamp into a user friendly time/date representation if you want to print out the time or date.

    Secondly, it is not necessary to query the database to find out the current date or time. There are PHP functions that can do this (which are more efficient).

    Thirdly, in PHP there writing
    if ($date=$polldate)
    is not going to do what you think it is doing. There is a special operator in PHP "==" which we use when we want to compare to values to see if they are the same or not. Eg,
    if ($date == $polldate)

    OK, so lets look at some code:
    PHP Code:
    // assign the timestamp for midnight lastnight to $today
    // that is to say, assign a timestamp that represents today's date
    // and 0 hours, 0 minutes and 0 seconds.
    $today mktime000date("m"), date("d"), date("Y") );

    // now we will create a timestamp from
    // the $polldate (which was recieved in the URL)
    // I'm assuming that we are using the American
    // date format and that 02032001 is 03 February 2001

    // first we need to extract the month, day and year values
    // out of $polldate
    $month substr($polldate02);
    $day substr($polldate22);
    $year substr($polldate44);

    // now make the timestamp
    $polltime mktime(000$month$day$year);

    // whew! now we can compare the two timestamps
    // which are both set for midnight
    if ( $today == $polldate ) {
       
    // echo the code for the  poll
    }

    // now because our timestamps are in seconds,
    // to add a day we can simply represent this in seconds
    // and add it on:
    // 60 seconds to a minute,
    // 60 minutes to an hour,
    // 24 hours in a day,
    // 1 day = 60*60*24 seconds

    if ( $poll == ($polldate + (60*60*24)) ) {
       
    // echo the code for the other poll

    What I did above is by no means the only way to go about it. In fact, I wonder whether it is the most efficient. Others may have a better way of coding that logic.

    As for your first query, while the other posts have given you a good direction of what you should/could do, you need to explain more specifically what you are doing and then you will receive better advice for how to generate the code.

  10. #10
    Senior Webdesigner koolbrian's Avatar
    Join Date
    Dec 2000
    Location
    Mauritius
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok,i'll try my best to explain you what i want.
    I need a script to automatically change the poll to a next poll, after some time (2 weeks for exemple!). the first poll's html is as follows (the one which i need to change after 2 weeks) :

    TO REDUCE SIZE:
    <html> <p>poll 1 , WHO is your pet? </p></html>


    The second one (that need to be seen after 2 weeks)

    <html> <p> poll 2, Where id your brain? </p> </html>


    could i please get the code for the first poll to change to the second poll after 2 weeks??????


    Now my second problem is the shop stuff. I must update the "cool stuff in shop" , which contains a SHORt description of a product, and a photo. The html for me to change the product is as follows:

    <!-- Code -->
    <SCRIPT>singleLeftLink(1555805,"areacool.vstorestuff.com");</SCRIPT>
    <!-- Code -->


    where the numbers 1555805 is the product id and the "areacool.vstorestuff.com" is the url.
    How to update this every 2 week. (same as the first one).
    I mean i put MANY products' id in a <?php ?> and then, it automatically changes every 2 weeks!, HOPE u understood, if not, tell me to re-explain you, i'll do it with pleisure, cause i really need this help!

    Brian
    BrianStudio - the webdesign company
    Professional & Affordable
    Brian Dove - Senior Graphic Designer
    Direct Hire: info@brianstudio.com

  11. #11
    Senior Webdesigner koolbrian's Avatar
    Join Date
    Dec 2000
    Location
    Mauritius
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, another small question ( with no relation with the thread context) , how to send an email to MANY addresses, people ???, must seperate each address with a comma ? or a ; , ??/

    Brian
    BrianStudio - the webdesign company
    Professional & Affordable
    Brian Dove - Senior Graphic Designer
    Direct Hire: info@brianstudio.com

  12. #12
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This last question is covered in the PHP Manual. http://www.php.net/mail
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •