y2yang Posted May 5, 2009 Share Posted May 5, 2009 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> Link to comment https://forums.phpfreaks.com/topic/156881-solved-am-i-using-print-data-from-mysql-correctly/ Share on other sites More sharing options...
y2yang Posted May 5, 2009 Author Share Posted May 5, 2009 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> Link to comment https://forums.phpfreaks.com/topic/156881-solved-am-i-using-print-data-from-mysql-correctly/#findComment-826433 Share on other sites More sharing options...
RussellReal Posted May 5, 2009 Share Posted May 5, 2009 honestly looks good to me >.> Link to comment https://forums.phpfreaks.com/topic/156881-solved-am-i-using-print-data-from-mysql-correctly/#findComment-826438 Share on other sites More sharing options...
y2yang Posted May 5, 2009 Author Share Posted May 5, 2009 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. Link to comment https://forums.phpfreaks.com/topic/156881-solved-am-i-using-print-data-from-mysql-correctly/#findComment-826450 Share on other sites More sharing options...
y2yang Posted May 5, 2009 Author Share Posted May 5, 2009 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. Link to comment https://forums.phpfreaks.com/topic/156881-solved-am-i-using-print-data-from-mysql-correctly/#findComment-826464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.