osdir.com
mailing list archive

Subject: [PHP] databse query - msg#00249

List: php-general

Date: Prev Next Index Thread: Prev Next Index
Hello to all,

please i'm new PHP and trying to display some records from my db using
dreamweaver.

I have 2 tables ( Subjects and Pages) where Subjects is the parent and Pages
is the child.

I want to get all pages belonging to each subject but my query gives me all
pages under the first result of the query.

How can I get only pages of each subject under it's own ID ( parent + it's
child)?

I'll include my code for better reference.





<?php require_once('../../Connections/shop.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")

{

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;



$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
"NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;

break;

}

return $theValue;

}

}



mysql_select_db($database_shop, $shop);

$query_menu_list = "SELECT * FROM subjets";

$menu_list = mysql_query($query_menu_list, $shop) or die(mysql_error());

$row_menu_list = mysql_fetch_assoc($menu_list);

$totalRows_menu_list = mysql_num_rows($menu_list);



mysql_select_db($database_shop, $shop);

$query_pages = "SELECT * FROM pages WHERE id_subject = id";

$pages = mysql_query($query_pages, $shop) or die(mysql_error());

$row_pages = mysql_fetch_assoc($pages);

$totalRows_pages = mysql_num_rows($pages);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml";>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>menu_list</title>

</head>



<body>

<?php while ($row_menu_list = mysql_fetch_assoc($menu_list)){

echo "<li>{$row_menu_list['subget_name']}</li>" ;



while ($row_pages = mysql_fetch_assoc($pages)){

echo "<li>{$row_pages['page_name']}</li>";}



} ?>

</body>

</html>

<?php

mysql_free_result($menu_list);



mysql_free_result($pages);

?>



The query gives this result:



* informatica

* Dove Siamo

* Lorem

* web templates in vendita

* assistenza

* shop

* contatti

Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

RE: [PHP] Listening on host:port - Windows

Thanks, you are right. I used php.exe -v to confirm cgi version. My query is what parameter do I use to specify host and port? That will have the same effect as -b in php5. Sorry if I didn't make it clear. John _____ From: ?? [mailto:delmeok@xxxxxxxxx] Sent: Friday, June 05, 2009 8:24 AM To: j.fairley@xxxxxxxxxx Subject: Re: [PHP] Listening on host:port - Windows in php4,php.exe is the cgi version for default,and php-cli is the cli version in php5,php.exe is the cli version,and php-cgi is the cgi version i think you can use php.exe instead of php-cgi.exe in php4 2009/6/5 John Fairley <j.fairley@xxxxxxxxxx> I'm running my test server on Windows XP SP3 and have been successfully running PHP 5 for some time using: php-cgi.exe -b 127.0.0.1:10000 My live server is running on PHP 4.4 and that gives an incompatibility risk in problem solving. So I've removed PHP 5 on my test server and have installed PHP 4.4.9 but I can't find how I set host and port in php. Running php -v has confirmed that this is the cgi-fcgi version. I'm sure it's simple but I'm being driven nuts. TIA, John

Next Message by Date: click to view message preview

Re: [PHP] https setup

PJ wrote: Can't find anything on G or web - but I probably didn't try hard enough. I am unable to set my virtual hosts to handle https. I have apache22, mod_ssl, opnenssl and the httpd and httpd-vhosts.conf files are set up "correctly" but directing a sensitive user information page to an HTTPS page returns an error of "not found". The virtual hosts works fine, except for HTTPS. This is on my intranet for local developing. TIA By "not found" do you mean a 404 error from the https domain? If so, then you probably just have the DocumentRoot directive set up incorrectly for your secure domain. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Previous Message by Thread: click to view message preview

[PHP] preg_replace

I bought PHP & MySQL for DUMMIES and it shows me how to use special characters for pattern matching and I've figured out the basics of using preg_replace to replace pattern matches. What I am having trouble with, though, is figuring out how to replace anything that does not match the pattern. For example, I want to replace anything that is NOT an alphanumeric character. Any help would be appreciated. Thanks. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Next Message by Thread: click to view message preview

[PHP] PHP, OOP and AJAX

Update. Hello Everyone, First of all, thank you all for your input. I ran a sinmple test using the suggestions you gave me and and require_once. Using firebug to test the output, I got an internal server error. I found out what the problem was. What I am doing is I have classes which represent the objects, another class containing the functions. From the function class I create an instance of each object, manipulate the information, return the HTML result. Finally I have a runner class that creates an instance of the function class, calls the function required and outputs the information. What the problem was for some reason I was did not create an instance of the function class, just was calling the function. Well by creating the runner class I solved the problem. Thanks all for your help. Regards Julian
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by