Jump to content

y2yang

Members
  • Posts

    59
  • Joined

  • Last visited

    Never

Everything posted by y2yang

  1. Thanks anupamsaha. Works like a charm. I owe you one.
  2. hello, can somebody help me here? Am I using the referrer correctly here? It's not working. I'm having syntax error.
  3. I don't think I did this part correctly: history.go(-1); <? if($session->logged_in){ history.go(-1); } else{ ?>
  4. header("Location: ".$session->referrer-1); I wanted for the referrer to go back twice. My situation: From home.php, I got to login.php, and login.php send a request to process.php, once process.php done the processing, it send the page back to login.php. What I wanted is for process.php to send the page back to home.php. How do I go about doing that? Here is what I have in process.php: function procLogin(){ global $session, $form; /* Login attempt */ $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); /* Login successful */ if($retval){ header("Location: ".$session->referrer-1); }
  5. I got it fixed by renaming my id manually, good thing it's only 1290 rows and i have to fix only 90 rows starting with row 1207. But I can see where this is going if I would to delete say row 100th and I have over 1000 row, that's about 900 rows to rename. Me being novice, there is most likely a better way to accomplish this. The thing that bothered me is that on id 1291, my last row, the image that showed up was in row 1290 and not the image from row 1291, as if row 1291 doesn't exist at all. I set it so that if the url's id is anything higher than the last row id, that it would return the real last row instead. My problem is probable better explained in an essay so I'll just move on but please answer this one last question. Does re-indexing my column id require it done manually or with a script? On the side note, I could create a row 1207 and put an image in the row 1207 that say "image no longer exist" so people linking to my pages would not get a different page when they visited the pages, so as to be consistence.
  6. Can I re-auto increment my id so no gap would be in between any number? say i have rows 1206 and 1208, but not 1207, and I want to re-number my id so no gap like 1207 is there. I use a code that call the title of the next and previous row as my link, but since there is no title on 1207, there is no title and and I don't want that. I use a + and - 1 code.
  7. <?php echo "<img src=\".../wallpaper/<?php print $row['img_large']; ?>"\>"; ?>
  8. I can create a new column no problem. What function or code would I need to achieve so that mysql would update the column everytime it's accessed? If it required long code, I can just go google it up, but if it's not long code can you show me how?
  9. How can I get this code: <select name="SearchField" id="SearchField" style="width:80px;" class="vam"><option value="title">Title</option><option value="body">Body</option></select> To achieve something like this code: <input type="checkbox" name="title" value="on" /> <input type="checkbox" name="body" value="on" /> What I want is to get a url something like this: .../list.php?SearchText=...&body=on&title=on I wanted the url to somehow, have BODY and TITLE as a string up there. I know this is not considered php but I don't know where else to post it.
  10. I would like to perform two condition in one else if statement. Here is my code: <?php } // end if elseif($Article == "1" && $numrows == 0){ ?> Don't know if this is right, but certainly it's not showing what I wanted. BTW, what is &, &&, % used mainly for in php? ...and by any chance would someone explain what this code do for me? Thanks. Been having it for a while but still don't know how it works; I don't feel so proud of myself ??? <?php if (!empty($count) && $count % $half_point == 0) { ?>
  11. Need for php to get field before current field and field after current field from mysql, sort of like a next and previous, only they're text file. Example: There are two of this in my HTML table: <?php print $row['title_main']; ?> I want the first one to do something like this: <?php print $row['title_main'] + 1; ?> And the second one to : <?php print $row['title_main'] -1; ?> Here is my code: <tr style="height:25px;"> <td><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_prev.gif" class="vam" alt="" /></td> <td class="tal fc14"><span style="margin:0 0 0 5px;"><a href="read.php?nPageNo=<?php echo $_GET['nPageNo']; ?>&Article=<?php print $prevpage; ?>"><?php print $row['title_main']; ?></a></span></td> </tr> <tr style="height:1px;"><td colspan="2" class="bgc9"></td></tr> <tr style="height:25px;"> <td><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_next.gif" class="vam" alt="" /></td> <td class="tal fc14"><span style="margin:0 0 0 5px;"><a href="read.php?nPageNo=<?php echo $_GET['nPageNo']; ?>&Article=<?php print $nextpage; ?>"><?php print $row['title_main']; ?></a></span></td> </tr> I got nPageNo to get the correct link id but not the Article. Here is my query: <?php // Connect to DB. // find out how many rows are in the table $query = "SELECT COUNT(*) FROM info_all"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $img_per_page = 1; // find out total pages $totalpages = ceil($numrows / $img_per_page); // Get current page or set a default. if (isset($_GET['Article']) && is_numeric($_GET['Article'])) { // cast var as int $Article = (int) $_GET['Article']; } else { // Default page number. $Article = 1; } // end if // if current page is greater than total pages... if ($Article > $totalpages) { // set current page to last page $Article = $totalpages; } // end if // if current page is less than first page... if ($Article < 1) { // set current page to first page $Article = 1; } // end if // Get table information. $query = "SELECT * FROM info_all WHERE Article=$Article"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); $row = mysql_fetch_assoc($result); // Get previous page number. $prevpage = $Article + 1; // Get next page. $nextpage = $Article - 1; ?> The code I used to get my nPageNo id is // Get previous page number. $prevpage = $Article + 1; // Get next page. $nextpage = $Article - 1; and I used <?php print $prevpage; ?> to get previous id <?php print $nextpage; ?> to get next id I would like to achieve something similar to <?php print $row['title_main']; ?>
  12. Ok solved after some googleing around. What I needed was adding WHERE Article=$Article to my query. Sorry forgot to mention field Article was my PRIMARY key.
  13. The print data works now but I can't seem to get the next row of data to display on my next ID. URL read.php?nPageNo=1&Article=2 should have displayed the second row of data but somehow it keep displaying the first row of data. I don't know what to do.
  14. Ok I got the data to show on my page but have come into encounter with another issue. On my next URL id, I can't get the next row of data to show. It kep showing the first row only. If URL = read.php?nPageNo=1&Article=1 I would like for row 1 to show. If URL = read.php?nPageNo=1&Article=2 I would like for row 2 to show. and show on. The 5 fields that I used from one row is title_main, date, img, title_sub, body_txt Here is the revised code of my previous one. <?php // Connect to DB. // Get table information. $query = "SELECT * FROM info_all"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); $row = mysql_fetch_assoc($result); // Get current page or set a default. if (isset($_GET['Article']) && is_numeric($_GET['Article'])) { // cast var as int $currentpage = (int) $_GET['Article']; } else { // Default page number. $currentpage = 1; } // end if // Get previous page number. $prevpage = $currentpage - 1; // Get next page. $nextpage = $currentpage + 1; ?> <!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> <title>Vicki Zhao Wei Cafe</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="imagetoolbar" content="no" /> </head> <body id="BodyArea" style="background:url('http://file.vickizhao.net/files/2008/0124/bg_01.jpg') center top;" onload="execOnloadHandle();"> <table> <colgroup> <col width="50%" /><col width="1000" /><col width="50%" /> </colgroup> <tr> <td></td> <td> <div id="HeaderArea"> <div id="HeaderContent"> <?php require("http://vickizhao.net/starhome/include/Header.php"); ?> </div> </div> <div id="SubContentArea" style="background:url('http://file.vickizhao.net/files/2007/0827/white.jpg');"> <div id="SubPageTitle" style="background:url('http://file.vickizhao.net/files/2008/0124/top_060606_01.jpg');"> <table> <tr style="height:120px;"> <td class="vam"> <?php require("http://vickizhao.net/starhome/include/StarName.php"); ?> </td> </tr> </table> </div> <div id="SubMenu" style="background:black repeat;"> <?php require("http://vickizhao.net/starhome/include/SubMenu.php"); ?> </div> <div id="SubInner"></div> <div id="SubContent"> <script type="text/javascript">//addOnloadHandle("openReply('http://image.vickizhao.net')");</script> <div style="width:580px;margin:0 auto;"> <!-- Title Start --> <div id="StarhomeTitle"> <img src="http://image.vickizhao.net/title/txt_sub_starhome7.gif" class="vam" alt="" /> </div> <!-- Title End --> <table width="100%"> <colgroup> <col width="55px" /><col width="525" /><!--<col width="405" /><col width="55px" /><col width="65px" />--> </colgroup> <tr><td colspan="4"><div class="BLine2"></div></td> </tr> <tr style="height:28px;"> <td class="vam tac"><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_title.gif" alt="" /></td> <td class="vam tal"><span style="margin:0 0 0 5px;"><?php print $row['title_main']; ?><?php print $row['date']; ?></span></td> <!-- <td class="vam tac"><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_date.gif" alt="" /></td> <td class="vam tal"><span>2008-12-09</span></td> --> </tr> <tr><td colspan="4"><div class="line2"></div></td></tr> <!-- photo description --> <tr> <td colspan="4" class="tac"> <div id="strContent" style="margin:20px 0 20px 0;width:580px;overflow:auto;"> <?php print $row['img']; ?><br /> <div class="lh20" style="margin:10px 0 0 0;"><P><?php print $row['title_sub']; ?></P> <P> </P> <P><?php print $row['body_txt']; ?></P></div> </div> <script type="text/javascript">reSizeImgContent('strContent',580);</script> </td> </tr> <tr><td colspan="4"><div class="BLine2"></div></td></tr> <tr style="height:35px;" class="tar"> <td colspan="4"><a href="../list.php?Pid=<?php echo $_GET['Article']; ?>"><img src="http://image.vickizhao.net/style_guide/btn/btn_starhome_list.gif" class="hand" alt="" /></a></td> </tr> </table> <!-- start comments --> <?php require("comment/comm.php"); ?> <!-- end comments --> <p style="margin:40px;"></p> <!-- begin prev / next --> <table width="100%"> <colgroup> <col width="70" /><col /> </colgroup> <tr style="height:2px;"><td colspan="2" class="bgc9"></td></tr> <tr style="height:25px;"> <td><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_prev.gif" class="vam" alt="" /></td> <td class="tal fc14"><span style="margin:0 0 0 5px;"><a href="read.php?nPageNo=<?php echo $_GET['nPageNo']; ?>&Article=<?php print $prevpage; ?>"><?php print $row['title_main']; ?></a></span></td> </tr> <tr style="height:1px;"><td colspan="2" class="bgc9"></td></tr> <tr style="height:25px;"> <td><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_next.gif" class="vam" alt="" /></td> <td class="tal fc14"><span style="margin:0 0 0 5px;"><a href="read.php?Pid=<?php echo $_GET['nPageNo']; ?>&Article=<?php print $nextpage; ?>"><?php print $row['title_main']; ?></a></span></td> </tr> <tr style="height:2px;"><td colspan="2" class="bgc9"></td></tr> </table> <p style="margin:40px;"></p> <div class="tal" style="margin:0 0 3px 0;"><img src="http://image.vickizhao.net/starhome/photo/write/txt_photolist.gif" class="vam" alt="" /></div> <div class="line2"></div> <p style="margin:22px;"></p> <!-- photo list --> <?php include("../photo_list.php"); ?> <p style="margin:20px;"></p> </div> </div> <div id="SubImage"> <?php require("../include/SubImage.php"); ?> </div> </div> </td> <td></td> </tr> <tr><td></td><td><div id="FooterArea"></div></td><td></td></tr> </table> </body> </html>
  15. I called some data from my MYSQL data, can you check to see if I am doing it correctly in my HTML? My data is not showing up on my page. <?php // Connect to DB. // Get table information. $query = "SELECT * FROM info_all"; $result = mysql_query($query, $conn) or trigger_error("SQL", E_USER_ERROR); $row = mysql_fetch_row($result); // Get current page or set a default. if (isset($_GET['Article']) && is_numeric($_GET['Article'])) { // cast var as int $currentpage = (int) $_GET['Article']; } else { // Default page number. $currentpage = 1; } // end if // Get previous page number. $prevpage = $currentpage - 1; // Get next page. $nextpage = $currentpage + 1; ?> <!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> <title>Vicki Zhao Wei Cafe</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="imagetoolbar" content="no" /> </head> <body id="BodyArea" style="background:url('http://file.vickizhao.net/files/2008/0124/bg_01.jpg') center top;" onload="execOnloadHandle();"> <table width="100%"> <colgroup> <col width="55px" /><col width="525" /><!--<col width="405" /><col width="55px" /><col width="65px" />--> </colgroup> <tr><td colspan="4"><div class="BLine2"></div></td> </tr> <tr style="height:28px;"> <td class="vam tac"><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_title.gif" alt="" /></td> <td class="vam tal"><span style="margin:0 0 0 5px;"><?php print $row['title_main']; ?><?php print $row['date']; ?></span></td> <!-- <td class="vam tac"><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_date.gif" alt="" /></td> <td class="vam tal"><span>2008-12-09</span></td> --> </tr> <tr><td colspan="4"><div class="line2"></div></td></tr> <!-- photo description --> <tr> <td colspan="4" class="tac"> <div id="strContent" style="margin:20px 0 20px 0;width:580px;overflow:auto;"> <?php print $row['img']; ?><br /> <div class="lh20" style="margin:10px 0 0 0;"><P><?php print $row['title_sub']; ?></P> <P> </P> <P><?php print $row['body_txt']; ?></P></div> </div> <script type="text/javascript">reSizeImgContent('strContent',580);</script> </td> </tr> <tr><td colspan="4"><div class="BLine2"></div></td></tr> <tr style="height:35px;" class="tar"> <td colspan="4"><a href="../list.php?Pid=<?php echo $_GET['Article']; ?>"><img src="http://image.vickizhao.net/style_guide/btn/btn_starhome_list.gif" class="hand" alt="" /></a></td> </tr> </table> <!-- start comments --> <?php require("comment/comm.php"); ?> <!-- end comments --> <p style="margin:40px;"></p> <!-- begin prev / next --> <table width="100%"> <colgroup> <col width="70" /><col /> </colgroup> <tr style="height:2px;"><td colspan="2" class="bgc9"></td></tr> <tr style="height:25px;"> <td><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_prev.gif" class="vam" alt="" /></td> <td class="tal fc14"><span style="margin:0 0 0 5px;"><a href="read.php?nPageNo=<?php echo $_GET['nPageNo']; ?>&Article=<?php print $prevpage; ?>"><?php print $row['title_main']; ?></a></span></td> </tr> <tr style="height:1px;"><td colspan="2" class="bgc9"></td></tr> <tr style="height:25px;"> <td><img src="http://image.vickizhao.net/style_guide/icn/icn_starhome_next.gif" class="vam" alt="" /></td> <td class="tal fc14"><span style="margin:0 0 0 5px;"><a href="read.php?Pid=<?php echo $_GET['nPageNo']; ?>&Article=<?php print $prevpage; ?>"><?php print $row['title_main']; ?></a></span></td> </tr> <tr style="height:2px;"><td colspan="2" class="bgc9"></td></tr> </table> <p style="margin:40px;"></p> <div class="tal" style="margin:0 0 3px 0;"><img src="http://image.vickizhao.net/starhome/photo/write/txt_photolist.gif" class="vam" alt="" /></div> <div class="line2"></div> <p style="margin:22px;"></p> <!-- photo list --> <?php include("../photo_list.php"); ?> <p style="margin:20px;"></p> </div> </div> <div id="SubImage"> <?php require("../include/SubImage.php"); ?> </div> </div> </td> <td></td> </tr> <tr><td></td><td><div id="FooterArea">FOOTER</div></td><td></td></tr> </table> </body> </html>
  16. Thank you soooooo much Ken2k7. You are life savor for the past few weeks in my life. Anyway, my pagination is now completed all thanks to you. My next project is trying to convert my hard coded read page into programmed, in other word, automatic, I just love that word. This will help to convert my repeated of same code over 10000+ lines of code (which is just a bunch of elsesif elseif elseif lines, sad huh?) into less than 100 lines of code, and the best part, it's automatic so no need to edit everytimes I add photo to my library. Anyway for the time being, I'll like to give you a sneak peak at my hard coded read page which will be programmed....
  17. Can anyone tell me if I used the "<?php $_GET['nPageNo']>" correctly in there? <a href="http://<?php echo $_SERVER['SERVER_NAME']; ?>/starhome/photo/read/read.php?nPageNo=<?php $_GET['nPageNo']>&Article=<?php print $list['id']; ?>"> Extra info, in case you wanted to know what I am doing with the above code, or wish to achieve with it: What am I doing: I have an image pagination and when I clicked on a image to go and view it, I also implemented that image pagination in there. Example: If the current page I am on URL is: list.php?nPageNo=3 Then when I clicked on an image to go and view it, I would like for the URL to be something like this: read.php?nPageNo=3&Article=19 Where id nPageNo from list.php is transfered to read.php with &Article=THE_ARTICLE_ID Thank.
  18. Thanks Ken2k7. The code you gave me worked good. But somehow I still not see the dotted line. Can you double check the code? Thanks.
  19. Please help, I am new and will take any advice. The bottom line is I wanted to get a dotted line in between my two rows of images. The code that I used to achieve that line in hard coded is: <div style="clear:left;overflow:hidden;width:0;height:0;"></div> <p style="margin:20px;"></p> <div class="dotHLine1"></div> <p style="margin:20px;"></p> dotHLine is a class I defined in my css to get that dotted line. The completed hard coded (which included the code above) to get the two rows of images is below, it may look long but the only thing changing is the LINK URL and IMAGE PATH. <div...> <table...> <tr...> <td><a href="...view.php?id=8"><img src="...thumb8.jpg"></a></td> </tr> </table> </div> <div...> <table...> <tr...> <td><a href="...view.php?id=7"><img src="...thumb7.jpg"></a></td> </tr> </table> </div> <div...> <table...> <tr...> <td><a href="...view.php?id=6"><img src="...thumb6.jpg"></a></td> </tr> </table> </div> <div...> <table...> <tr...> <td><a href="...view.php?id=5"><img src="...thumb5.jpg"></a></td> </tr> </table> </div> // DOTTED LINE code///////////////////////////////////// <div style="clear:left;overflow:hidden;width:0;height:0;"></div> <p style="margin:20px;"></p> <div class="dotHLine1"></div> <p style="margin:20px;"></p> // DOTTED LINE code///////////////////////////////////// <div...> <table...> <tr...> <td><a href="...view.php?id=4"><img src="...thumb4.jpg"></a></td> </tr> </table> </div> <div...> <table...> <tr...> <td><a href="...view.php?id=3"><img src="...thumb3.jpg"></a></td> </tr> </table> </div> <div...> <table...> <tr...> <td><a href="...view.php?id=2"><img src="...thumb2.jpg"></a></td> </tr> </table> </div> <div...> <table...> <tr...> <td><a href="...view.php?id=1"><img src="...thumb1.jpg"></a></td> </tr> </table> </div> If I used loop to achieve that long code above, it will look like this, but without the dotted line code (and that's where my problem come in) since I can't have the dotted line to repeat after every image: <?php $query = "SELECT * FROM thumb LIMIT 0, 8"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { ?> <div...> <table...> <tr...> <td><a href="...view.php?id=<?php print $row['id']; ?>"><img src="<?php print $row['imgpath']; ?>"></a></td> </tr> </table> </div> <?php } ?> The loop will returned 8 images from my mysql row 1-8 to my HTML. The 8 images will fit into 2 rows on my page, with 4 images on top and 4 on bottom. 8 7 6 5 4 3 2 1 Now what I wanted to do is to have a dotted line in between my rows, like this: 8 7 6 5 --------- 4 3 2 1 But as you can see, loop will put the images into my HTML like this: 8 7 6 5 4 3 2 1 ; without the dotted line. What I wanted is to have something like if row = 4, then put my dotted line code after: 8 7 6 5 DOTTED LINE CODE 4 3 2 1 and my page will fit it into something like this: 8 7 6 5 -------- 4 3 2 1 With all wish, I hope I make sense and may god help me.
  20. Is this correct? $sql = 'SELECT ['id', 'imgpath'] FROM thumb'; How do you select id and imgpath from mysql?
  21. Can anyone tell me what is wrong with this? Can I do this? $page_id = $news $cid; <?php if(!isset($_GET['Pid'])) { $cid = 1; } else { $cid = (int) $_GET['Pid']; } $news = "news_"; $page_id = $news $cid; ?>
  22. You're Perfecto gevans. Yet another hero saved my day. ;D ;D ;D ;D
  23. <?php $page_id = md5(uniqid(rand(), true)); ?> like this?
×
×
  • 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.