pumaf1 Posted September 29, 2008 Share Posted September 29, 2008 Hi, I am trying to write a F1 GP database - Yes i know its been done before but it is just a bit of fun for me. What I want to do is get the a list from my SQL database, in this example we are looking for the drivers surname beginning with the letter A. you can see what I have done so far here: http://www.pumaf1.org.uk/members/ib/drivera.php now then when I try and add a column, in this case to show the drivers Nationality, it wont do it. here is the code I have so far: <html> <?php // listing script // connect to the server mysql_connect( '', '', '' ) or die( "Error! Could not connect to database: " . mysql_error() ); // select the database mysql_select_db( 'web16-results' ) or die( "Error! Could not select the database: " . mysql_error() ); // retrieve all the rows from the database $query = "SELECT * FROM infobase "; $query = "SELECT DISTINCT name FROM infobase WHERE name LIKE 'a%' ORDER BY name asc"; $results = mysql_query( $query ); // print out the results if( $results ) { ?> <body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#FF0000" alink="#FF0000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><div align="center"> </div> <div align="center"><font size="2" face="verdana"> <? include '../../header.php' ?> </font> </div> <div align="center"> <table width="770" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="57" valign="top"> <p> </p> <table width="247" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td bgcolor="#FF0000"><div align="center"><font color="#FFFFFF" face="verdana"><strong>"A"</strong></font></div></td> </tr> <tr> <td><table width="300" border="0" align="center" cellpadding="1" cellspacing="1"> <?php while( $contact = mysql_fetch_object( $results ) ) { // print out the info $id = $contact -> id; $name = $contact -> name; $nat = $contact -> nat; ?> <tr> <td bgcolor="#CCCCCC"><font size="1" face="verdana"><?php echo( "<a HREF='driveralld.php?name=$name'>$name<br></a>" );?></font></td> <td bgcolor="#CCCCCC"><div align="center"><font size="1" face="verdana"><?php print( "$nat" );?></font></div></td> </tr> <? } } else { die( "Sorry we are having a database problem, please contact admin and report the following error : " . mysql_error() ); } ?> </table></td> </tr> </table> <p> </p><div align="center"><a href="javascript:history.go(-1)" class="style1"><font size="2" face="verdana">Back</font></a> </div></td> </tr> </table> <font size="2" face="verdana"> <? include '../../footer.php' ?> </font></div> </body> if anyone could point me in the right direction i would be very happy! Quote Link to comment https://forums.phpfreaks.com/topic/126334-solved-help-with-php-page/ Share on other sites More sharing options...
pumaf1 Posted September 30, 2008 Author Share Posted September 30, 2008 sorry I have done some re-gigging so please use this address: http://www.pumaf1.org.uk/ib/drivera.php Quote Link to comment https://forums.phpfreaks.com/topic/126334-solved-help-with-php-page/#findComment-654018 Share on other sites More sharing options...
wildteen88 Posted September 30, 2008 Share Posted September 30, 2008 It wont display the Nationality as you have only told MySQL to return the name of the driver Change your query to: $query = "SELECT DISTINCT name, nationality FROM infobase WHERE name LIKE 'a%' ORDER BY name asc"; Now to display the nationality you'd use $nationality= $contact->nationality; echo $nationality; Within your while loop. Quote Link to comment https://forums.phpfreaks.com/topic/126334-solved-help-with-php-page/#findComment-654043 Share on other sites More sharing options...
pumaf1 Posted October 1, 2008 Author Share Posted October 1, 2008 Of course!!!!!! You know when you have been staring it in the face for ages then leave it.... thanks very much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/126334-solved-help-with-php-page/#findComment-654931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.