Jump to content

list all records in database starting with the letter 'A'


Recommended Posts

i tried this and its not working... blank page

 

<?php

mysql_connect("localhost", "Master", "password");
mysql_select_db("Login");

$letter = htmlentities($_GET['search']); 
$user = mysql_query("SELECT * FROM Users WHERE username LIKE '$letter%' ORDER BY username")or die (mysql_error());  

while($rowz = mysql_fetch_array($user)){
$username = $rowz['username'];
echo "<font face='Courier New' font size=2px font color=#FBB917>$username</font>";
}
?>

Not really sure what is wrong, worked fine using my database information:

 

<?php

mysql_connect("localhost", "Master", "password") or trigger_error("Connection Failed: " . mysql_error());
mysql_select_db("Login") or trigger_error("Database Selection failed: " . mysql_error());

$letter = isset($_GET['search']) ? htmlentities($_GET['search']) : ''; 
$user = mysql_query("SELECT * FROM Users WHERE username LIKE '{$letter}%' ORDER BY username")or trigger_error ("SQL Failed: " . mysql_error());  

while($rowz = mysql_fetch_assoc($user)){
    $username = $rowz['username'];
    echo "<font face='Courier New' font size=2px font color=#FBB917>$username</font>";
}
?>

 

Try that and see if it does any better, not sure if it will because the original way seemed fine on my server, so it could be a server issue.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.