Jump to content

Archived

This topic is now archived and is closed to further replies.

lpxxfaintxx

Members Edit Cat Page

Recommended Posts

This page is fairly simple. It makes a mysql query and echo out all the categories owned by "$owner." It works perfectly except for one major thing. If the "$imagename" has multiple words (seperated by spaces) then it only shows the first word, leaving out the rest. I'm not really sure whats wrong, please help.

Regards,
AIM Multimedia.com

[code] <?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
opentable('Edit Categories');

$owner = $userdata['user_name'];

$sql = "SELECT * FROM `registered_cat` WHERE `owner` = '$owner'";
$result=mysql_query($sql);

// Define $color=1
$color="1";

echo '<table width="1000" border="1" align="center" cellpadding="2" cellspacing="0">';
while($rows=mysql_fetch_array($result)){
$id = $rows['id'];
if($color==1){
echo '<tr bgcolor="#eeeeee" onmouseover ="style.backgroundColor=\'#3D59AB\';" onmouseout=\'style.backgroundColor="#eeeeee"\'>
<td>'.$rows['status'].'</td><td>'.$rows['cat_name'].'</td><td>'.$rows['date'].'
<td><a href="/memberseditcat.php?editid='.$id.'">Edit</a></td>
</tr>';
// Set $color==2, for switching to other color
$color="2";
}

else {
echo '<tr bgcolor="#c0c0c0" onmouseover ="style.backgroundColor=\'#3D59AB\';" onmouseout=\'style.backgroundColor="#c0c0c0"\'>
<td>'.$rows['status'].'</td><td>'.$rows['cat_name'].'</td><td>'.$rows['date'].'</td>
<td><a href="/memberseditcat.php?editid='.$id.'">Edit</a></td>
</tr>';
// Set $color back to 1
$color="1";
}
}
$editid = $_GET['editid'];
$sql2="SELECT * FROM registered_cat WHERE id = '$editid'";
$result2=mysql_query($sql2);
$rows2=mysql_fetch_array($result2);
$catname = $rows2['cat_name'];
$catid = $rows2['id'];
$catdescription = $rows2['cat_description'];

if(isset($_GET['editid']) AND $rows2['owner'] = $owner) {
opentable('Change Information');
echo '<br /><br /> <center><body><table width="700" border="1" cellpadding="2" cellspacing="0">
  <tr>
    <td width="156">Status:</td>
    <td width="530"><form id="form1" name="form1" method="post" action="editcatprocess.php?save=1">
    <font color= "green" >Public</font>
        <input name="status" type="radio" value="public" />
        </label>
<label>
    <font color="red"> Private </font>
     <input name="status" type="radio" value="private" />
     <input name="editid2" type="hidden" value='.$catid.'>
    </label>
    <label>
    <label>
    
    <input name="Save1" type="submit" id="Save1" value="Save" />
    </label>
    </form>
    </td>
  </tr>
  <tr>
    <td>Image Name: </td>
    <td><form id="form2" name="form2" method="post" action="editcatprocess.php?save=2">
      <label>
        <input name="imagename" type="text" id="imagename" value='.$catname.' size="40" maxlength="50"> <-- Something is going wrong here or something
             <input name="editid2" type="hidden" value='.$catid.'>
        </label>
      <label>
      
      <input name="Save2" type="submit" id="Save2" value="Save">
      </label>
    </form>
    </td>
  </tr>
  <tr>
    <td height="77">Image Description: </td>
    <td><form name="imagedescription" method="post" action="editcatprocess.php?save=3">
      <label>
        <textarea name="imagedescription" cols="50" rows="3" id="imagedescription">'.$catdescription.'</textarea>
</label>
      <label>
      <input name="imagedescription2" type="submit" id="Save3" value="Save">
      </label>
           <input name="editid2" type="hidden" value='.$catid.'>
    </form>
    </td>
  </tr>
</table></center>';


}
require_once "footer.php";

?>[/code]

Sorry, I'm not a very organized coder. It may be a little hard to understand what the script does, without all the tabbing and stuff.

Share this post


Link to post
Share on other sites
I would suggest to use the "here document" syntax to output
multiple lines with $variable interpolation instead of just echo when printing all this html, that way you can mix html and variables - and this should work even with spaces if it is stored correctly in your table, look it through and try it out:
[code]
echo <<<__HTML_END

<br /><br /> <center><body><table width="700" border="1" cellpadding="2" cellspacing="0">
  <tr>
    <td width="156">Status:</td>
    <td width="530"><form id="form1" name="form1" method="post" action="editcatprocess.php?save=1">
    <font color= "green" >Public</font>
        <input name="status" type="radio" value="public" />
        </label>
<label>
    <font color="red"> Private </font>
     <input name="status" type="radio" value="private" />
     <input name="editid2" type="hidden" value="$catid">
    </label>
    <label>
    <label>

    <input name="Save1" type="submit" id="Save1" value="Save" />
    </label>
    </form>
    </td>
  </tr>
  <tr>
    <td>Image Name: </td>
    <td><form id="form2" name="form2" method="post" action="editcatprocess.php?save=2">
      <label>
        <input name="imagename" type="text" id="imagename" value="$catname" size="40" maxlength="50">
             <input name="editid2" type="hidden" value="$catid">
        </label>
      <label>

      <input name="Save2" type="submit" id="Save2" value="Save">
      </label>
    </form>
    </td>
  </tr>
  <tr>
    <td height="77">Image Description: </td>
    <td><form name="imagedescription" method="post" action="editcatprocess.php?save=3">
      <label>
        <textarea name="imagedescription" cols="50" rows="3" id="imagedescription">'$catdescription'</textarea>
</label>
      <label>
      <input name="imagedescription2" type="submit" id="Save3" value="Save">
      </label>
           <input name="editid2" type="hidden" value="$catid">
    </form>
    </td>
  </tr>
</table></center>

__HTML_END;
[/code]

Just be aware that the ending __HTML_END; or whatever you use must appear on a
line with no whitespace in front and just a semicolon in the end. no extra whitespace!

Share this post


Link to post
Share on other sites

×

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.