d22552000 Posted October 13, 2007 Share Posted October 13, 2007 It really isn't working too well, so hey, I tried this out... I made a script to query the name field in teh database of files for any file starting with a single letter chosen. "X%" would search for everythign beginning with an X. (in mysql terms a % is a wildcard*) My current code can be found below, it sucks balls, yes, but I could not think of a better way to do it. It currently searches and returns no results no matter what, although all of my files currently in the database do not have capital letters so maybe iI should search for both the upercanse and lowercase letters for an input? (X and x). But how would I do this? I am using RANGE to make the HTML inks for it, and I THINK I am doing the page stepping properly by saying LIMIT (perpage),(startnum); <?PHP if (!empty($_GET['go'])) { $mysearch =$_GET['go']; $mysearch = trim($mysearch); if (!$mysearch || $mysearch=='') html('Search, No Results!','No Results Were Returned!'); if (strlen($mysearch)>2) html('Hacking Attempt Detected, THIS IS NOT THE SEARCH!.'); /* MYSQL CONNECTION */ mysql_connect(localhost,'root',''); $page = 1 + $_GET['p'] * 25; $sql = "SELECT * FROM `*`.`files` "; $sql.= "WHERE `Name` LIKE '$mysearch%' LIMIT 25,$page"; $result = mysql_query($sql); if (!$result) html('No Results!','No Results Were Returned!'); $RET = '<font size="3">Returned '.$num_books.' Results</font> <TABLE width="95%"> '; while(list($ID,$Name,nul,$Description,nul,$Downloads)= mysql_fetch_row($result)) { $RET.= " <TR><TD><a href='./FORM/Files.php?download&id=$ID'>$Name</a></TD><TD>$Description</TD><TD>$Downloads</TD></TR> "; } $RET.= '</TABLE>'; } $REM = $RET; $REE=''; foreach (range('1', '9') as $letter) { $REE.= '<A HREF="?go='.$letter.'">'.$letter.'</A> '; } foreach (range('A', 'Z') as $letter) { $REE.= '<A HREF="?go='.$letter.'">'.$letter.'</A> '; } $RET = $REE.$REM; echo $RET; ?> So , even though my code SUCKS, why doesn't it work? BTW, I am aware that I have not outputted the page selection dropdown yet. Quote Link to comment https://forums.phpfreaks.com/topic/73044-making-a-file-browsing-script-page-stepping-wtf/ Share on other sites More sharing options...
d22552000 Posted October 13, 2007 Author Share Posted October 13, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/73044-making-a-file-browsing-script-page-stepping-wtf/#findComment-368448 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.