Wrox Programmer Forums
|
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2012, 07:22 PM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 3 Select1/2 php

Hi all,
Problem I am having is that this code is returning 2 of each entry.
select1.php:
PHP Code:
<?php
$db 
mysql_connect('localhost''bp6am''bp6ampass') or die ('Unable to connect. Check your conneciton parameters.');
mysql_select_db('moviesite'$db) or die(mysql_error($db));

// select the movie titles and thier genre after 1990
$query 'SELECT
        movie_name, movie_type
    FROM
        movie
    WHERE
        movie_year > 1990
    ORDER BY
        movie_type'
;
$result mysql_query($query$db) or die(mysql_error($db));


// show the results as a foreach loop
while ($row mysql_fetch_array($result))
{
    foreach (
$row as $value)
    {
        echo 
$value ' ';
    }
    echo 
'<br>';
}
?>
select2.php
PHP Code:
<?php
$db 
mysql_connect('localhost''bp6am''bp6ampass') or die ('Unable to connect. Check your conneciton parameters.');
mysql_select_db('moviesite'$db) or die(mysql_error($db));

// select the movie titles and thier genre after 1990
$query 'SELECT
        movie_name, movie_type
    FROM
        movie
    WHERE
        movie_year > 1990
    ORDER BY
        movie_type'
;
$result mysql_query($query$db) or die(mysql_error($db));


// show the results as a foreach loop
echo '<table border="1">';
while (
$row mysql_fetch_array($result))
{
    echo 
'<tr>';
    foreach (
$row as $value)
    {
        echo  
'<td>' $value '</td>';
    }
    echo 
'</tr>';
}
echo 
'</table>';
?>
Where is the problem?
 
Old April 6th, 2012, 01:50 AM
Registered User
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

your code seems to be correct. Please mention what you want to do with and what is happening?
 
Old April 6th, 2012, 09:02 AM
Registered User
 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default displaying twice

The code may look correct, but whenever i run it, it displays the output twice.

Grand Canyon Grand Canyon 2 2

Why is it doing that to my code, and not the book code?

Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 6 commit.php MySequel BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 6 February 5th, 2012 04:57 PM
PHP 5, Wrox, CH 7 navigator.php Jon_ BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 August 24th, 2008 01:13 PM
Beg. PHP 5 > Ch. 11 - fetch_field.php crater BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 January 2nd, 2007 12:20 PM
Ch. 1: PHP Installation Troubles: php3 vs php manjito BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 June 12th, 2003 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.