@No4NaMe

Как правильно оформить checkbox?

Имеется скрипт whois првоерка домена на занятость, но в нем не правильно оформлены checkbox все в один ряд. Подскажите как в этом скрипте упорядочить их по 2 в ряд что бы не потерять ширину input потмоу что они как-то взаимосвязаны.

<?php
/*************************************************
 * Max's Whois
 *
 * Version: 1.0
 * Date: 2007-11-28
 *
 ****************************************************/

class maxWhois{

    var $serverList;
    var $tr = 0;
    
function maxWhois(){   

        $this->serverList[0]['top']      = 'com';
	$this->serverList[0]['server']   = 'whois.crsnic.net';
	$this->serverList[0]['response'] = 'No match for';
	$this->serverList[0]['check']    = true;
	
	$this->serverList[1]['top']      = 'net';
	$this->serverList[1]['server']   = 'whois.crsnic.net';
	$this->serverList[1]['response'] = 'No match for';
	$this->serverList[1]['check']    = false;

	$this->serverList[2]['top']      = 'org';
	$this->serverList[2]['server']   = 'whois.publicinterestregistry.net';
	$this->serverList[2]['response'] = 'NOT FOUND';
	$this->serverList[2]['check']    = false;
	
	$this->serverList[3]['top']      = 'info';
	$this->serverList[3]['server']   = 'whois.afilias.net';
	$this->serverList[3]['response'] = 'NOT FOUND';
	$this->serverList[3]['check']    = false;
	
	$this->serverList[4]['top']      = 'name';
	$this->serverList[4]['server']   = 'whois.nic.name';
	$this->serverList[4]['response'] = 'No match';
	$this->serverList[4]['check']    = false;
	
	$this->serverList[5]['top']      = 'us';
	$this->serverList[5]['server']   = 'whois.nic.us';
	$this->serverList[5]['response'] = 'Not found:';
	$this->serverList[5]['check']    = false;

	$this->serverList[6]['top']      = 'biz';
	$this->serverList[6]['server']   = 'whois.nic.biz';
	$this->serverList[6]['response'] = 'Not found';
	$this->serverList[6]['check']    = false;

	$this->serverList[8]['top']      = 'tv';
	$this->serverList[8]['server']   = 'whois.internic.net';
	$this->serverList[8]['response'] = 'No match for';
	$this->serverList[8]['check']    = false;
}

function showHeader(){
?>

<?php
}

function showWhoisForm(){
?>
<table width="100%" ><tr><td>
            <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" class="form-search-2 with-dropdown clearfix">
	    <input name="domain" type="text" autocomplete="on"  />
            <div><button class="custom-btn big invers" name="submitBtn" type="submit">ПРОВЕРИТЬ</button></div>
</td></tr><tr>
            <?php
            	$i = 6;
                foreach ($this->serverList as $value) {
                    if ($value['check'] == true) $checked=" checked ";
            		else $checked = " ";
            		
            		echo '<td style="width:66px;"><input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'].'</td>';
                    $i++;            		
            		if ($i > 0) {
            		    $i = 0;
            		    echo '</tr><tr>';
            		}
            	}
            	
            ?>	
				</tr>
				</table>			
            </form>
<?php
}

function showFooter(){
?>

<?php
}

function processWhois(){
    $this->showHeader();

    if (!isset($_POST['submitBtn'])){
        $this->showWhoisForm();
    } else {

        $domainName = (isset($_POST['domain'])) ? $_POST['domain'] : '';
        
       	for ($i = 0; $i < sizeof($this->serverList); $i++) {
       		$actTop = "top_".$this->serverList[$i]['top'];
       		$this->serverList[$i]['check'] = isset($_POST[$actTop]) ? true : false;
       	}

        // Check domains only if the base name is big enough
        if (strlen($domainName)>2){
           	for ($i = 0; $i < sizeof($this->serverList); $i++) {
	       		if ($this->serverList[$i]['check']){
			     	$this->showDomainResult($domainName.".".$this->serverList[$i]['top'],
			     	                        $this->serverList[$i]['server'],
			     	                        $this->serverList[$i]['response']);
			    }
		    }
        }
        $this->showWhoisForm();
        
    }
    $this->showFooter();

}

function showDomainResult($domain,$server,$findText){
   if ($this->tr == 0){
       $this->tr = 1;
       $class = " class='tr2'";
   } else {
       $this->tr = 0;
       $class = "";
   }
   if ($this->checkDomain($domain,$server,$findText)){
      echo "<tr $class><td>$domain</td><td class='ava'>Свободен <a href='/'>Зарегистрировать</a></td></tr>";
   }
   else echo "<tr $class><td>$domain</td><td class='tak'>Занят</td></tr>";
}

function checkDomain($domain,$server,$findText){
    $con = fsockopen($server, 43);
    if (!$con) return false;
        
    // Send the requested doman name
    fputs($con, $domain."\r\n");
        
    // Read and store the server response
    $response = ' :';
    while(!feof($con)) {
        $response .= fgets($con,128); 
    }
        
    // Close the connection
    fclose($con);
        
    // Check the response stream whether the domain is available
    if (strpos($response, $findText)){
        return true;
    }
    else {
        return false;   
    }
}

}
?>
  • Вопрос задан
  • 248 просмотров
Пригласить эксперта
Ответы на вопрос 1
aliencash
@aliencash
Партизан
Этот фрагмент:

<?php
            	$i = 6;
                foreach ($this->serverList as $value) {
                    if ($value['check'] == true) $checked=" checked ";
            		else $checked = " ";
            		echo '<td style="width:66px;"><input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'].'</td>';
                    $i++;            		
            		if ($i > 0) {
            		    $i = 0;
            		    echo '</tr><tr>';
            		}
            	}
            ?>


замените на:

<?php
            	$i = 3;
                foreach ($this->serverList as $value) {
                    if ($value['check'] == true) $checked=" checked ";
            		else $checked = " ";
            		echo '<td style="width:66px;"><input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'].'</td>';
                    $i++;
                    if ($value['check'] == true) $checked=" checked ";
            		else $checked = " ";
            		echo '<td style="width:66px;"><input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'].'</td>';
                    $i++;
            		if ($i > 0) {
            		    $i = 0;
            		    echo '</tr><tr>';
            		}
            	}
            ?>


Пишу примерно, отлаживайте сами...
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы