lasha Posted September 20, 2012 Share Posted September 20, 2012 hello I have problem and i think my topic title explains everything ("A-Z selector does not select veri first record from database") I can't understend why, please help Thanks <table width="100%" border="0" > <tr> <td valign="top"> <ul id="items"> <?php $this_link = htmlentities( $_SERVER['PHP_SELF'] ); $letters = range('A', 'Z'); $menu = '<ul id="az">'."\n"; foreach ( $letters as $letter ) { $menu .= '<li><a href="'. $this_link .'?var='. $letter .'">'. $letter .'</a></li>'."\n"; } $menu .= '</ul>'."\n"; if ( isset( $_GET['var'] ) AND in_array( $_GET['var'], $letters ) ){ $result = mysql_query("SELECT * FROM data WHERE band_name LIKE '". $_GET['var'] ."%' ",$db); $myrow = mysql_fetch_array($result); if (!$result) { echo "<p>The operation unsuccessful ... Please contact the administrator by e-mail: [email protected] <br> <strong>Error:</strong></p>"; exit(mysql_error()); } if(mysql_num_rows($result) > 0) { $myrow = mysql_fetch_array($result); do { printf (" <li> <table style='float:left; margin:0px;'> <tr> <td valign='top' id='header23' style='color:#888888; font-family:arial;'> <div> <span class='vidtitle'><span style='color:#fff; font-size:12px;'><strong>%s</strong></span></span> <br><a href='%s' target='_blank'>Sound Cloud</a> <br> <a href='%s' target='_blank'>%s</a> </div> <br> </td> </tr> </table> </li> ",$myrow["band_name"],$myrow["sound_cloud"],$myrow["social_link"],$myrow["place_in_social"]); } while ($myrow = mysql_fetch_array($result)); } else { echo "<p>Information not found...</p>"; } } else { echo '<p>Please select a letter</p>'; } ?> </ul> <div style="position:absolute; top:1px; left:111px;"><?php echo $menu; ?></div> </td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/268612-a-z-selector-does-not-select-veri-first-record-from-database/ Share on other sites More sharing options...
Jessica Posted September 20, 2012 Share Posted September 20, 2012 very. $result = mysql_query("SELECT * FROM data WHERE band_name LIKE '". $_GET['var'] ."%' ",$db); $myrow = mysql_fetch_array($result); if (!$result){...} if(mysql_num_rows($result) > 0){ $myrow = mysql_fetch_array($result); do..... This is the section in which the problem exists. I've cut out some code to make it shorter. Do you see the problem now? Link to comment https://forums.phpfreaks.com/topic/268612-a-z-selector-does-not-select-veri-first-record-from-database/#findComment-1379632 Share on other sites More sharing options...
lasha Posted September 20, 2012 Author Share Posted September 20, 2012 aahaaa There is $myrow = mysql_fetch_array($result); twice yeah? Thank you jesirose, it was problem and now everything works perfect!! thanks thanks )))))))) Link to comment https://forums.phpfreaks.com/topic/268612-a-z-selector-does-not-select-veri-first-record-from-database/#findComment-1379638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.