Creating a MYSQL query in a loop SEE LAST POST
Moderator: General Moderators
Creating a MYSQL query in a loop SEE LAST POST
Hi all
Just another quick issue this time.]
Is it not possible to use mysql_fetch_row($result): when you have used a where clause in $result as i get the mysql_fetch_row(): error
sorry i dont know what its called where the function looks at the () var in the brackets
thanks reece
Just another quick issue this time.]
Is it not possible to use mysql_fetch_row($result): when you have used a where clause in $result as i get the mysql_fetch_row(): error
sorry i dont know what its called where the function looks at the () var in the brackets
thanks reece
Last edited by reecec on Mon Aug 14, 2006 10:47 am, edited 2 times in total.
sorry wasnt sure if you needed to see the code
Code: Select all
$table=$_REQUEST['table'];
$result = mysql_query("select * from $table");
$searchquery='mysql_query("SELECT * FROM test ';
$i=0;
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result, $i);
$name=$meta->name;
$con = ( $field[$i]=='' ) ? '"' : "$name = $field[$i]";
$finish = ( $i == 1) ? '")' : ' AND ';
$searchquery .= "$con$finish";
$i++;
}
echo $searchquery;
if ($searchquery) {
echo "Searched $table";
} else {
echo "Error Searching $table";
}
echo '<table border="1" cellspacing="0" cellpadding="0">';
while ($field=mysql_fetch_field($result)) {
echo "<th>";
echo "$field->name";
echo "</th>";
}
echo "<th>";
echo "Delete";
echo "</th>";
while ($row = mysql_fetch_row($searchquery)) {
echo "<tr>";
for ($i=0; $i<mysql_num_fields($searchquery); $i++) {
echo "<td>";
echo "$row[$i]";
echo "</td>";
}}Hi thanks all for you replyes
but when i check the query it works and doesnt give an error and says sucsess
but even if i do a standard on a new script
thanks reece
but when i check the query it works and doesnt give an error and says sucsess
but even if i do a standard on a new script
it works but as soon as i tell it what row to get using a WHERE is doesnt like it can i not use this to get a specific rowmysql_fetch_rows
thanks reece
sorry an example may help
this is fine
but when a where clause is added it gives an error
thanks reece
this is fine
Code: Select all
$result=mysql_query("SELECT * FROM anytable");
$field=mysql_fetch_field($result)Code: Select all
$result=mysql_query("SELECT * FROM anytable WHERE field=anything");
$field=mysql_fetch_field($result)thanks reece
try the mysql_error() function
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
you are using ticks incorrectly in this query:
or even
instead, it should say this:mysql_query("SELECT * FROM `test` WHERE 'username' = 'test' AND 'profile' = 'test' ")
Code: Select all
$sql = mysql_query("SELECT * FROM `test` WHERE username = 'test' AND profile = 'test' ");Code: Select all
$sql = mysql_query("SELECT * FROM `test` WHERE `username` = 'test' AND `profile` = 'test' ");
