Hi,
been trying to get eform2db running with little success. A friend of mine came up with some plain PHP codes and there are some problems there. I guess it is all related to the way Modx handless queries? So there are (for the moment) two bits of code I use that should interact. I "installed"
listpub as a snippet and
pubdetails too, and as I am writing this I reckon that the problem is probably: "where should I put this
pubdetail.php or how to link to it"?
listpubphp.: list the tabel
publish and shows two collums:
idpub and
publisher.
Idpub links to the
(2)pubdetails.php.
My problem is that the
listpub dóes display the table field content, but the links allways bring me to the first page of the site and thus does NOT show any details. Maybe someone can spot the problem?
1) listpub.php:
<?php
$idpubdetails = $_GET['idpd'];
$idpubmod = $_GET['idpmod'];
$sqlConn = mysql_connect('localhost','user','password');
if (!$sqlConn)
{
die ('unable to connect' . mysql_error());
}
$db = mysql_select_db('dbase', $sqlConn);
// 001: Database query
$query = "select * from publish order by idpub ASC";
// 002: Execute query
$res = mysql_query($query, $sqlConn);
if (!$res)
{
die ('Could not run query: ' . mysql_error());
}
// everything went ok, so we can display the data
echo "<h4>List of Publishers</h4>";
echo " <table border=\"0\" cols=\"2\" cellpadding=\"0\" cellspacing=\"0\" width=\"400\">";
while ($row = mysql_fetch_array($res, MYSQL_BOTH))
{
$reccnt++;
$idpub = $row[0];
$publisher = $row[3];
$pubmodlink = "<a href=\"/dbase/index.php?id=".$idpubmod."&idpub=".$idpub."\">";
$pubmodlink = $pubmodlink . $idpub . "</a>";
$publink = "<a href=\"/dbase/index.php?id=".$idpubdetails."&idpub=".$idpub."\">";
$publink = $publink . $publisher . "</a>";
echo " <tr>";
echo " <td valign=\"top\">" . $pubmodlink . "</td>";
echo " <td valign=\"top\">" . $publink . "</td>";
echo " </tr>";
}
echo " </table>";
mysql_free_result($res);
mysql_close($sql_Conn);
?>
and the
2) pubdetails.php:
<?php
$idpub = $_GET['idpub'];
$sqlConn = mysql_connect('localhost','usern','password');
if (!$sqlConn)
{
die ('unable to connect' . mysql_error());
}
$db = mysql_select_db('dbase', $sqlConn);
// read in the data of the selected record
$query = "select * from publish where idpub = " . $idpub;
// 002: Execute query
$res = mysql_query($query, $sqlConn);
if (!$res)
{
die ('Could not run query: ' . mysql_error());
}
if ($row = mysql_fetch_array($res, MYSQL_BOTH))
{
$abbreviation = $row[1];
$address = $row[2];
$publisher = $row[3];
$website = $row[4];
$email = $row[5];
$oddities = $row[6];
$telephone = $row[7];
}
echo "<h4>Publisher details</h4>";
echo " <table border=\"0\" cols=\"2\" cellpadding=\"0\" cellspacing=\"0\" width=\"400\">";
echo " <tr>";
echo " <td width=\"60\"></td>";
echo " <td width=\"340\"></td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Abbreviation:</td>";
echo " <td>".$abbreviation."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Address:</td>";
echo " <td>".$address."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Publisher:</td>";
echo " <td>".$name."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Website:</td>";
echo " <td>".$website."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Email:</td>";
echo " <td>".$email."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Telephone:</td>";
echo " <td>".$telephone."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\">Oddities:</td>";
echo " <td>".$oddities."</td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"60\" valign=\"top\"> </td>";
echo " <td></td>";
echo " </tr>";
echo " </table>";
mysql_close($sql_Conn);
?>