simcoweb Posted August 26, 2006 Share Posted August 26, 2006 I have about 20 entries in the database. I'm trying to extract them and display one at a time in a display. Here's the code:[code]mysql_connect($dbhost, $dbuser, $dbpass) or die('No database here, boss');mysql_select_db($dbname) or die('That database can not be found, boss.');$sql=("SELECT * FROM members");$result = mysql_query($sql) or die('Can not find that database today');// insert extract functionextract(mysql_fetch_array($result,EXTR_SKIP));while ($row = mysql_fetch_assoc($result)) { echo <<<HTML[/code]But here's the display showing just the first entry over and over again: http://www.plateauprofessionals.com/display.php Quote Link to comment https://forums.phpfreaks.com/topic/18730-why-is-this-returning-the-same-row-over-and-over/ Share on other sites More sharing options...
.josh Posted August 26, 2006 Share Posted August 26, 2006 not enough code to go on Quote Link to comment https://forums.phpfreaks.com/topic/18730-why-is-this-returning-the-same-row-over-and-over/#findComment-80791 Share on other sites More sharing options...
simcoweb Posted August 26, 2006 Author Share Posted August 26, 2006 Here's the whole page:[code]<?php // test to display addbiz resultsinclude 'config.php';include 'header.php';mysql_connect($dbhost, $dbuser, $dbpass) or die('No database here, boss');mysql_select_db($dbname) or die('That database can not be found, boss.');$sql=("SELECT * FROM members");$result = mysql_query($sql) or die('Can not find that database today');// insert extract functionextract(mysql_fetch_array($result,EXTR_SKIP));while ($row = mysql_fetch_assoc($result)) { echo <<<HTML<div align='center'><table border='0' cellpadding='0' style='border-collapse: collapse' width='530'><tr><td colspan='2' background='http://www.plateauprofessionals.com/images/top2.gif' width='530' height='35' style='padding: 10px'><h2>$name</h2></td></tr><tr><td height='15' colspan='2'></td></tr><tr><td style='padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px' width='229' valign='top'>$image</td><td style='padding-left: 10px; padding-right: 10px' width='261'><div align='center'><table border='0' cellpadding='0' style='border-collapse: collapse' width='100%'><tr><td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top: 1px dotted #666633; border-bottom-width: 1px; padding: 4px' width='46%' bgcolor='#E3E1E1'><font class='bodytext'><i>• $title</i></td></tr><tr><td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#EFEDED'><font class='bodytext'>• $phone</td></tr><tr><td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#E3E1E1'><font class='bodytext'>• $email</td></tr><tr><td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#EFEDED'>• <a class="body" href="$url">Click Here To Visit My Site</a></td></tr><tr><td style='border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px dotted #666633; padding: 4px' width='46%' bgcolor='#E3E1E1'>• <a class="body" href='contact.php'>Click here to contact $name</a></td></tr></table></div> </td></tr><tr><td style='padding: 10px' colspan='2'><font class='bodytext'><b>About My Services</b></td></tr><tr><td style='padding: 10px' colspan='2' class='bodytext' bgcolor='#e9efef' width='500'>$details</td></tr><tr><td style='padding: 10px' colspan='2'><font class='bodytext'><b>My Specialties</b></td></tr><tr><td style='padding: 10px' colspan='2' class='bodytext' bgcolor='#edecde' width='500%'>$specialties</td><tr><td style='padding-left: 0px; padding-right: 0px; padding-top: 4px; padding-bottom: 4px' background='images/bottom.gif' height='37' colspan='2'><p align='center' class='bodytext'>You can use our <a class="body" href='search.php'>key word search</a> option also.</td></tr></table></div>HTML;}include 'footer.php';?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/18730-why-is-this-returning-the-same-row-over-and-over/#findComment-80793 Share on other sites More sharing options...
wildteen88 Posted August 26, 2006 Share Posted August 26, 2006 I getParse error: parse error, unexpected T_VARIABLE, expecting '(' in /home2/wwwplat/public_html/display.php on line 12When going to the link provided.Also everything seems to be fine with the code. Prehap this:[code]extract(mysql_fetch_array($result,EXTR_SKIP));[/code]needs to go inside the while loop like so:[code]while ($row = mysql_fetch_assoc($result)) { extract($row);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18730-why-is-this-returning-the-same-row-over-and-over/#findComment-80794 Share on other sites More sharing options...
simcoweb Posted August 26, 2006 Author Share Posted August 26, 2006 Cool. Moving that 'extract' into the 'while' statement produced the results. Now I have to figure out why in the spot where their image is supposed to show up that it's printing the /tmp name for each one.That display is back up. I just hadn't uploaded the 'fixed' version when you tried.http://www.plateauprofessionals.com/display.php Quote Link to comment https://forums.phpfreaks.com/topic/18730-why-is-this-returning-the-same-row-over-and-over/#findComment-80798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.