-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
with the code you provided , you removed the pagination which is what i want to add to it
-
that bit of code, was written by someone to break line every 3 entrys
-
it still only echoes the first letter of the word,
what i am trying to do is paginate this
<?php require_once 'header.php'; $pageid = "2"; $sq1 = "SELECT * FROM hayleyedit WHERE page_id ='{$pageid}' LIMIT 0,1;"; $result1 = mysql_query($sq1) or die("Error:" . mysql_error()); $rom = mysql_fetch_assoc($result1); $content_port = $rom['content']; 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><?php echo"$content_port"; ?> <?php if ($_SESSION['logged_in'] == true) { ?> <td><a href="live_edit.php?editpageid=<?php echo $_SESSION['page_name'] ?>">Edit</a></td></tr></table> <?php } else { ?> </td></tr></table> <?php } ?> <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"; } ?> </div> <?php require_once 'footer.php'; ?>
-
-
how can this work
<?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_link, image_name, image_id, image_caption FROM hayleyimages LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); // print the random numbers while(list($val) = mysql_fetch_array($result)) { echo "$val"; ?> <table id="portfolio_image"> <tr><th><?php echo .$val['image_name'].; ?></th></tr><tr><td><?php echo '<a href="'.$val['image_link'].'" rel="lightbox" title="'.$val['image_caption']. '" ><img src="'.$val['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$val['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$val['image_caption']. ' </a>'; ?></td></tr><tr><td><a href="portfolio.php">Return To Gallery</a></td></tr></table><br> <?php } echo '<br>'; // 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); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one 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 = ' [Prev] '; // we're on page one, don't enable 'previous' link $first = ' [First Page] '; // nor 'first page' link } // print 'next' link only if we're not // on the last page 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 = ' [Next] '; // we're on the last page, don't enable 'next' link $last = ' [Last Page] '; // nor 'last page' link } // print the page navigation link echo $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong>" . $next . $last; ?>
this bit inparticular
<?php $query = "SELECT image_link, image_name, image_id, image_caption FROM hayleyimages LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); // print the random numbers while(list($val) = mysql_fetch_array($result)) { echo "$val"; ?> <table id="portfolio_image"> <tr><th><?php echo .$val['image_name'].; ?></th></tr><tr><td><?php echo '<a href="'.$val['image_link'].'" rel="lightbox" title="'.$val['image_caption']. '" ><img src="'.$val['image_link'].'"width="200px" /></a>'; ?></td><td width="200px"><?php echo 'Image ID :'.$val['image_id'].''; ?></td></tr><tr><td><?php echo ' '.$val['image_caption']. ' </a>'; ?></td></tr><tr><td><a href="portfolio.php">Return To Gallery</a></td></tr></table><br> <?php }
it echoes the letter
i
but i know that the database has information and that it is connected and that all the words are right(i think), a similar code is working on my site, and i need to add pagination to it.
I've found out that the
i
is the first letter of the image_link
-
edited for easier reading, but still have a problem.
is it my update statement?
"UPDATE hayleyedit SET content = '{$update}' WHERE page_id = '{$page_id}'";
-
i am connecting to the database before the code you can see,
this is my whole code (without connection details)
<?php if(isset($_POST['save'])) { $update =mysql_real_escape_string($_POST['content']); $query_update = "UPDATE hayleyedit SET content = '{$update}' WHERE page_id = '{$page_id}'"; mysql_query ($query_update) or die("Error:" . mysql_error()); } if ($_SESSION['logged_in'] == true) { if (isset($_GET['editpageid'])) { if ((int) $_GET['editpageid'] > 0) { $page_id = $_GET['editpageid']; $sql = "SELECT * FROM hayleyedit WHERE page_id ='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql) or die("Error:" . mysql_error()); $row = mysql_fetch_assoc($result); $welcome = $row['content']; $name = $row['page_name']; ?> <p>Editing <?php echo "$name"; ?></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" name="save"/></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 Page List</a>"; exit(); } exit(); } else { echo "Unknown Page ID! <br />"; echo "<a href=\"live_edit.php\">Return to Page List</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT page_name, content, page_id FROM hayleyedit ORDER BY page_id"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { echo "Page List:<br />"; while ($row = mysql_fetch_assoc($result)) { echo '<table border="1"><tr><td><a href="?editpageid=' . $row['page_id'] . '">' . $row['page_name'] . '</a></td></tr></table>'; } } } else { header("Location:http://".$_SERVER[HTTP_HOST]); } mysql_close(); ?> </div> </div>
I need the update to update the content with the page ID it has, that is in the URL as
?editpageid=(whatever id)
-
if's it JS shouldn't it be enclosed in script tags?
<script></script> (there should be more stuff in the tags like language, someone might be able to help there)
-
this is my code
<?php if ($_SESSION['logged_in'] == true) { if (isset($_GET['editpageid'])) { if ((int) $_GET['editpageid'] > 0) { $page_id = $_GET['editpageid']; $sql = "SELECT * FROM hayleyedit WHERE page_id ='{$page_id}' LIMIT 0,1;"; $result = mysql_query($sql) or die("Error:" . mysql_error()); $row = mysql_fetch_assoc($result); $welcome = $row['content']; $name = $row['page_name']; ?> <p>Editing <?php echo "$name"; ?></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" name="save"/></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 Page List</a>"; exit(); } exit(); } else { echo "Unknown Page ID! <br />"; echo "<a href=\"live_edit.php\">Return to Page List</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT page_name, content, page_id FROM hayleyedit ORDER BY page_id"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { echo "Page List:<br />"; while ($row = mysql_fetch_assoc($result)) { echo '<table border="1"><tr><td><a href="?editpageid=' . $row['page_id'] . '">' . $row['page_name'] . '</a></td></tr></table>'; } } } else { header("Location:http://".$_SERVER[HTTP_HOST]); } if(isset($_POST['save'])) { $update =mysql_real_escape_string($_POST['content']); $query_update = "UPDATE hayleyedit SET content = '{$update}' WHERE page_id = '{$page_id}'"; mysql_query ($query_update) or die("Error:" . mysql_error()); } mysql_close(); ?>
there are no errors , it reloads the page after i submit it and my changes aren't made, and they are not changed in th DB either. anyone help?
-
yep, forgot to mention that , you need to change some of it for yourself.
-
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]); }
-
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.
-
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();
-
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
-
BUMP NO>2
PLEASE GIVE ME SOME HELP < ANY>
-
O.O.P
Object Oreintieted(can't spell) programming
It looks liks the host you with doesn't support PHP
-
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(); ?>
-
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;
-
BUMP!!!
??? :-X :-\ :'(
[move]I really need help with this . Can anyone help???[/move]
-
hmm, well there arn't many more ways (if any) of recognizing unique users.
-
host,
store there host in the database
i think it's something like
$_SERVER['HTTP_HOST']
-
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(); ?>
-
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
-
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.
Opening directories
in PHP Coding Help
Posted
save the theme details in a mysql database