显示数据库中评分更高的产品 [英] display product from database which has more rating

查看:90
本文介绍了显示数据库中评分更高的产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有我正在制作一个asp.net Web应用程序的人……我已经给出了对该产品进行评级的系统.

为此,我在该产品上使用了四个单选按钮,即25%的Ist收音机,50%的第二个收音机和

等等...
用户对该产品进行评分,我将其保存在数据库中
1.)产品编号
2.)userid
3.)评分.

现在假设用户何时对产品进行评分,然后注销.现在,当任何用户登录到

软件,然后在数据库中获得更高评分的产品应放在首页并写成

作为当日产品"以及该产品的详细信息..
假设我在数据库中有两个t.v条目
t.v-25%
t.v-50%

和观看

观看75%
手表100%

现在总体而言,手表在数据库中的显示获得了更高的评价-

在buttonvote上,我已经做到了

helo to all i am making an asp.net web application...I have given the system of rating the product..

for that i have taken four radio buttons behnid that product, Ist radio of 25%, second of 50% and

so on...
user rate that product and i saved it in database
1.)product id
2.)userid
3.)rating.

Now suppose when user rates the product and after that log out..now when any user login into the

software then the product which got more ratings in database should come at front page and written

as "product of the day" and the details of that product..
suppose i have two entries of t.v in database
t.v-25%
t.v-50%

and watch

watch-75%
watch-100%

now overall, watch got more rating as showing in database--

on buttonvote i have done this

protected void btnvote_Click(object sender, EventArgs e)
    {
        int s=0;
        if (rd1.Checked)
        {
            s = 25;
        }
        else if (rd2.Checked)
        {
            s = 50;
        }

        else if (rd3.Checked)
        {
            s = 75;
        }

        else if (rd4.Checked)
        {
            s = 100;
        }      

        DataSet ds = new DataSet();
        OleDbDataAdapter adp = new OleDbDataAdapter("select * from ratings", con);
        adp.Fill(ds,"virtual");
        DataRow dr4;
        dr4 = ds.Tables["virtual"].NewRow();

        dr4[0] = lblname.Text;
        dr4[1] = s;
        dr4[2] = mm.Text;

        ds.Tables["virtual"].Rows.Add();

        adp.InsertCommand = new OleDbCommand();
        adp.InsertCommand.CommandText = "insert into ratings values(" + "'" + lblname.Text + "'" + 

"," + "'" + s + "'" + "," + "'" + mm.Text + "'" + ")";
        adp.InsertCommand.Connection = con;
        adp.Update(ds, "virtual");

        Response.Write("<script>alert('Thanks for your rating')</script>");
        rd1.Visible = false;
        rd2.Visible = false;
        rd3.Visible = false;
        rd4.Visible = false;
        Image1.Visible = false;
        Image2.Visible = false;
        HyperLink1.Visible = false;
        btnvote.Visible = false;
        Label4.Visible = false;
        Label3.Visible = false;        
    }




之后,我将要做些什么来帮助我.




after that what will i have to do plz help me.

推荐答案

您需要重新开始.您的代码因多种原因无法使用

1-缺乏安全感
2-无设计
3-由于变量名称不正确而无法读取
4-使用response.write,由于无法定位输出而在ASP.NET中无用
5-一般缺乏设计或代码质量

有了合适的代码库后,带有ORDER BY子句的SQL请求将按等级对项目进行排序.
You need to start again. Your code is not usable for a number of reasons

1 - lack of concern for security
2 - no design
3 - unreadable due to poor variable names
4 - use of response.write, which is useless in ASP.NET due to inability to position output
5 - general lack of design or code quality

Once you have a decent code base, a SQL request with an ORDER BY clause will order your items by rating.


用户按下登录按钮后,导航至所需页面并使用下面的代码
Once the user pressed login button navigate to desired page and use the code below
DataTable dt;
String str="select product_name from propduct where ratio in(select max(ratio) from product);"
DataAdapter da=new DataAdapter(str,con);
da.fill(dt);

txtProductOfDay.Text=dt.rows[0][0].ToString();



希望它能满足您的要求. :-O



Hope it can fullfil ur requiremant. :-O


这篇关于显示数据库中评分更高的产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