Well, as a matter of fact, it is only you, who can get to know.
use mysql_error() function to see if something wrong with this query.
also check if there are any data in the database.
also instead of $_GET[‘ID’] you should use
intval($_GET['ID'])
to follow SQL syntax rules and avoid malicious SQL injection
Now, if you look in my select, i have said is $numrows is 0 then show a message. I get this message if there are no returns. But on the page where i expect something the message does not appear. So this means the code knows that it should output something…
$query = "SELECT * FROM tbl_cat_selection WHERE cat_id = '".$_GET['ID']."'";
Try to avoid to get the variable directly in the select statement. Instead use
$myid = $_GET['ID'];
[COLOR="Orange"][SIZE="2"](to protect your database you will need to validate your variable here)[/SIZE][/COLOR]
$query = "SELECT * FROM tbl_cat_selection WHERE cat_id = \\"$myid\\";
or
$myid = $_POST['ID'];
[COLOR="Orange"][SIZE="2"](to protect your database you will need to validate your variable here)[/SIZE][/COLOR]
$query = "SELECT * FROM tbl_cat_selection WHERE cat_id = \\"$myid\\";
And you will want to change the “" with all the tables you need. You must avoid using "”. It will be faster and more secure.
Might be a stupid question, but are you sure there is a column called main_image in that table? And if there is, does it contain any data?
You might also want to debug your code adding some echo and print_r commands here and there to see what parts of the script are actually executed, and what value variables have at that time.
If you’re not doing any validation, storing the $_GET or $_POST variable in another variable has no advantage at all. And why do you put the value in double quotes? Use single quotes, or non at all if the value is numeric. Which makes me think: OP, is cat_id numeric? Then don’t use quotes.
And you will want to change the “*” with all the tables you need.
They’re called columns, not tables, but you’re correct about not using the ‘*’