This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Can I add a "LIMIT" statement?


  1. rscott7706
    Member

    Following is code that works great for some online newsletters. But, I get one continuous column (year 2006 through 2008) - not useful as is. I would like to break in to year columns.

    Can I add a LIMIT statement to the following code (i.e LIMIT 1, 12):

    $query = "select
    A.*,
    B.option as month,
    C.option as year
    from
    (ap_form_4 as A
    left join ap_element_options as B
    on A.element_1=B.option_id and B.element_id=1 and B.form_id=4)
    left join ap_element_options as C
    on A.element_2=C.option_id and C.element_id=2 and C.form_id=4";

    $result = mysql_query($query) or die(mysql_error());

    echo "<font face=\"arial\">";
    while($row = mysql_fetch_array($result)){
    echo "<font color= #800000><font size=2><b>";
    echo "<p>";
    echo $row['month'];
    echo " ";
    echo $row['year'];
    echo " ";
    echo "  -  View";
    echo "</b></font>";
    echo "<font color= #E4DCAB><font size=2>";
    echo "<br>";
    }
    ?>

    Posted 15 years ago #
  2. yuniar

    I suppose so. Did you get any error message when you add the LIMIT?


    MachForm Founder

    Posted 15 years ago #
  3. rscott7706
    Member

    Yes, it crashed it. I may be trying to put it in the wrong place.

    Here is the error code:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' B.option as month, C.option as year from (ap_form_4 as ' at line 2

    I put the limit statement here:

    $query = "select
    A.* LIMIT 1, 10,
    B.option as month,
    C.option as year
    from

    Thanks!!
    Ron

    Posted 15 years ago #
  4. redityo

    Hi Ron,

    I think you wrong put the limit statement, it should be like this

    select
    A.*,
    B.option as month,
    C.option as year
    from
    (ap_form_4 as A
    left join ap_element_options as B
    on A.element_1=B.option_id and B.element_id=1 and B.form_id=4)
    left join ap_element_options as C
    on A.element_2=C.option_id and C.element_id=2 and C.form_id=4
    LIMIT 1,10

    MachForm Support

    Posted 15 years ago #

RSS feed for this topic

Reply