<?php 
$query1 = "SELECT `asc_prods.name` FROM `asc_prods` LEFT JOIN `democart` ON `asc_prods.pid` = `democart.tip`;";
$result1 = mysql_db_query($query);
while($row1 = mysql_fetch_array($result1)) {
	echo "<td> {$row1[0]} </td>";
}
?>

I've got the above code, the problem I have with it is that I need to get the value returned by the statement $query1 into a table datacell, and frankly I don't know how to do it. When I execute it in the phpmyadmin it returns the rows as expected. Now the problem is that before I insert them in the above mentioned datacell I have to separate them somehow (they are in the order I want them to be, so this is the only problem, actually two problems). Hope someone can help me.

Recommended Answers

All 2 Replies

mysql_db_query takes two[or three] parameters. The first is the database name, the second is the query, the optional third is the connection. Use php.net it's your friend.

mysql_db_query takes two[or three] parameters. The first is the database name, the second is the query, the optional third is the connection. Use php.net it's your friend.

Ok, I did change mysql_db_query into mysql_query, and still no luck so I tried to create a temporary table in mysql into which I add the results of the $query1 variable, but upon execution it gives me a mysql error, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO temp VALUES(1001, x)' ", where x is 2 or 3 words long. The code I'm using for creating the temporary table is:

INSERT INTO temp VALUES({$row1[0]}, {$row1[1]});

. Sorry for being such a noob.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.