adamjblakey Posted August 6, 2007 Share Posted August 6, 2007 I am just trying to assign my results to an array but cannot see what i am doing wrong here as the results do not seem to be assigning Here is the code: $strippagename = str_replace("-", " ",$_GET['title']); $sql = "SELECT id,title FROM `recipes` WHERE `category2` = '$strippagename'"; $res = mysql_query($sql); $i = -1; while ($row = mysql_fetch_assoc($res)) { $cat_url = strtr($row['title'], "éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ. ","eeeaeauoiaabcdefghijklmnopqrstuvwxyz--"); $cat_url = ereg_replace('[^a-zA-Z0-9_-]', '', $cat_url); $tmp = array( 'id' => $row['id'], 'title' => $row['title'], 'caturl' => $cat_url ); $results[$i++] = $tmp; } echo "<pre>"; print_r($results); echo "</pre>"; What am i doing wrong here? I am just trying to assign my results to an array but cannot see what i am doing wrong here as the results do not seem to be assigning Here is the code: Code: // get all the recipes from the table $strippagename = str_replace("-", " ",$_GET['title']); $sql = "SELECT * FROM recipes WHERE category2 = '$strippagename'"; // looping through the table to get all results $res = mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); $results = array(); $i=0; while (list($title) = mysql_fetch_row($res)) { $cat_url = strtr($title, "éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ. ","eeeaeauoiaabcdefghijklmnopqrstuvwxyz--"); $cat_url = ereg_replace('[^a-zA-Z0-9_-]', '', $cat_url); $tmp = array( 'id' => $r['id'], 'title' => $title, 'caturl' => $cat_url ); $results[$i++] = $tmp; } Cheers, Adam Quote Link to comment https://forums.phpfreaks.com/topic/63510-what-am-i-doing-wrong-here/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.