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?
Started 15 years ago by rscott7706 | 4 posts |
-
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 # -
I suppose so. Did you get any error message when you add the LIMIT?
MachForm Founder
Posted 15 years ago # -
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 2I put the limit statement here:
$query = "select
A.* LIMIT 1, 10,
B.option as month,
C.option as year
fromThanks!!
RonPosted 15 years ago # -
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 #
Reply
You must log in to post.