Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. sorry, the script i posted is missing stuff and to complex try this one if ($_SESSION['logged_in'] == true) { if (isset($_GET['edit'])) { if ((int) $_GET['edit'] > 0) { $userid = $_GET['edit']; $sql = "SELECT * FROM hayleyedit WHERE `page_name`='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $welcome = $row['content']; ?> <p>Editing <?php echo "$page_id"; ?></p> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><textarea name="content" cols="60" rows="20" title="Edit Site Content"><?php echo "$welcome"; ?></textarea><br /><input type="submit" value="Change" title="Save Changes"/></form> <?php if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"live_edit.php\">Return to Members Page</a>"; exit(); } exit(); } else { echo "Unknown User ID! <br />"; echo "<a href=\"live_edit.php\">Return to Members Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT page_name, content FROM hayleyedit"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { echo "User List:<br />"; while ($row = mysql_fetch_assoc($result)) { echo '<table border="1"><tr><td><a href="?id=' . $row['page_name'] . '">' . $row['content'] . '</a></td></tr></table>'; } } } else { header("Location:http://".$_SERVER[HTTP_HOST]); }
  2. ok, i am now using this , if ($_SESSION['logged_in'] == true) { if (isset($_GET['edit'])) { if ((int) $_GET['edit'] > 0) { $userid = $_GET['edit']; $sql = "SELECT * FROM hayleyedit WHERE `page_name`='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $welcome = $row['content']; ?> <p>Editing <?php echo "$page_id"; ?></p> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><textarea name="content" cols="60" rows="20" title="Edit Site Content"><?php echo "$welcome"; ?></textarea><br /><input type="submit" value="Change" title="Save Changes"/></form> <?php if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"live_edit.php\">Return to Members Page</a>"; exit(); } exit(); } else { echo "Unknown User ID! <br />"; echo "<a href=\"live_edit.php\">Return to Members Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT page_name, content FROM hayleyedit"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { echo "User List:<br />"; while ($row = mysql_fetch_assoc($result)) { echo '<table border="1"><tr><td><a href="?id=' . $row['page_name'] . '">' . $row['content'] . '</a></td></tr></table>'; } } } else { header("Location:http://".$_SERVER[HTTP_HOST]); } what can i replace these with > 0 as i am using page names like, index.php not 1, 2 etc.
  3. i am using sessions on each page, the session is set to a varaible with the page name in it , how can i make it so that if you visit the page editor it gives you a choice of pages to edit, but if you go there through a page link it is on the correct editing part. That probably didn't make sense , so here is my code this is on each page $pagename = "index.php"; // different value on each page $_SESSION['page_name'] = $pagename; and then there is a link <td><a href="live_edit.php?edit=<?php echo $_SESSION['page_name'] ?>">Edit</a></td></tr></table> for each page for direct editing, and here is my editing page if ($_SESSION['logged_in'] == true) { $page_id = $_SESSION['page_name']; $sql = "SELECT * FROM hayleyedit WHERE `page_name`='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $welcome = $row['content']; ?> <p>Editing <?php echo "$page_id"; ?></p> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><textarea name="content" cols="60" rows="20" title="Edit Site Content"><?php echo "$welcome"; ?></textarea><br /><input type="submit" value="Change" title="Save Changes"/></form> <?php } else { header("Location:http://".$_SERVER[HTTP_HOST]); } mysql_close();
  4. erm ,it is most likely if they do have it that you have to pay for it, or if not contact about it, or move host
  5. O.O.P Object Oreintieted(can't spell) programming It looks liks the host you with doesn't support PHP
  6. this is what i use , this should help you <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { ?> <table class="welcome_port"><tr><td>Welcome this is my portfolio.</td></tr></table> <table id="portfolio"> <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } mysql_close(); ?>
  7. erm, ok i just heard this a few minutes ago, ? that sets what happens if it is true or not for example this $variable_name = (clause) ? true:false;
  8. BUMP!!! ??? :-X :-\ :'( [move]I really need help with this . Can anyone help???[/move]
  9. hmm, well there arn't many more ways (if any) of recognizing unique users.
  10. host, store there host in the database i think it's something like $_SERVER['HTTP_HOST']
  11. this is the loop i want to add. <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } mysql_close(); ?>
  12. just a little thing i noticed this <input type="text" name="eng" size="40" class="field" not closed and you should change include to require ''; incase it can;t get one it won't continue then
  13. I have this working pagination code <?php // how many rows to show per page $rowsPerPage = 1; // by default we show first page $pageNum = 1; // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; } // counting the offset $offset = ($pageNum - 1) * $rowsPerPage; $query = " SELECT image_id FROM hayleyimages " . " LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); // print the random numbers while($row = mysql_fetch_array($result)) { echo $row['val'] . '<br>'; } // ... more code here // ... the previous code // how many rows we have in database $query = "SELECT COUNT(image_id) AS numrows FROM hayleyimages"; $result = mysql_query($query) or die('Error, query failed'); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); // print the link to access each page $self = $_SERVER['PHP_SELF']; $nav = ''; for($page = 1; $page <= $maxPage; $page++) { if ($page == $pageNum) { $nav .= " $page "; // no need to create a link to current page } else { $nav .= " <a href=\"$self?page=$page\">$page</a> "; } } // ... still more code coming // ... the previous code // creating previous and next link // plus the link to go straight to // the first and last page if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">[Prev]</a> "; $first = " <a href=\"$self?page=1\">[First Page]</a> "; } else { $prev = ' '; // we're on page one, don't print previous link $first = ' '; // nor the first page link } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> "; } else { $next = ' '; // we're on the last page, don't print next link $last = ' '; // nor the last page link } // print the navigation link echo $first . $prev . $nav . $next . $last; // ... and we're done! ?> but now how do i get it to show i database entry on each page, like it should??? i have a mysql loop already working , and i want to intergrate it into this page.
  14. it echos 1, but there are 3 entries in there
  15. i am only doing this , as no one helped on my pagination problem but the step by step tutorial i am following , doesn't seem to work.
  16. i am using this code $totalCount = "SELECT image_id, COUNT(image_id) FROM hayleyimages GROUP BY image_id "; $rsCOUNT = mysql_query($totalCount, $conn) or die(mysql_error()); $rowCount = mysql_fetch_object($rsCOUNT); echo "$rowCount"; and the echo is the word Object anyone no why?? also this is the code i was told to use "SELECT COUNT (*) as 'Total' FROM mysql.helpkeyword"; mysql is there database name and helpkeyword is there table name this didn't work when i tryed it . is it outdated?
  17. i found this code, <?php $max = 2; //amount of articles per page. change to what to want $p = $_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view the news article! if(isset($_GET['act']) && $_GET['act'] == "view") { $id = $_GET['id']; $sql = mysql_query("SELECT * FROM hayleyimages WHERE image_id = '$id'"); while($r = mysql_fetch_array($sql)) { $title = $r['image_name']; $story = $r['image_caption']; $author = $r['image_link']; echo "<div><p>$title</p><p>$author</p><p>$story</p></div>"; } }else{ //view all the news articles in rows $sql = mysql_query("SELECT * FROM hayleyimages LIMIT ".$limits.",$max") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(image_id) AS tot FROM hayleyimages"),0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); //the table echo "<table><tr><td>Title</td><td>Author</td></tr><tr>"; while($r = mysql_fetch_array($sql)) { $id = $r['id']; $title = $r['title']; $author = $r['author']; echo "<td><a href='news.php?act=view&id=$id'>$title</a></td><td>$author</td>"; } //close up the table echo "</tr></table>"; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='news.php?p=$i'>$i</a>|"; } } ?> now can some explain how to intergrate it into this code, <?php require_once 'nav_bar.php'; if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; if(mysql_num_rows($result) > 0) { ?> <div id="prof_img"> <table id="portfolio_image"> <tr><th><?php echo "$imageprofname"; ?></th></tr><tr><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr><tr><td><a href="portfolio.php">Return To Gallery</a></td></tr></table></div> <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { ?> <table class="welcome_port"><tr><td>Welcome this is my portfolio.</td></tr></table> <table id="portfolio"> <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } mysql_close(); ?> </div> </body> </html> this bit in particular <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?>
  18. does that not have to be used with
  19. how can i paginate this require_once 'nav_bar.php'; if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; if(mysql_num_rows($result) > 0) { ?> <table id="portfolio_image"> <tr><th><?php echo "$imageprofname"; ?></th><td><?php echo '<a href="'.$row['image_link'].'" rel="lightbox" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$row['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$row['image_caption']. ' </a>'; ?></td></tr></table> <?php } if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { ?> <table class="welcome_port"><tr><td>Welcome this is my portfolio.</td></tr></table> <table id="portfolio"> <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> </table> <?php if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } mysql_close(); ?> </div> </body> </html> this is the exact piece that needs paginating <?php $loop = 3; $loop1 = 3; while($row=mysql_fetch_array($result)){ // Start looping table row if ($loop == 3) { echo "<tr>"; } $toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td> </td>'; $toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td> </td>'; if ($loop == 3) { echo "</tr>"; $loop=0; } } if (substr($toecho, -5) != "</tr>") { $toecho .= "</tr>"; } echo $toecho; echo $toecho1; } ?> i have tried pagination tutorials, but i can't ever get it to work
  20. thanks, had to change some things, but it works
×
×
  • 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.