اذهب إلى المحتوى

Our World عالمنا

الأعضاء
  • المساهمات

    84
  • تاريخ الانضمام

  • تاريخ آخر زيارة

كل منشورات العضو Our World عالمنا

  1. عندي جدول منتجات به عدة حقول منها item_id, name, description, photo أريد أن أضيف ساعات العمل الى المنتج؛ هل أضيف الحقول الاتية الى ذلك الجدول أم الأفضل أن أنشأ جدول جديد؛ ولو أنشأت جدول جديد كيف يكون الربط الصحيح الحقول هي from_saturday, to_saturday,from_sunday,to_sunday...etc
  2. التعارض هو "عند الضغط على اللينك الموجود فى الترقيم بدءا من الصفحة الثانية (234) المفترض ان يكمل باقى الاعلانات التى عرض جزء منها فى الصفحة الاولى؛ ولكن ما يحدث هو انه يحولني الى قسم "all categories" ويعرض كل الاعلانات موزععة على صفحات الترقيم بدلا من عرض اعلانات القسم الذي اخترته
  3. هذه هي الاكواد لعل الصورة تتضح اكثر: ===================================== الصفحة الرئيسية <!----------------------------START CATEGORIES---------------------> <span class="Choose-category latest-ads">Choose a category</span> <section class="category-section"> <?php if(!empty($cats)){ foreach ($cats as $cat) { ?> <div> <?php if($cat['cat_id']==1){echo '<i class="fas fa-store"></i>';} if($cat['cat_id']==2){echo '<i class="fas fa-tools"></i>';} if($cat['cat_id']==3){echo '<i class="fas fa-shopping-bag"></i>';} if($cat['cat_id']==4){echo '<i class="fas fa-store"></i>';} if($cat['cat_id']==5){echo '<i class="fas fa-user-friends"></i>';} if($cat['cat_id']==6){echo '<i class="fas fa-question-circle"></i>';} echo "<a href='search.php?c=".$country."&i=".$cat['cat_id']."&n=".$cat['name']."' class='cat' value=".$cat['cat_id'].">".$cat['name']."</a>"; ?> </div> <?php } } ?> </section> ================================ صفحة البحث if( (isset($_GET['c']) && is_numeric($_GET['c']) && isset($_GET['i']) && is_numeric($_GET['i']) && isset($_GET['n']) && ($_GET['n']=='Activities' || $_GET['n']=='Jobs'||$_GET['n']=='Products/Services'||$_GET['n']=='Occasions'||$_GET['n']=='Wanted'||$_GET['n']=='Lost'))|| isset($_GET['page'] ) ) { $catid =isset($_GET['i'])?$_GET['i']:''; //category id $catName =isset($_GET['n'])?$_GET['n']:''; //category name $count =isset($_GET['c'])?$_GET['c']:''; //country id $countryName =''; $country=$count<1||$count>4?1:$count; $category=$catid<1||$catid>6?0:$catid; //================================ // pagination echo 'pageNum='. $pageNum= isset($_GET['page']) && is_numeric($_GET['page']) ? intval($_GET['page']) : 1; $adsPerPage=3; echo '<BR>startFrom='. $startFrom=($pageNum-1)* $adsPerPage; //============================== //country & category are false if(($country<1 || $country>4) && ($category<1 || $category>6) ){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id>0 and country.country_id=1 "); $stmt->execute(); $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id>0 and country.country_id=1 limit $startFrom,$adsPerPage "); $stmt->execute(); $item= $stmt->fetchAll(); //country & category are true }elseif(($country>=1 && $country<=4) && ($category>=1 && $category<=6) ){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id =? and country.country_id=? "); $stmt->execute(array($category,$country)); $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id =? and country.country_id=? limit $startFrom,$adsPerPage "); $stmt->execute(array($category,$country)); $item= $stmt->fetchAll(); //country is true, category is false }elseif(($country>=1 && $country<=4) && ($category<1 || $category>6) ){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id>0 and country.country_id=? "); $stmt->execute(array($country)); $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id>0 and country.country_id=? limit $startFrom,$adsPerPage "); $stmt->execute(array($country)); $item= $stmt->fetchAll(); //country is false, category is true }elseif(($country<1 || $country>4) && ($category>=1 && $category<=6) ){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id=? and country.country_id=1 "); $stmt->execute(array($category)); echo 'adsTotalNumb='. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join sub on items.subcat_id=sub.subcat_id join categories on categories.cat_id=items.CAT_ID JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where categories.cat_id=? and country.country_id=1 limit $startFrom,$adsPerPage "); $stmt->execute(array($category)); $item= $stmt->fetchAll(); } //===================start pagination========================= $jumpForward=3; $jumpBackward=3; if($NumberOfPages>1 ){ if(isset($_GET['page'])){ echo '<span style="margin-left:35vw">page '.$_GET['page'].'</span>';}else{ echo '<span style="margin-left:35vw">page 1</span>'; } ?> <nav aria-label="Page navigation example" class="pagination-container"> <ul class="pagination pagination-lg"> <?php if(($pageNum-$jumpBackward)>=1 ){ //previous ?> <li class="page-item"><a class="page-link prev" href="?page=<?php echo ($pageNum-$jumpBackward)?>">Previous (-3)</a></li><?php }else{ ?> <li class="page-item disabled"><a class="page-link">Previous</a></li><?php } ///**/ for ($page=1; $page<= $NumberOfPages; $page++) { //for loop echo '<li class="page-item"><a class="page-link" href="search.php?page='. $page.'">'. $page.'</a></li>'; } if(($pageNum+$jumpForward)<=$NumberOfPages ){ //next ?> <li class="page-item"> <a class="page-link next" href="?page=<?php echo ($pageNum+$jumpForward)?>" >Next (+3)</a> </li><?php }else{ ?> <li class="page-item disabled"> <a class="page-link " >Last</a> </li><?php } ?> </ul > </nav> <?php } } =================================== الصفحة التي تجلب الاعلانات بناء على كود الاجاكس //GET COMING FROM SEARCH PAGE TO RETURN ITEMS BASD ON AJAX if ( (isset($_GET['cat']) || isset($_GET['sub']) || isset($_GET['country']) || isset($_GET['state']) || isset($_GET['city']) || isset($_GET['search']) ) || isset($_GET['page'] ) ) { $category =$_GET['cat']; $subcat =$_GET['sub']; $country=$_GET['country']; $state =$_GET['state']; $city =$_GET['city']; $search =$_GET['search']; echo 'pagenum='. $pageNum= isset($_GET['page']) && is_numeric($_GET['page']) ? intval($_GET['page']) : 1; $adsPerPage=2; $startFrom=($pageNum-1)* $adsPerPage; if( $category>0 && $subcat==0 && $state==0 && $city==0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and categories.cat_id=? "); $stmt->execute(array($country,$category)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //GET ADS $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and categories.cat_id=? limit $startFrom,$adsPerPage "); $stmt->execute(array($country,$category)); $item= $stmt->fetchAll(); }elseif( $category==0 && $subcat==0 && $state==0 && $city==0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? "); $stmt->execute(array($country)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //GET ADS $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? limit $startFrom,$adsPerPage "); $stmt->execute(array($country)); $item= $stmt->fetchAll(); }elseif( $category==0 && $subcat==0 && $state>0 && $city==0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? "); $stmt->execute(array($country,$state)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? "); $stmt->execute(array($country,$state)); $item= $stmt->fetchAll(); }elseif( $category==0 && $subcat==0 && $state>0 && $city>0){ $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and city.city_id=? "); $stmt->execute(array($country,$state,$city)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and city.city_id=? "); $stmt->execute(array($country,$state,$city)); $item= $stmt->fetchAll(); }elseif( $subcat==0 && $state>0 && $city==0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and categories.cat_id=?"); $stmt->execute(array($country,$state,$category)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and categories.cat_id=? limit $startFrom,$adsPerPage"); $stmt->execute(array($country,$state,$category)); $item=$stmt->fetchAll(); }elseif( $subcat>0 && $state>0 && $city==0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and sub.subcat_id =?"); $stmt->execute(array($country,$state,$subcat)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and sub.subcat_id =? limit $startFrom,$adsPerPage"); $stmt->execute(array($country,$state,$subcat)); $item=$stmt->fetchAll(); }elseif( $subcat>0 && $state>0 && $city>0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and sub.subcat_id =? and city.city_id=?"); $stmt->execute(array($country,$state,$subcat,$city)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and sub.subcat_id =? and city.city_id=? limit $startFrom,$adsPerPage"); $stmt->execute(array($country,$state,$subcat,$city)); $item=$stmt->fetchAll(); }elseif( $subcat==0 && $state>0 && $city>0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and city.city_id=? and categories.cat_id=? "); $stmt->execute(array($country,$state,$city,$category)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and state.state_id=? and city.city_id=? and categories.cat_id=? limit $startFrom,$adsPerPage"); $stmt->execute(array($country,$state,$city,$category)); $item=$stmt->fetchAll(); }elseif( $subcat==0 && $state==0 && $city>0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and city.city_id=? and categories.cat_id=? "); $stmt->execute(array($country,$city,$category)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //get ads $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and city.city_id=? and categories.cat_id=? limit $startFrom,$adsPerPage"); $stmt->execute(array($country,$city,$category)); $item=$stmt->fetchAll(); }elseif( $subcat>0 && $state==0 && $city==0){ $stmt=$conn->prepare(" SELECT count(item_id) FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and sub.subcat_id=? "); $stmt->execute(array($country,$subcat)); echo 'adsTotalNumber'. $adsTotalNumber=$stmt->fetchColumn(); echo '<br>NumberOfPa='. $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); //GET ADS $stmt=$conn->prepare(" SELECT sub.*,categories.*,items.*,country.*,state.*,city.* FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id where country.country_id=? and sub.subcat_id=? limit $startFrom,$adsPerPage "); $stmt->execute(array($country,$subcat)); $item=$stmt->fetchAll(); //===================start pagination========================= $jumpForward=3; $jumpBackward=3; if($NumberOfPages>1 ){ if(isset($_GET['page'])){ echo '<span style="margin-left:35vw">page '.$_GET['page'].'</span>';}else{ echo '<span style="margin-left:35vw">page 1</span>'; } ?> <nav aria-label="Page navigation example" class="pagination-container"> <ul class="pagination pagination-lg"> <?php if(($pageNum-$jumpBackward)>=1 ){ //previous ?> <li class="page-item"><a class="page-link prev" href="?page=<?php echo ($pageNum-$jumpBackward)?>">Previous (-3)</a></li><?php }else{ ?> <li class="page-item disabled"><a class="page-link">Previous</a></li><?php } /*$page=max(1,$pageNum-5);$page<=min($pageNum+2,$NumberOfPages);$page++*/ for ($page=1; $page<= $NumberOfPages; $page++) { //for loop echo '<li class="page-item"><a class="page-link" href="search.php?page='. $page.'">'. $page.'</a></li>'; } if(($pageNum+$jumpForward)<=$NumberOfPages ){ //next ?> <li class="page-item"> <a class="page-link next" href="?page=<?php echo ($pageNum+$jumpForward)?>" >Next (+3)</a> </li><?php }else{ ?> <li class="page-item disabled"> <a class="page-link " >Last</a> </li><?php } ?> </ul > </nav> <?php } }
  4. الـ $_GET المرسل من pagination متعارض مع $_GET اخر فى الصفحة عندما اضغط على رقم 2 فى ترقيم الصفحة يذهب الى صفحة بها منتجات من قسم اخر
  5. $pageNum= isset($_GET['page']) && is_numeric($_GET['page']) ? intval($_GET['page']) : 1; $adsPerPage=4; $startFrom=($pageNum-1)* $adsPerPage; عند استخدام الكود التالي بدون التحديد ( limit) يتم عرض كل الاعلانات مع وجود الترقيم باسفل ولكن وجوده كعدمه فعند الضغط على اى رقم (1,2,3) يعرض كل الاعلانات if ($category==0 && $subCategory==0 && $state==0 ) { $stmt=$conn->prepare(" SELECT * FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id WHERE country.country_id=? AND items.NAME LIKE '%$inputSearch%' order by feature desc /*limit $startFrom,$adsPerPage*/"); $stmt->execute(array($country)); $item= $stmt->fetchAll(); } عند استخدام الكود نفسه مع التحديد ( limit) يعرض 4 اعلانات فقط ولا يعرض ترقيم هكذا: if ($category==0 && $subCategory==0 && $state==0 ) { $stmt=$conn->prepare(" SELECT * FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id WHERE country.country_id=? AND items.NAME LIKE '%$inputSearch%' order by feature desc limit $startFrom,$adsPerPage"); $stmt->execute(array($country)); $item= $stmt->fetchAll(); } $adsTotalNumber=count($item); $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); ايه حل المشكلة
  6. هذا هو الكود الذى استخدمه $jumpForward=3; $jumpBackward=3; $active=$_GET['page']==$pageNum?'active':''; if($NumberOfPages>1){ ?> <nav aria-label="Page navigation example" class="pagination-container"> <ul class="pagination pagination-lg"> <?php if(($pageNum-$jumpBackward)>=1 ){ //previous ?> <li class="page-item"><a class="page-link prev" href="?page=<?php echo ($pageNum-$jumpBackward)?>">Previous (-3)</a></li><?php }else{ ?> <li class="page-item disabled"><a class="page-link">Previous</a></li><?php } for ($page=1; $page<= $NumberOfPages; $page++) { //for loop echo '<li class="page-item"';if($_GET["page"]==$pageNum){ echo $active;} echo ">"; echo '<a class="page-link" href="search.php?page='. $page.'">'. $page.'</a></li>'; } if(($pageNum+$jumpForward)<=$NumberOfPages ){ //next ?> <li class="page-item"> <a class="page-link next" href="?page=<?php echo ($pageNum+$jumpForward)?>" >Next (+3)</a> </li><?php }else{ ?> <li class="page-item disabled"> <a class="page-link " >Last</a> </li><?php } ?> </ul > </nav> <?php }
  7. فاهم الفكرة.. جربتها قبل السؤال هنا ومفيش نتيجة.
  8. صورة اريد ان اجعل اللينك المضغوط عليه فى ال pagination مميز highlighted كما فى الصورة المرفقة $adsPerPage=2; $pageNum= isset($_GET['page'])&& is_numeric($_GET['page']) ? intval($_GET['page']) : 1; $startFrom=($pageNum-1)* $adsPerPage; $jumpForward=3; $jumpBackward=3; if($NumberOfPages>1){ ?> <nav aria-label="Page navigation example" class="pagination-container"> <ul class="pagination pagination-lg"> <?php if(($pageNum-$jumpBackward)>=1 ){ //previous ?> <li class="page-item"><a class="page-link prev" href="?page=<?php echo ($pageNum-$jumpBackward)?>">Previous (-3)</a></li><?php }else{ ?> <li class="page-item disabled"><a class="page-link">Previous</a></li><?php } for ($page=max(1,$pageNum-5);$page<=min($pageNum+2,$NumberOfPages);$page++) { //for loop echo '<li class="page-item "><a class="page-link activePagLink" href="search.php?page='. $page.'">'. $page.'</a></li>'; } if(($pageNum+$jumpForward)<=$NumberOfPages ){ //next ?> <li class="page-item"> <a class="page-link next" href="?page=<?php echo ($pageNum+$jumpForward)?>" >Next (+3)</a> </li><?php }else{ ?> <li class="page-item disabled"> <a class="page-link " >Last</a> </li><?php } ?> </ul> </nav> <?php }
  9. ارغب في تمييز صفحة نشطة فى pagination هذا هو الكود //=======pagination======================== $adsPerPage=2; $stmt=$conn->prepare(" SELECT count(item_id) from items where country_id=? "); $stmt->execute(array($country)); $adsTotalNumber=$stmt->fetchColumn(); $NumberOfPages=ceil($adsTotalNumber/$adsPerPage); $pageNum= isset($_GET['page'])&& is_numeric($_GET['page']) ? intval($_GET['page']) : 1; // $clicked=isset($_GET['page'])&& is_numeric($_GET['page'])?$_GET['page']:1; $startFrom=($pageNum-1)* $adsPerPage; $stmt2=$conn->prepare(" SELECT * from items where country_id=? limit $startFrom,$adsPerPage "); $stmt2->execute(array($country)); $item=$stmt->fetchAll(); //=======pagination================================== ?> <nav aria-label="Page navigation example" class="pagination-container"> <ul class="pagination pagination-lg"> <?php if(($pageNum-$jumpBackward)>=1 ){ //previous ?> <li class="page-item"><a class="page-link prev" href="?page=<?php echo ($pageNum-$jumpBackward)?>">Previous (-3)</a></li><?php }else{ ?> <li class="page-item disabled"><a class="page-link">Previous</a></li><?php } for ($page=max(1,$pageNum-5);$page<=min($pageNum+5,$NumberOfPages);$page++/*$page=1; $page<= $NumberOfPages ; $page++*/) { //for loop echo '<li class="page-item "><a class="page-link" href="search.php?page='. $page.'">'. $page.'</a></li>'; } if(($pageNum+$jumpForward)<=$NumberOfPages ){ //next ?> <li class="page-item"> <a class="page-link next" href="?page=<?php echo ($pageNum+$jumpForward)?>" >Next (+3)</a> </li><?php }else{ ?> <li class="page-item disabled"> <a class="page-link " >Last</a> </li><?php } ?> </ul> </nav> <?php
  10. العمل و الاكواد كانت صحيحة ولكنني جعلت القسم الذي سيظهر به الاقتراح position absolute ,z-index 10 ليكون ظاهر فوق العناصر فجاءت النتائج فوق بعضها ولم ارى الا واحدة فقط
  11. تم حل المشكلة.. شكرا لتعاونكم
  12. تم مراعاة الملاحظات السابقة ولكن يظهر اقتراح واحد فقط على الرغم من ان كلمة البحث موجوده في مكانين اي يجب ظهور اقتراحين وليس اقتراح واحد
  13. HTML <input type="text" name="input-search" id="input-search" autocomplete="off" > <button class="btn btn-success btn-search-index" id="btn-search-index">SEARCH</button> <div class="show2"></div> ajax <script type="text/javascript" src="<?php echo $js; ?>jquery-3.6.0.min.js"></script> <script> $(document).ready(function(){ //ajax call input search $("#input-search").on("keyup", function(){ var search=$(this).val(); if ($(this).val().length>0){ $.ajax({ url:"showSearch.php", data:{sentSearch:search}, success: function(data){ $('.show2').html(data); } }); }else{ $('.show2').html(''); } }); PHP if ($_SERVER['REQUEST_METHOD']=='POST') { $inputSearch =$_POST['input-search']; $stmt=$conn->prepare(" SELECT * FROM items join categories on categories.cat_id=items.CAT_ID join sub on items.subcat_id=sub.subcat_id JOIN country ON items.country_id=country.country_id JOIN state ON items.state_id=state.state_id JOIN city ON items.city_id=city.city_id WHERE =? items.NAME LIKE '%$inputSearch%' or items.description2 LIKE '%$inputSearch%' "); $stmt->execute(); $items= $stmt->fetchAll(); } if (!empty($items)) { foreach ($items as $value) { echo $value['NAME']; } } PHP to get ajax suggestions if (isset($_GET['sentSearch']) ) { $search= $_GET['sentSearch']; $stmt3=$conn->prepare(" SELECT * FROM items WHERE (CONVERT(items.NAME USING utf8) LIKE '%$search%') ORDER BY item_id DESC LIMIT 2"); $stmt3->execute(); $searchRslt=$stmt3->fetch(); $row=$stmt3->rowCount(); if (!empty($searchRslt)) { echo "<div class='show'>".$searchRslt['NAME'].'<br>'."</div>"; }else{ echo "<div class='show'>No results</div>"; } }
  14. على الرغم من عدم وجود جدول اخر به نفس الاسم؛ الا ان اقتراحك جاء بالنتيجة المرجوه سؤال اخر: عندي يوجد فى قاعدة البيانات اكثر من اقتراح لكلمة البحث الا ان الاستعلام يعرض اقتراح واحد فقط.. اريد عرض عدة اقتراحات وليس واحد فقط
  15. السلام عليكم لدي حقل بحث وارغب فى عرض اقتراحات على المستخدم اثناء قيامه بالكتابة.. الاقتراح يعتمد على الاتصال بقاعدة البيانات جدول items حيث يوجد بع عمودان للبحث (NAME , description2)؛ انا ارغب فى ان يكون البحث فى عمود NAME لكن يعطي لى رسالة خطأ؛ اما اذا اخترت البحث فى الحقل الاخر يتم تقديم الاقتراح بنجاح. أريد ان يكون البحث فى عمود NAME ؛ ما الحل؟ رسالة الخطأ هي: Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'NAME' in where clause is ambiguous in C:\xampp2\htdocs\LAFETAA\search.php:59 Stack trace: #0 C:\xampp2\htdocs\LAFETAA\search.php(59): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp2\htdocs\LAFETAA\search.php on line 59
  16. استخدمت هذا الاستعلام ولكن يعطي رسالة خطأ SELECT * FROM categories AS sub_category_1, sub_category_2, sub_category_3 JOIN categories as sub_category_1 ON sub_category_1.category_id = sub_category_1.parent_category_id JOIN categories as sub_category_2 ON sub_category_2.parent_category_id = sub_category_1.category_id JOIN categories as sub_category_3 ON sub_category_3.parent_category_id = sub_category_2.category_id
  17. انا لا اطلب حل واجبات.. انا اتعلم ذاتيا والمصادر 90% منها نظري بدون تطبيق على موقع فعلي.. ثانيا: لكي استخدم join لابد ان يكون هناك اسمين مختلفين والجدول واحد وليس به الا حقل اسم واحد
  18. الرجاء كتابة الاستعلام.. جزاك الله خيرا
  19. لو عايز استدعي التصنيفات مع بعض فقط دون الـ items كيف يكون الاستعلام
  20. قمت باضافة المفاتيح كما أوضحت..يعطيني رسالة can't add or update a child row #1452 - Cannot add or update a child row: a foreign key constraint fails (`project`.`#sql-dc8_186`, CONSTRAINT `#sql-dc8_186_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `items` (`item_id`))
  21. ممكن تكملة الجدول الهرمي الواحد مع كتابة الاستعلام
  22. اللى تعلمته انى لما اربط جدولين اضع foreign key واحد فى احد الجدولين واجعله يشير للجدول الاخر.. انت كده استخدمت two foreign keys واحد فى جدول الـ item والتاني فى الجدول المربوط معه وهو الـ category .. صح كده؟؟ لو عندك لينك لفيديوهات عملية.. اكون شاكر لو ارسلت اللينك
  23. انت كده ربطت جدول الـ item مع جداول التصنيفات الثلاث.. لماذا لم تربط جداول التصنيفات الثلاث مع بعضها البعض بحيث يتفرع عن التصنيف الرئيسي (category) تصنيفان تابعان هما (sub-category1 & sub-category2) عشان لما اضيف الـ item تبع تصنيف فرعي اعرف أوصل للأب والأب الأكبر ؟ تقصد اني محتاج 3 جداول وسيطة زيادة على الجداول اللى انا ذكرت اسمائها فى السؤال الاول؟
  24. ما الطريقة الصحيحة لربط جدول للعناصر مع ثلاث جداول للتقسيمات كالاتى: جدول العناصر item item (item_id, item_name) جداول التصنيفات category, sub- category 1, sub-category 2 category(category_id, category_name) sub-category1(sub-category1_id, sub-category1_name) sub-category2(sub-category2_id, sub-category2_name) بحيث أستطيع ان استدعي اسفل العنصر أسماء كل جداول التقسيمات التابعة له
  25. المشكلة كانت خطأ في صفحة php وتم حلها .. شكرا أخي وشكرا لحسوب.. أنتم موقعي المفضل من الان
×
×
  • أضف...