Jump to content

How to display images in one straight line using php html?


georgelvc

Recommended Posts


function draw($str,$checksum=false){
        global $unit,$x,$Code39,$height,$bw;
        $str=strtoupper($str);
        if ($checksum) {
            $str=$str.checksum($str);
        }
        $str='*'.$str.'*';
        $long=(strlen($str)+100)*100;
        $width=$bw*$long;
        $text=str_split($str);
        $img='';
        $img.= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"[url=http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\]http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";[/url]
        $img.= "<svg width='$width$unit' height='$height$unit' version='1.1' xmlns='
[url=http://www.w3.org/2000/svg]        
 
        foreach($text as $char){
            $img.=drawsymbol($char);
        }
 
        $img.='</svg>';
 
        return $img;
    }
 
    function drawsymbol($char){
        global $unit,$Code39,$x,$y,$dx,$bw,$fs,$dx,$yt,$bl;
        $x+=$bw;
        $img='';
        $img.= '<desc>'.htmlspecialchars($char)."</desc>\n";
        $xt=$x+$dx;
        $img.= "<text x='$xt$unit' y='$yt$unit' font-family='Arial' font-size='$fs'>$char</text>\n";
        $val =str_split($Code39[$char]);
        $len=9;
        for ($i=0; $i<$len; $i++){
            $num=(int)$val[$i];
            $w=$bw*$num;
            if(!($i % 2)){
                $img.= "<rect x='$x$unit' y='$y$unit' width='$w$unit' height='$bl$unit' fill='black' stroke-width='0' />\n";
            }
            $x += $w;
        }
        return $img;
    }
 
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="GET" action="Code39.php">
 
</form>
</body>
</html>
<?php
    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);
    
    $mcode=1000001; 
$count=0;
while ($count<=20){
    $code = isset($_GET['code']) ? $_GET['code'] :$mcode ;
    $barcode = draw($code);
 
    echo "<div style=\"float:left;\">";
    echo $mcode."<br>";
    echo $barcode."<br>";
    echo "</div>";
 
    $count++;
    $mcode++;
}
?>

post-204772-0-17071100-1499909235_thumb.png

Link to comment
Share on other sites

This is really an html question, is it not?

 

All that code, and your question boils down to this section:

 

echo "<div style=\"float:left;\">";
    echo $mcode."<br>";
    echo $barcode."<br>";
    echo "</div>";
 
See those

tags? You know what they do, don't you? If you take those out, what do you think will happen? Try this perhaps?

Link to comment
Share on other sites

The reason why I pointed you to the forum guidelines was to a) make you use code tags and b) see an honest debugging attempt from you.

 

This "Here's a wall of code I copied and pasted from the Internet, now fix it for me" doesn't work. He can help you with specific issues, but we aren't going to do your job.

 

You've posted a screen shot. Have you also looked at it? You keep increasing the left margin, which will obviously defeat any alignment attempts. If you look at the page source (or just the scroll bar of your browser), you'll also see that the calculated width of a single image is gigantic. No screen is big enough to display those images next to each other.

 

Again, those are basic debugging steps which everybody can do. Yet they make a big difference, because they show that you actually care about the problem, and they allow us to have a proper discussion.

Edited by Jacques1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.