الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

سؤال متعلق بحلقة While

بدأه islamalking في 10 يناير 2010 · 1 رد · 427 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

طبعاً احتارت ماذا اسمي الموضوع وكيف ابدأ فيه

انا عندي فكره اريد اطبقها على موقعي

ومتعلق بحلقة while

والكود كما هو موجود بالموقع

  while ($mirror_info = mysql_fetch_array ($data))
  {
    $host = get_host ($mirror_info['hostid']);
    $hostfile = $host['file'];
    $stat = $mirror_info['status'];
    if ($mirror_info['status'] == 0)
    {
      $status = 'Upload';
    }
    else
    {
      if ($mirror_info['status'] == 1)
      {
        $status = 'Retry';
        exec ('' . $php_path . ' -c ' . $config_ini . ' ' . $hostfile . ' ' . $file_id . ' ' . $stat . '  >/dev/null &');
      }
      else
      {
        if ($mirror_info['status'] == 2)
        { 

		  $status = 'Failed';
        }
        else
        {
          if ($mirror_info['status'] == 3)
          {
            $status = 'Success';
          }
        }
      }
    }

    echo '<tr>
		<td><img src=/images/' . $host['name'] . '.jpg </img></td>';
    if ($stat == 3)
    {
      if ($direct_url == '1')
      {
        echo '<td><a href=' . $mirror_info['url'] . ' target=_blank><img src=/images/click.gif border=\'0\' /></a></td>';
      }
      else
      {
        echo '<td><a href=/redirect/' . $file_id . '/' . $mirror_info['hostid'] . ' target=_blank><img src=/images/click.gif border=\'0\' /></a></td>';
      }
    }
    else
    {
      echo '<td><img src=/images/na.gif /></td>';
    }

    echo '<td>' . $mirror_info['hits'] . '</td>
	 	<td><img src=/images/' . $status . '.gif /></td>	
	 </tr>';
  }

المشكلة كلها الامر التالي علي ما اعتقد

      else
      {
        if ($mirror_info['status'] == 2)
        { 

		  $status = 'Failed';
        }

اريد في حالة كون الـ status يساوي 2 ان يعيد الحلقة من جديد بدل تنفيذ امر Failed

ارجو ان تفهمو قصدي

وارجو ان يساعدني احد لشده احتياجي لهذا الشرح

أسف لو المكان مو مناسب بس كتبت هنا الموضوع لأصحاب الخبره الذين يدخلون هنا

يعطيكم العافيه جميعاً :)

تم تعديل هذه المشاركة بواسطة islamalking في 10 يناير 2010 في 00:02

#2

ها هو الكود اخى العزيز:

<?
function check_status($mirror_info)
{
    global $direct_url, $php_path, $config_ini, $hostfile, $file_id;

  $host = get_host ($mirror_info['hostid']);
  $hostfile = $host['file'];
  $stat = $mirror_info['status'];
  if ($mirror_info['status'] == 0)
  {
    $status = 'Upload';
  }
  else
  {
    if ($mirror_info['status'] == 1)
    {
      $status = 'Retry';
      exec ('' . $php_path . ' -c ' . $config_ini . ' ' . $hostfile . ' ' . $file_id . ' ' . $stat . '  >/dev/null &');
    }
    else
    {
      if ($mirror_info['status'] == 2)
      {
          check_status($mirror_info);
      }
      else
      {
        if ($mirror_info['status'] == 3)
        {
          $status = 'Success';
        }
      }
    }
  }

  echo '<tr>
              <td><img src=/images/' . $host['name'] . '.jpg </img></td>';
  if ($stat == 3)
  {
    if ($direct_url == '1')
    {
      echo '<td><a href=' . $mirror_info['url'] . ' target=_blank><img src=/images/click.gif border=\'0\' /></a></td>';
    }
    else
    {
      echo '<td><a href=/redirect/' . $file_id . '/' . $mirror_info['hostid'] . ' target=_blank><img src=/images/click.gif border=\'0\' /></a></td>';
    }
  }
  else
  {
    echo '<td><img src=/images/na.gif /></td>';
  }

  echo '<td>' . $mirror_info['hits'] . '</td>
              <td><img src=/images/' . $status . '.gif /></td>
       </tr>';
}




while ($mirror_info = mysql_fetch_array ($data))
{
   check_status($mirror_info);
}
?>

لقد قمت بجعل الكود فى فنكشن بحيث فى الحالة رقم 2 يقوم بنداء الفنكشن مرة اخرى

ولله التوفيق

تم تعديل هذه المشاركة بواسطة القادرى في 12 يناير 2010 في 19:53

مواضيع مشابهة