Jump to content

[SOLVED] Autofill Spaces in Filename Output/Text?


inferium

Recommended Posts

I'm using the following code to generate a flyer-template output on the page based on values in a table. The actual page is at http://clearfrontmarketing.com/createflyer/or/

 

So, when I select one of these flyers from the dropdown list, the image name sometimes has a space in it. This makes it a bit tough to use the flyer on sites such as craigslist without going in and manually putting a %20 in every post.

 

Is there a way to autofill the spaces with %20 on the output code? Or, better yet, is there a way I can have the spaces taken out of the image filename when it is uploaded?

 

<?php
include('common/dbconnect.php');

$theID = $_POST['cID'];

if($theID != '') {
$sql = mysql_query("SELECT * FROM tblcars WHERE cID = $theID");
$row = mysql_fetch_array($sql);

$cbody = $row['cbody'];
$sql3 = mysql_query("SELECT btype FROM tblbody WHERE bID = $cbody");
$row3 = mysql_fetch_array($sql3);

$cdrive = $row['cdrive'];
$sql4 = mysql_query("SELECT dtype FROM tbldrive WHERE dID = $cdrive");
$row4 = mysql_fetch_array($sql4);
}

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Car Website</title>
<link rel="stylesheet" href="common/style.css" type="text/css" />
</head>

<body>

<------------snipsnipsniplet'sskipsomeofthis----------->

<TABLE WIDTH="600" HEIGHT="20" BORDER="0" CELLPADDING="0">
<TR>
<TD style="color:#f0f0f0;background-color:#000000">
<FONT SIZE="5"><b>'.$row['ctitle'].'</b></FONT></TD>
</TR>
<TR>
<TD>
<FONT SIZE="4"><b>'.$row['cslogan'].'</b></FONT>

</TD>
</TR>
</TABLE>

</TD>
</TR>


<TR>
<TD>
<TABLE>
<TR>
<TD WIDTH="310" ALIGN="center">

';	
			if($row['cphoto'] == '') {
				echo '<img  src="http://www.clearfrontmarketing.com/createflyer/or/images/nophoto.gif" />';
			} elseif($row['cphoto'] != '') {
				echo '<img  src="http://www.clearfrontmarketing.com/createflyer/or/images/cars/'.$row['cphoto'].'" style="width: 300px;" />';
			}
			echo '
</TD>

 

 

Thanks a bunch :)

Link to comment
Share on other sites

look

<?php
echo rawurlencode('s a s a');
?>

 

Ah, sweet. So how would I use that in this phrase? EDIT: namely, the part where cphoto is being used.

 

';   
            if($row['cphoto'] == '') {
               echo '<img  src="http://www.clearfrontmarketing.com/createflyer/or/images/nophoto.gif" />';
            } elseif($row['cphoto'] != '') {
               echo '<img  src="http://www.clearfrontmarketing.com/createflyer/or/images/cars/'.$row['cphoto'].'" style="width: 300px;" />';
            }
            echo '

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.