Şimdi Ara

Verileri sayfalamak

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir (1 Mobil) - 1 Masaüstü1 Mobil
5 sn
15
Cevap
0
Favori
515
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Arkadaşlar veritabanındaki verileri yazdırırken diyelimki her 15 bilgide bir 1-2-3-4-5 diye sayfalamasını istiyorum nasıl yaparım

    <Geri 1-2-3-4-5 İleri>

    şeklinde



    _____________________________
  • aslında basit.Şu an bu kodudaha genelgeçer yapmak isterdim ama vaktim yok.Bendeki 10 ar değiştiriyor.Değiştirmek istersen 10 yerin 15 yaz.Anlarsın zaten.

    Foruma girerken $b=0 verisini göndereceksin.<a href=forum.php?b=0>Mesajları göster</a>


    -- Forum.php --
    $veri_yolu = mysql_connect('localhost', 'root');mysql_select_db("database_name" , $veri_yolu);

    $result=mysql_query("SELECT * FROM table_name ", $veri_yolu);
    $numrowss = mysql_num_rows($result);
    $result=mysql_query("SELECT * FROM table_name ' order by id ASC limit $b,10 ", $veri_yolu);

    if($numrowss>10){
    $bg=$b-10;if($b>0){echo"<a href=forum.php?name=$name&b=$bg class=ub>< önceki </a>";}

    $i=1;$j=0;$imax=round($numrowss/10);if($imax*10<$numrowss){$imax++;}while($i<=$imax){if($b==(($i-1)*10)){echo' [';}else{echo" ";}echo "<a href=s_forum.php?name=$name&b=$j>$i</a>";if($b==(($i-1)*10)){echo']';}$i++;$j=$j+10;}

    $bi=$b+10;if($bi<=($imax-1)*10){echo"<a href=forum.php?name=$name&b=$bi class=ub> Sonraki ></a>";}
    }


    Not:
    - database_name yerini databaseinin adını
    - table_name yerini okuyacagın tableinin adını
    - $veri_yolu = mysql_connect('localhost', 'root');Ev bilgisayarında çalıştırıyorsan.
    - Eğer internetten çalıştıracaksan veriyolunu $veri_yolu = mysql_connect('adress.com, 'user','password'); Dikkat adrestehttp://wwww kullanma user ve password bölümlerine de database'in şifrelerini yazacaksın.

    Karşımdaki embesilmiş gibi anlattım kusura bakmayın.Ama benim zamanında takıldığım yerlerinde altını çizmek istedim.

    Herhalde çalışır.Bişiy olursa sorarsın.



    < Bu mesaj bu kişi tarafından değiştirildi looter -- 3 Nisan 2006; 15:06:34 >




  • bunu . net te yapmak isteyen arkadaşlar içinde belki bu kod biraz fikir verebilir

    public class urunler : System.Web.UI.UserControl
    {
    protected System.Web.UI.WebControls.Label paging;
    protected System.Data.DataSet setds;
    protected System.Web.UI.WebControls.Table uruntablo;
    protected System.Web.UI.WebControls.Label Button1;
    int count=0;


    private void Page_Load(object sender, System.EventArgs e)
    {
    SqlConnection conn=new SqlConnection();
    conn.ConnectionString=System.Configuration.ConfigurationSettings.AppSettings.Get("aronsatis");
    int group=1;

    group=Convert.ToInt32(Request.QueryString.Get("grup"));
    if(group==0)
    {
    group=1;
    }
    SqlCommand urunsayi=new SqlCommand();
    urunsayi.Connection=conn;
    urunsayi.CommandText="urunsayi";
    urunsayi.Parameters.Add(new SqlParameter("@katid",group));
    urunsayi.CommandType=CommandType.StoredProcedure;
    SqlDataReader urunsayird;
    conn.Open();
    urunsayird= urunsayi.ExecuteReader();
    while(urunsayird.Read())
    {
    count=urunsayird.GetInt32(0);
    }
    conn.Close();
    if(count==0)
    {
    paging.Font.Name="Tahoma";
    paging.Text="Bu Gruba Ait Ürün Bulunmamaktadir<br><br><a href='#'onClick='history.back()'>Geri Dön</a>";
    }
    else
    {
    int pagesize=20;
    int baslama=0;
    baslama=Convert.ToInt32(Request.QueryString.Get("sfno"));
    if(baslama!=0)
    {
    baslama=baslama-1;
    }



    baslama=baslama*pagesize;


    Response.Write(group);
    SqlCommand uruncekme=new SqlCommand();
    uruncekme.Connection=conn;
    uruncekme.CommandText="uruncekme";
    uruncekme.CommandType=CommandType.StoredProcedure;
    uruncekme.Parameters.Add(new SqlParameter("@katid",group));
    SqlDataAdapter urundoldur=new SqlDataAdapter(uruncekme);
    DataTable urundt=new DataTable("urun");
    conn.Open();
    urundoldur.Fill(setds,baslama,pagesize,"urun");
    conn.Close();

    int pagecount=count/pagesize;
    if(count%pagesize!=0)
    {
    pagecount=pagecount+1;
    }
    int sayfalama=1;
    if(Convert.ToInt32(Request.QueryString.Get("sfno"))!=0)
    {
    sayfalama=Convert.ToInt32(Request.QueryString.Get("sfno"));
    }

    int ukid=Convert.ToInt32(Request.QueryString.Get("ukid"));
    paging.Text="";
    for(int k=1;k<=pagecount;k++)
    {
    if(k==sayfalama)
    {
    paging.Text=paging.Text+" "+k;
    }
    else
    {
    paging.Text=paging.Text+" <a href='product.aspx?ukid="+ukid+"&grup="+group+"&sfno="+k+"' target='_self'>"+k+"</a>";
    }
    }



    //////////// URUNLERI YERLESTIR //////////////
    int sayac=0;
    string bgcolor;
    Char l2=new Char();
    l2='"';
    int gro=Convert.ToInt32(Request.QueryString.Get("grup"));
    if(gro==0)
    {
    uruntablo.Rows.Clear();
    paging.Text="";
    Button1.Visible=false;
    }
    else
    {
    Button1.Visible=true;
    Button1.Text="<a href='#' onClick="+l2+"window.open('compare.aspx', '', 'scrollbars=yes,resizable=yes,width=800,height=600,left=200,top=100')"+l2+" class='style3' style='text-decoration:none'>KARSILASTIR</a>";

    foreach(DataTable myTable in setds.Tables)
    {
    foreach(DataRow myRow in myTable.Rows)
    {
    TableRow dis=new TableRow();


    if(sayac%2==0)
    {
    bgcolor="whitesmoke";
    }
    else
    {
    bgcolor="#ffffff";
    }

    string temp="<TABLE bgcolor='"+bgcolor+"' width='100%'><tr align='Left' style='border-color:Black;border-width:1px;border-style:Solid;'>";
    temp+="<td style='width:20px;'><input id='"+myRow[0].ToString()+"' value='"+myRow[0].ToString()+"' type='checkbox' name='urun' /></td>";
    /*temp+="<td><img src='urunresimleri/"+myRow[4].ToString()+"' border='0' width=100px /></td>";*/
    temp+="<td style='width:35%;font-family:Tahoma;font-size:10pt'>"+myRow[2].ToString()+"</td>";
    temp+="<td style='width:35%;font-family:Tahoma;font-size:10pt'><a href='#' onClick="+l2+"window.open('urunayrinti.aspx?id="+myRow[0].ToString()+"', '', 'scrollbars=yes,resizable=yes,width=700,height=500,left=200,top=100')"+l2+" class='style3' style='text-decoration:none'>"+myRow[1].ToString()+" -  "+myRow[3].ToString()+"</a></td>";
    temp+="<td style='width:20px;'><img src='images/urk.bmp' border='0' width='20px' /></td>";
    temp+="<td style='width:20px;'><img src='images/urk.bmp' border='0' width='20px' /></td>";
    temp+="<td style='width:20px;'><img src='images/urk.bmp' border='0' width='20px' /></td>";
    temp+="<td style='width:35px;font-family:Tahoma;font-size:10pt'>"+myRow[5].ToString()+"_YTL</td></tr></TABLE>"; Label l1=new Label();
    l1.Text=temp;

    TableCell c1=new TableCell();
    c1.BorderWidth=1;
    c1.BorderColor=System.Drawing.Color.Silver;
    c1.Controls.Add(l1);
    dis.Controls.Add(c1);
    uruntablo.Rows.Add(dis);
    sayac++;



    }

    }
    }





    }

    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.setds = new System.Data.DataSet();
    ((System.ComponentModel.ISupportInitialize)(this.setds)).BeginInit();
    //
    // setds
    //
    this.setds.DataSetName = "NewDataSet";
    this.setds.Locale = new System.Globalization.CultureInfo("en-US");
    this.Load += new System.EventHandler(this.Page_Load);
    ((System.ComponentModel.ISupportInitialize)(this.setds)).EndInit();

    }
    #endregion

    private void Button1_Click(object sender, System.EventArgs e)
    {


    string idler=Request.Form.Get("urun");
    String[] ara=idler.Split(',');
    for(int i=0;i<ara.Length;i++)
    {
    Response.Write(ara+ "<br>");
    }

    }


    }
    }
    _____________________________
    Software changes. This is a rather obvious statement, but it is a fact that must be ever present in the minds of developers and architects. Although we tend to think of software development as chiefly an engineering exercise, the analogy breaks down very quickly. When was the last time someone asked the designers of the Empire State building to add ten new floors at the bottom, put a pool on the top, and have all of this done before Monday morning?




  • Dostum,

    Bu nedir?!
  • asp.net te paging yapan bir user control... sadece bu konu başlığı benim bayağı canımı sıkmıştı bir ara...artık nerede görsem birine bir yardımı olur diyorum
    _____________________________
    Software changes. This is a rather obvious statement, but it is a fact that must be ever present in the minds of developers and architects. Although we tend to think of software development as chiefly an engineering exercise, the analogy breaks down very quickly. When was the last time someone asked the designers of the Empire State building to add ten new floors at the bottom, put a pool on the top, and have all of this done before Monday morning?
  • diyorsun ki artık bu soru hem php hem de asp için cevaplandı



    < Bu mesaj bu kişi tarafından değiştirildi looter -- 3 Nisan 2006; 15:11:59 >
  • aynen öyle dostum... kendi kodumu yazacam diye kastığım 1 haftayı düşünüyorumda...Kimsenin Başına Gelmesin!
    fikir fikirdir...olsunda
    _____________________________
    Software changes. This is a rather obvious statement, but it is a fact that must be ever present in the minds of developers and architects. Although we tend to think of software development as chiefly an engineering exercise, the analogy breaks down very quickly. When was the last time someone asked the designers of the Empire State building to add ten new floors at the bottom, put a pool on the top, and have all of this done before Monday morning?
  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
  • looter yaw ben yapamadım

    ben kodları ile veritabanındaki resimleri yayınlıyorum ama sayfalamayı yapamadım

    kodlarım bu

    $baglan = mysql_connect($host,$dbuser,$dbpw);
    mysql_select_db ($dbname,$baglan);
    $sorgu = "SELECT * FROM resim ORDER BY id DESC";
    $sorgulama = mysql_query($sorgu);

    if (mysql_num_rows($sorgulama)>0) {
    // Kayitlarin listelenmesi
    while ($kayit = mysql_fetch_array($sorgulama)) {
    $baslik = $kayit["baslik"];
    $resim = $kayit["resim"];
    $url = $kayit["url"];
    $aciklama = $kayit["aciklama"];
    $gonderen = $kayit["gonderen"];
    $tarih = $kayit["tarih"];

    echo "<center><a href=\"$url\"><b>$baslik</b><br></a><font size= 1>$gonderen - $tarih</font><br><a href=\"$url\"><img src=\"$resim\"><br>$aciklama</center><br><br>";
    }
    }
    else {
    echo "<center><b>Resim Eklenmemiş</b></center>";
    }

    buna ne gibi ekleme yapmam lazım
    _____________________________




  • Gene forum.php ye <a href=forum.php?b=0>Resimleri göster</a> den gelecen.
    Birde bunun işlemesi için tablonda id sütunun olmalı $sorgu = "SELECT * FROM resim ORDER BY id DESC";

    -- Forum.php --
    <?
    $baglan = mysql_connect($host,$dbuser,$dbpw);
    mysql_select_db ($dbname,$baglan);

    $sorgu = "SELECT * FROM resim ORDER BY id DESC";
    $sorgulama = mysql_query($sorgu);
    $numrowss = mysql_num_rows($sorgulama);

    $sorgu = "SELECT * FROM resim ORDER BY id DESC limit $b,15";
    $sorgulama = mysql_query($sorgu);

    while ($kayit = mysql_fetch_array($sorgulama)) {
    $baslik = $kayit["baslik"];
    $resim = $kayit["resim"];
    $url = $kayit["url"];
    $aciklama = $kayit["aciklama"];
    $gonderen = $kayit["gonderen"];
    $tarih = $kayit["tarih"];
    echo "<center><a href=\"$url\"><b>$baslik</b><br></a><font size= 1>$gonderen - $tarih</font><br><a href=\"$url\"><img src=\"$resim\"><br>$aciklama</center><br><br>";
    }

    if($numrowss>10){
    $bg=$b-10;if($b>0){echo"<a href=forum.php?b=$bg class=ub>< önceki </a>";}

    $i=1;$j=0;$imax=round($numrowss/10);if($imax*10<$numrowss){$imax++;}while($i<=$imax){if($b==(($i-1)*10)){echo' [';}else{echo" ";}echo "<a href=s_forum.php?b=$j>$i</a>";if($b==(($i-1)*10)){echo']';}$i++;$j=$j+10;}

    $bi=$b+10;if($bi<=($imax-1)*10){echo"<a href=forum.php?b=$bi class=ub> Sonraki ></a>";}
    }
    ?>

    Sen bir dene olmassa gene sorarsın.



    < Bu mesaj bu kişi tarafından değiştirildi looter -- 3 Nisan 2006; 23:32:05 >




  • kardeş olduda
    tek sorun var b=0 diye gönderince bütün resimleri sıralıyo [SONRAKİ] butonuna tıklayınca kaçtane kalmışsa onu
    _____________________________
  • mesela senin table da 18 tane kayıt vaar.

    ilk sayfada 15 tane gösterir.Sonrakinde geri kalan 3 taneyi....

    Sen ne yapmasını istiyorsun?
  • neden 15 10 olarak ayarlamamışmıydık
    _____________________________
  • aaaa evet yaaa
    ben yarısını 10 yarısın 15 olarak ayarlamışım....
     
    <?
    $baglan = mysql_connect($host,$dbuser,$dbpw);
    mysql_select_db ($dbname,$baglan);

    $sorgu = "SELECT * FROM resim ORDER BY id DESC";
    $sorgulama = mysql_query($sorgu);
    $numrowss = mysql_num_rows($sorgulama);

    $sorgu = "SELECT * FROM resim ORDER BY id DESC limit $b,15";
    $sorgulama = mysql_query($sorgu);

    while ($kayit = mysql_fetch_array($sorgulama)) {
    $baslik = $kayit["baslik"];
    $resim = $kayit["resim"];
    $url = $kayit["url"];
    $aciklama = $kayit["aciklama"];
    $gonderen = $kayit["gonderen"];
    $tarih = $kayit["tarih"];
    echo "<center><a href=\"$url\"><b>$baslik</b><br></a><font size= 1>$gonderen - $tarih</font><br><a href=\"$url\"><img src=\"$resim\"><br>$aciklama</center><br><br>";
    }

    if($numrowss>15){
    $bg=$b-15;if($b>0){echo"<a href=forum.php?b=$bg class=ub>< önceki </a>";}

    $i=1;$j=0;$imax=round($numrowss/15);if($imax*15<$numrowss){$imax++;}while($i<=$imax){if($b==(($i-1)*15)){echo' [';}else{echo" ";}echo "<a href=s_forum.php?b=$j>$i</a>";if($b==(($i-1)*15)){echo']';}$i++;$j=$j+15;}

    $bi=$b+10;if($bi<=($imax-1)*15){echo"<a href=forum.php?b=$bi class=ub> Sonraki ></a>";}
    }
    ?>


    Yaparsan olur herhalde..




  • arkadaşlar uzun kodlara takılmayın
    sql de paging yapmanın size kolay yolaarın söyleyim
    1. ya sayfa numalararınnı columnlarda tutarınız (ürünlerin silinmediğini farzedicez)
    ha eğer ürün siliyonorsa
    temp table la işi çözcez
    diğerleri çünkü cursor yada uzun select sorguları performans açısından çok kötüdür
    doğru indexlenmiş bir tablo da temptable ya atacağınız 50.000 ürün bile yavaşlatmaz.
    temptable a atar
    sonra ID lerine göre sıralatırsınız

    select * from #temp where ID between a and b gibi

    sayfa sayısını da bi dropdownlist e koyarsınız olur biter.
    _____________________________
    .
  • sayfaları silinmiyen bir dinamik sayfa zor bulursunuz yalnız bilencekic her ne kadar pratikde olsa bence pek işe yarayacak bir kod gibi durmuyor ama zekice düşünülmüş, ne kadar basit olsada.
    _____________________________
    Gemi sola yatmıyor, bayaa bayaa su alıyor.
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.