Jump to content

[SOLVED] Searching a query result.


adam291086

Recommended Posts

I have a simple query that selects everything from a database and limits the results to one row ordered by desc. The code does work. The next step is to search the query result to see is if a certain feild has a result. I'm not sure how to do this. Any pointers are appreciated.

<?php

Include("config.php");
$con;

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$result = mysql_query("SELECT * FROM photos ORDER BY photo_id DESC LIMIT 1");
while($row = mysql_fetch_array($result))
{
echo $row['photo_id'];
}

?>

Link to comment
https://forums.phpfreaks.com/topic/72784-solved-searching-a-query-result/
Share on other sites

The next step is to search the query result to see is if a certain feild has a result.

 

You shouldn't search through the result, but write your query in such a way to only retrieve the data you need. eg;

 

SELECT * FROM foo WHERE bar = 'val';

 

What field do you want to check and what value do you want it checked for?

Basically what i am trying to do is search the database table and return the highest photo_id number. This equals the photo just uploaded. Then i want to check the photo_location and ensure the feild isn't empty. If it is empty then an error message is display else display photo uploaded ok.

Archived

This topic is now archived and is closed to further replies.

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