turpentyne Posted September 7, 2010 Share Posted September 7, 2010 I'm trying to figure out how to create a temporary table of a query join, so I can paginate the results. I kind of made half of this up as i was going along - which is dangerous for a beginner like me. I'm getting this error, and no results on the page: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 179 also, is there a way to combine the two queries (create temp and insert from/into) $sql2 = "CREATE TEMPORARY TABLE temp_search (plant_id INT PRIMARY KEY AUTO_INCREMENT, scientific_name VARCHAR(75), common_name VARCHAR(75), leaf_shape VARCHAR(75))"; $sqlx = "SELECT descriptors.leaf_shape ,plantae.scientific_name, plantae.common_name FROM descriptors INNER JOIN plantae ON (descriptors.plant_id = plantae.plant_name) WHERE descriptors.leaf_shape LIKE 'auriculate' AND descriptors.leaf_venation LIKE '%$select3%' AND descriptors.leaf_margin LIKE '%$select4%' INTO temp_search (leaf_shape, scientific_name, common_name)"; $sql = "SELECT * FROM temp_search ORDER BY scientific_name ASC LIMIT $start, $limit"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo $row['scientific_name'] . $row['common_name'] . $row['leaf_shape'] ; } Link to comment https://forums.phpfreaks.com/topic/212733-practicing-with-temp-tables-is-this-written-right/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 7, 2010 Share Posted September 7, 2010 Temporary tables are per-connection. They don't persist between page visits, so they would not be usable for pagination. Link to comment https://forums.phpfreaks.com/topic/212733-practicing-with-temp-tables-is-this-written-right/#findComment-1108141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.