Jump to content

linking comment systen to template page


Recommended Posts

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

this is the view source. or do you want other code? The bad photo id comes after the comment is deleted.

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>What do you know about.......</title>
<style type="text/css">
#What {
text-align: center;
}
</style>
</head>

<body>
BAD PHOTO ID<body>
<div id="comments">
<form method="POST" action="image_show.php?id=">
<label>Name:  </label><br /><input type="text" name="name" value="" /><br /><br />

<label>Comment:  </label><br /><textarea name="comment" cols="25" rows="7"></textarea><br /><br /><br />
<input type="submit" name="submit" value="Comment" /><br />
</form></div>
<font color="red">Name:</font>  andrew<br /><br /><font color="red">Comments:</font>  <br />asshole
&nbsp&nbsp&nbsp&nbsp<a href="delete.php?id=55">Delete User</a><br /><br /><hr size="5px" width="500px"

 

Link to comment
Share on other sites

here's the image_show.php where the thumbnail is dragged into:

<!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-Type" content="text/html; charset=UTF-8" />
<title>What do you know about.......</title>
<style type="text/css">
#What {
text-align: center;
}
</style>
</head>

<body>
<?php
$hostname='g
$username='g29';
$password='gw1!';
$dbname='yg
$usertable='g

mysql_connect('g!') or die(mysql_error());
mysql_select_db("g") or die(mysql_error());

$id = (int)$_GET['id'];
if( $id > 0 ) {
  $result = mysql_query("SELECT `name`, `photopath`, `state` FROM `photo` WHERE `id` = $id") or die(mysql_error());
  
  $row = mysql_fetch_array( $result );
  echo " <img src=\"{$row['photopath']}\" height=\"400px\" width=\"350px\" />". "<br />
";
  echo $row['name']. "\n". "<br/>";
  echo $row['state']. "\n";
} else {
  echo 'BAD PHOTO ID';
}
?>
<?php
$hostname='gm';
$username='yg;
$password='g;
$dbname='g';
$usertable='g

$myconn=mysql_connect('your17iue.com', 'yi9', 'Ai!') or die(mysql_error());
mysql_select_db("iu") or die(mysql_error());

$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
if($submit)
{
    if($name&&$comment)
    {
    $query=mysql_query("INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')");

    }
    else
    {
        echo "Please fill out all the fields.";
    }
}
$query_Recordset1 = "SELECT * FROM photo WHERE id=$id";
$Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
?>
<body>
<div id="comments">
<form method="POST" action="image_show.php?id=<?php echo $row_Recordset1['id'];?>">
<label>Name:  </label><br /><input type="text" name="name" value="<?php echo "$name" ?>" /><br /><br />
<label>Comment:  </label><br /><textarea name="comment" cols="25" rows="7"></textarea><br /><br /><br />
<input type="submit" name="submit" value="Comment" /><br />
</form></div>
<?php

$query=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($query))
{
     $id=$rows['id'];
     $name=$rows['name'];
     $comment=$rows['comment'];
     $linkdel="<a href=\"delete.php?id=" . $rows['id'] . "\">Delete User</a>";
     echo '<font color="red">Name:</font>  ' . $name . '<br />' . '<br />' . '<font color="red">Comments:</font>  ' . '<br />' . $comment . '&nbsp' . '&nbsp' .
      '&nbsp' . '&nbsp' .  $linkdel . '<br />' . '<br />' . 
     '<hr size="5px" width="500px" color="blue" />'  ;    
}
?>
</body>
</html>

 

and heres the delete.php

<?php
header("Location: image_show.php?id={$row_Recordset1['id']}");
require('connect.php');
$deleteid=$_GET['id'];
mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error());
?>

 

i was thinking of putting something like this in delete.php "<img src={$row_Recordset1['photopath']}"; not sure

Link to comment
Share on other sites

in delete.php...where is your $row_Recordset1['id'] coming from...you must set up your query again before using this for your redirect

<?php
header("Location: image_show.php?id={$row_Recordset1['id']}");
require('connect.php');
$deleteid=$_GET['id'];
mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error());
?>

