For details about passing parameters on the php page, refer to the php Tutorial.

Source: Internet
Author: User
For the parameter passing problem on the php page, please advise
$query = $db->findall("p_newsclass where f_id='$_GET[cid]'");while ($row = $db->fetch_array($query)) {$news_class_in.= $row[id].",";}echo $news_class_in=$news_class_in."$_GET[cid]";

Is to display the news list and print it out correctly.

But it is written to SQL.
$result = mysql_query("select id from p_newsbase where cid in ($news_class_in)");$total = mysql_num_rows($result);pageft($total, 20);if ($firstcount < 0)$firstcount = 0;$query = $db->findall("p_newsbase where cid in ($news_class_in)  limit  $firstcount, $displaypg");


An error occurs. the obtained cid has changed.


Reply to discussion (solution)

$ News_class_in. = $ row [id]. ",";
In this way, a comma is added, which can be removed using substr or rtrim:
While ($ row = $ db-> fetch_array ($ query )){
$ News_class_in. = $ row [id]. ",";
}
$ New_class_in = rtrim ($ new_class_in ,",");

Echo $ new_class
It should be the SQL error caused by the last comma in the parentheses of cid in ().

The URL is an id. how can I GET it with $ _ GET [cid?

The URL is an id. how can I GET it with $ _ GET [cid?




$query = $db->findall("p_newsclass where f_id='$_GET[cid]'");while ($row = $db->fetch_array($query)) {$news_class_in.= $row[id].",";}echo  $news_class_in=$news_class_in."$_GET[cid]";




This is the cid obtained by directly printing the URL.

The link specified for the htm file written below is cid.
{section name=l loop=$sm_list}     

{$sm_list[l].cidname} {$sm_list[l].title}

{$sm_list[l].date_time}

{/section}

$ News_class_in. = $ row [id]. ",";
In this way, a comma is added, which can be removed using substr or rtrim:
While ($ row = $ db-> fetch_array ($ query )){
$ News_class_in. = $ row [id]. ",";
}
$ New_class_in = rtrim ($ new_class_in ,",");

Echo $ new_class
It should be the SQL error caused by the last comma in the parentheses of cid in ().



Thank you for your answers. let me see the following. why is there no comma after I print it directly?

In the last figure, the incorrect SQL statement has an additional ",".
In this case, a comma is added at the end of the write loop.

$ News_class_in has a comma at the end of the variable.

Add one sentence:

$news_class_in = trim($news_class_in, ',');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.