This is PHP4 Code!
Simple Get A Result
$query = @mysql_query("SELECT user_name, password FROM member_profile WHERE email_address = '$user_name_login' AND password = '$password_login'");
$result = @mysql_fetch_array($query);
$result_display_username = $result['user_name'];
$result_username = strtolower($result['user_name']);
Does Record Exist
$query = @mysql_query("SELECT * FROM my_table WHERE some_field = $some_field AND some_field2 = $some_field2 AND some_field3 = 'yes'");
if (@mysql_num_rows($query))
{
Get Each Row Returned
$query1 = @mysql_query("SELECT * FROM some_table WHERE some_field = $some_value AND approved = 'pending'");
while ($result1 = @mysql_fetch_array($query1)) //Get each row returned
{
$m_title = $result1['member_username'];
//Do something with it...
}
Get Number Of Rows Returned
$count = @mysql_num_rows($query);
Get Specific Columns
$query_user_details = mysql_query("SELECT first_name, last_name, image_file_name FROM member_profile WHERE member_id = $user_id");
Get each field as a variable named as the field
foreach ( $result as $key => $value )
{
$$key = $value;
}
Using OR Arguments
$sql = "SELECT * FROM videos WHERE response_id = $vid AND (video_approved ='yes' || approved ='group' || approved ='school') AND public_private = 'public'";
Putting All Results Into An Array
$all_results = array(); //Empty array to hold returned rows
while ($row = @mysql_fetch_array($search_query))
{
$all_results[] = $row;
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.