Link to comment
Share on other sites

from here: Irealized im using to different connect scripts myconn.php and connect.php

<!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-Type" content="text/html; charset=UTF-8" />
<title>The List</title>
<style type="text/css">
#a {
text-decoration: none;
}
</style>
</head>

<body>

<div id="header"></div>


<?php require_once('myconn.php');

if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
    if (PHP_VERSION < 6) {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }
    
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
    switch ($theType) {
      case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
      case "long":
      case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
      case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
      case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
      case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
    }
    return $theValue;
  }
}

$maxRows_Recordset1 = 40;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_myconn, $myconn);
//Added ID
$query_Recordset1 = "SELECT `id`, `name`, `photopath`, `state` FROM photo ORDER BY `name` ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $myconn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<div id="photos">
  <table border="1" bordercolor="#000000">
    <?php $i=0;
    $numperpage=10; ?>
    <?php do { ?>
      <?php if ($i%$numperpage==0) echo "<tr>"; ?>
    <td align="center">
      
      <a href="image_show.php?id=<?php echo $row_Recordset1['id'];?>"><img src='<?php echo $row_Recordset1['photopath'] ;?>' height="100" width="100"/></a>
      <br/>
<?php echo $row_Recordset1['name']; ?><br/> <?php echo $row_Recordset1['state']; ?></td>
      <?php $i++;
      if ($i%$numperpage==0) echo "</tr>"; ?>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  </table>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
</body>
</html>

Link to comment
Share on other sites

im sorry man but I'm just way too confused right now. My brain feels like it gonna ooze out through my ears.

 

I put this in still bad photo id but I'm pretty sure the query is wrong. I'm not fully grasping this part. Sorry for being a pain. We've been on this for so long

 

<?php
header("Location: image_show.php?id={$row_Recordset1['id']}");
require('connect.php');
mysql_select_db($database_con, $con);

$query= mysql_query( "SELECT `id` FROM photo"); 
$row_id = mysql_fetch_assoc($query);
$deleteid=$_GET['id'];
mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error());
?>

Link to comment
Share on other sites

make it this

<?php

require('connect.php');

mysql_select_db($database_con, $con);

 

$query= mysql_query( "SELECT id FROM photo");

$row_id = mysql_fetch_assoc($query);

header("Location: image_show.php?id={$row_id['id']}");

 

$deleteid=$_GET['id'];

mysql_query("DELETE FROM comment WHERE id='$deleteid'") or die(mysql_error());

?>

Link to comment
Share on other sites

I think it may be time to stop. Either that or I'm going to smash my computer. BAD PHOTO ID. I have no idea what else to do. First it was the header changed that than it's back to Bad photo id.

 

yeah im getting rather frustrated myself...but i will leave you with this....the way that you got the photo id's for the photos so when you click on a photo it shows correctly, you want to use that exact same method on everything that will be either redirecting to that page, or submitting to that page, so that you do not lose your $_GET['photoid']; since you have a dynamic url in (image_show?id=), it is crucial that you maintain the correct id on the end of the url, so that you do not lose the ability to get that id via $_GET['photoid'], that is whats hapening here. when you redirect to the image_show page again after deleting your comment, you are losing that id...i would actually advise that you write your "delete comment" code on your image_show.php page. That way there is no need to redirect and you wont lose your photoid

Link to comment
Share on other sites

thats a good idea. Im going to try that. Again thanks so much for all the help. You have no idea how much i appreciate it. If anything else and hopefully there wont be, I'll save it for tomorrow. I think I need to take a break than look at everything again because its all become one big mess of code to me. I'll talk to you later. Thanks

Link to comment
Share on other sites

thats a good idea. Im going to try that. Again thanks so much for all the help. You have no idea how much i appreciate it. If anything else and hopefully there wont be, I'll save it for tomorrow. I think I need to take a break than look at everything again because its all become one big mess of code to me. I'll talk to you later. Thanks

good idea..sometimes its good to step away and come back later..if you ever need help with anything else il be here..

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.