I'm using Chris's DB structure to store Amazon node info, as below:
I want to use an SQL call to get the amazonid and MODE based on a URL's array.Code:example:
pid amazonid parentid textid name MODE
1 3118561 283155 50th books
So, with (for example) www.domain.com/cat/1/
1 - is the PID
I am trying to use:
And then later the variables $cat and $mode are used for 'node' and 'mode' respectively.PHP Code:
$var_array = explode("/",$REQUEST_URI);
if ($var_array[2] == 0) { $cat = '4178281'; $mode = 'books';}
else {
$sql = "SELECT * FROM blank_categories WHERE pid='$var_array[2]'";
$result = mysql_query($sql);
if ($result == 0) { $cat = '4178281'; } else { $cat = mysql_result($result, 0, 'amazonid');}
if ($result == 0) { $mode = 'books'; } else { $mode = mysql_result($result, 0, 'MODE'); }
;}
However, it's just not working! Nothing seems to be parsed, even if the array is empty (when it should go to the defaults, as above).
What am I doing wrong? :(