النتائج 1 إلى 5 من 5

الموضوع: لو ممكن طريقة جمع الاستعلام

  1. #1
    عضو نشيط جدا
    تاريخ التسجيل
    Jan 2008
    المشاركات
    392

    لو ممكن طريقة جمع الاستعلام



    السلام عليكم

    اخواني انا لدي قاعدة بيانات
    كود:
     CREATE TABLE `test` (
    `id` int(4) NOT NULL auto_increment,
    `name` varchar(65) NOT NULL default '',
    `lastname` varchar(65) NOT NULL default '',
    `email` varchar(65) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=7 ;
    
    -- 
    -- Dumping data for table `test`
    -- 
    
    
    INSERT INTO `test_mysql` VALUES (1, 'Billly', 'Blueton', 'bb5@phpeasystep.com');
    INSERT INTO `test_mysql` VALUES (2, 'Jame', 'Campbell', 'jame@somewhere.com');
    INSERT INTO `test_mysql` VALUES (3, 'Mark', 'Jackson', 'mark@phpeasystep.com');
    INSERT INTO `test_mysql` VALUES (4, 'Linda', 'Travor', 'lin65@phpeasystep.com');
    INSERT INTO `test_mysql` VALUES (5, 'Joey', 'Ford', 'fordloi@somewhere.com');
    INSERT INTO `test_mysql` VALUES (6, 'Sidney', 'Gibson', 'gibson@phpeasystep.com');
    كود عرض البيانات

    كود:
    <html dir="ltr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> 
    <title>Add Employee</title>
    <style type="text/css"/>
    body {
    font-family : tahoma;
    }
    </style>
    </head>
    <body>
    <?php
    
    include("config.php");
    
    $tbl_name="test_mysql"; // Table name
    
    
    
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    
    ?>
    <div align="center">
    <div align="center">
    	<table border="0" cellpadding="0" cellspacing="0" width="27%" height="20" id="table1">
    		<tr>
    			
    <div align="center">
    <div align="center">
    	<table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    	<table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    	<table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    <table border="1" cellspacing="0" cellpadding="5" style="border-style: solid; border-width: 1px" bgcolor="#FFFFFF" width="468">
    <tr>
    <td align="center" width="227"  >
    <font color="#000000"><strong>Name</strong></font></td>
    <td align="center" width="78"    >
    <font color="#000000"><strong>lastname</strong></font></td>
    <td align="center" width="125"  >
    <font color="#000000"><strong>Email</strong></font></td>
    </tr>
    
    <?php
    while($rows=mysql_fetch_array($result)){
    ?>
    <tr>
    
    <td width="227" align="center"  bordercolorlight="#FFFFFF" ><b><?php echo $rows['name']; ?></b></td>
    <td width="78" align="center"  bordercolorlight="#FFFFFF" ><b><?php echo $rows['lastname']; ?></b></td>
    <td width="125" align="center"  bordercolorlight="#FFFFFF" ><b><?php echo $rows['email']; ?></b></td>
    
    </tr>
    <?php
    }
    ?>
    </table>
    </div>
    </td>
    </tr>
    
    </table>
    </div>
    
    
    <?php
    mysql_close();
    ?>
    </body>
    </html>
    اريد ان يكون في نهاية كود عرض البيانات يظهر لي عدد البيانات

    مثلا عندي 6 اسما مدخلة في القاعدة وهي
    Billly
    Jame
    Mark
    Linda
    Joey
    Sidney

    اريد ان يكون في نهاية الجدول يظهر لي الرقم 6 لان البيانات التي ظهرت 6 صفوف الناتجة عن الاستعلام







  2. #2
    عضو فعال جدا
    تاريخ التسجيل
    Apr 2002
    المشاركات
    2,046


    يمكنك جلب عدد النتائج لاي استعلام باستخدام الدالة mysql_num_rows
    كالتالي:
    كود PHP:
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    $num_result = @mysql_num_rows($result);
    echo 
    $num_result






    __________________
    مدونتي

  3. #3
    عضو نشيط جدا
    تاريخ التسجيل
    Jan 2008
    المشاركات
    392


    اخوي لقد اضفت الدالة ولكن لا يظهر شي

    الكود
    كود:
    <html dir="ltr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> 
    <title>Add Employee</title>
    <style type="text/css"/>
    body {
    font-family : tahoma;
    }
    </style>
    </head>
    <body>
    <?php
    
    include("config.php");
    
    $tbl_name="test_mysql"; // Table name
    
    
    
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    $num_result = @mysql_num_rows($result);
    echo $num_result; 
    ?>
    <div align="center">
    <div align="center">
    	<table border="0" cellpadding="0" cellspacing="0" width="27%" height="20" id="table1">
    		<tr>
    			
    <div align="center">
    <div align="center">
    	<table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    	<table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    	<table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    <table border="1" cellspacing="0" cellpadding="5" style="border-style: solid; border-width: 1px" bgcolor="#FFFFFF" width="468">
    <tr>
    <td align="center" width="227"  >
    <font color="#000000"><strong>Name</strong></font></td>
    <td align="center" width="78"    >
    <font color="#000000"><strong>lastname</strong></font></td>
    <td align="center" width="125"  >
    <font color="#000000"><strong>Email</strong></font></td>
    </tr>
    
    <?php
    while($rows=mysql_fetch_array($result)){
    ?>
    <tr>
    
    <td width="227" align="center"  bordercolorlight="#000000" ><b><?php echo $rows['name']; ?></b></td>
    <td width="78" align="center"  bordercolorlight="#000000" ><b><?php echo $rows['lastname']; ?></b></td>
    <td width="125" align="center"  bordercolorlight="#000000" ><b><?php echo $rows['email']; ?></b></td>
    
    </tr>
    <tr>
    <td width="430" align="center"  bordercolorlight="#000000" colspan="3" ><?php echo $rows['result']; ?></td>
    </tr>
    <?php
    }
    ?>
    <tr>
    
    
    </tr>
    </table>
    </div>
    </td>
    </tr>
    
    </table>
    </div>
    
    <?php
    mysql_close();
    ?>
    </body>
    </html>
    بحيث تم اضافة
    كود:
    include("config.php");
    
    $tbl_name="test_mysql"; // Table name
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    $num_result = @mysql_num_rows($result);
    echo $num_result;
    واضافة
    كود:
    <td width="430" align="center"  bordercolorlight="#FFFFFF" colspan="3" ><?php echo $rows['result']; ?></td>
    ولكن لا يعمل





    التعديل الأخير تم بواسطة manindark ; 22-06-2008 الساعة 10:29 PM

  4. #4
    عضو نشيط
    تاريخ التسجيل
    Feb 2008
    المشاركات
    281


    السلام عليكم ورحمة اللة وبركاتة

    وهذا حل بعيد عن دالة mysql_num_rows واسرع ويظهر لك عدد النتائج التى فى المصفوفة فقط
    كود PHP:
    <html dir="ltr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> 
    <title>Add Employee</title>
    <style type="text/css"/>
    body {
    font-family : tahoma;
    }
    </style>
    </head>
    <body>
    <?php

    include("config.php");

    $tbl_name="test_mysql"// Table name



    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);

    ?>
    <div align="center">
    <div align="center">
        <table border="0" cellpadding="0" cellspacing="0" width="27%" height="20" id="table1">
            <tr>
                
    <div align="center">
    <div align="center">
        <table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
        <table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
        <table width="393" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <td>
    <div align="center">
    <table border="1" cellspacing="0" cellpadding="5" style="border-style: solid; border-width: 1px" bgcolor="#FFFFFF" width="468">
    <tr>
    <td align="center" width="227"  >
    <font color="#000000"><strong>Name</strong></font></td>
    <td align="center" width="78"    >
    <font color="#000000"><strong>lastname</strong></font></td>
    <td align="center" width="125"  >
    <font color="#000000"><strong>Email</strong></font></td>
    </tr>

    <?php
    while($rows=mysql_fetch_array($result)){
    $num++;
    ?>
    <tr>

    <td width="227" align="center"  bordercolorlight="#FFFFFF" ><b><?php echo $rows['name']; ?></b></td>
    <td width="78" align="center"  bordercolorlight="#FFFFFF" ><b><?php echo $rows['lastname']; ?></b></td>
    <td width="125" align="center"  bordercolorlight="#FFFFFF" ><b><?php echo $rows['email']; ?></b></td>

    </tr>
    <?php
    }
    ?>
    </table>
    <b>أجمالى المسجلين <?=$num;?></b>
    </div>
    </td>
    </tr>

    </table>
    </div>


    <?php
    mysql_close
    ();
    ?>
    </body>
    </html>







  5. #5
    عضو نشيط جدا
    تاريخ التسجيل
    Jan 2008
    المشاركات
    392


    الف شكر اخوي tech










ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض