Posts: 45
Threads: 12
Joined: Sep 2011
Hi
I want to get the custom_id from the pages table and display it what is a good way of doing this.
Thanks
Peter
Posts: 45
Threads: 12
Joined: Sep 2011
Hi
Here is code I am using
<?php
define ('IN_COMMENTICS', '1');
require "../comments/includes/db/connect.php";
$query = mysql_query("SELECT * FROM `".$mysql_table_prefix."pages'");
if(!$con){
die('could not connect:' .mysql_error());
}
mysql_select_db("pages", $con);
$result = mysql_query("SELECT * FROM `".$mysql_table_prefix."pages'");
echo"<table border ='1'>
<tr>
<th>Custom ID</th>
</tr>";
While($row = my_sql_fetch_array($result)){
echo"<tr>";
echo"<td>". $row['custo_id]."</td>";
echo"</tr>";
}
echo"</table>";
?>
And error on page says could not connect Table a7...._comment.pages doesn't exist
Any help appreciated
Thanks
Peter
Posts: 45
Threads: 12
Joined: Sep 2011
Hi
When I am logged into my database on my server When I run
SELECT * FROM `pages` on sql query all is displayed as should be.
I just get could not connect error when i try to run it from my page .
help welcome
Thanks
Peter
Posts: 535
Threads: 31
Joined: Jul 2010
I'm giving you three guesses...
Posts: 45
Threads: 12
Joined: Sep 2011
Hello Static,
it is to get just one entry the ("SELECT id FROM pages WHERE custom_id = 'cagarole'") and only list first occurrence.
(as cagarole is the page name 'cmtx_title' which I know without actually opening my database)
which I then want to use in this query Like:
$query = mysql_query("SELECT MAX(rating) AS highest_rating FROM comments WHERE is_approved = '1' AND page_id = '("SELECT id FROM pages WHERE custom_id = 'cagarole'")'");
$result = mysql_fetch_assoc($query);
$highest_rating = $result["highest_rating"];
Otherwise I have to hardcode both queries.
Other question can I run query's on two tables at the same time.
Thanks for your help with this.
Peter
Posts: 45
Threads: 12
Joined: Sep 2011
Hi Static,
here is my new code:
<?php
define ('IN_COMMENTICS', '1');
require "../comments/includes/db/connect.php";
$query = mysql_query("SELECT `id` FROM `".$mysql_table_prefix."pages` WHERE custom_id = `cagarole` LIMIT 1" );
if(!$con){
die('could not connect:' .mysql_error());
}
mysql_select_db("pages", $con);
$result = mysql_query("SELECT `id` FROM `".$mysql_table_prefix."pages`" WHERE custom_id = `cagarole` LIMIT 1");
echo"<table border ='1'>
<tr>
<th> ID</th>
</tr>";
While($row = my_sql_fetch_array($result)){
echo"<tr>";
echo"<td>". $row['id']."</td>";
echo"</tr>";
}
echo"</table>";
?>
But I still get "could not connect" error.
Thanks for your help.
Peter
Posts: 2,905
Threads: 59
Joined: Jun 2010
Have
you completed
the interview?
Posts: 45
Threads: 12
Joined: Sep 2011
Thanks Steven,
that is exactly what I wanted. As I know the names of all my pages this makes things a lot easier.
Peter