phpSensei Posted December 11, 2008 Share Posted December 11, 2008 <?php //database inforamtion $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ $query = "SELECT * FROM `flight_webair` WHERE flight_route = '$flight_route_out'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ /// show all the webair data here } }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 <?php //database inforamtion $host = "stocks"; // Host name $username = "wbennett"; // Mysql username $password = "mysql5"; // Mysql password $db_name = "wbennett"; // Database name $tbl_name1 = "flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Variables $flight_route_out = $_POST['flight_route_out']; $flight_route_return = $_POST['flight_route_return']; $date_out = $_POST['departure_date']; $date_return = $_POST['return_date']; $passenger_num = $_POST['num_of_pass']; $one_way = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first. //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($result) > 0){ $query = "SELECT * FROM `flight_webair` WHERE flight_route = '$flight_route_out'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ /// show all the webair data here } }else{ echo 'Sorry, couldn\'t find any flights'; } mysql_free_result($result); ?> In the curly brace can i write pure html in there? this is what i really need it to do so i can get it to generate not only what the query returned but also stuff like my header, buttons and all my standard page layout. (much like a basic template for the page so it looks consistant. thanks Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 overall what i want to be able to do is not only generate the flight info on the fly but also use a load of bulk HTML aswell which will provide my site template. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 Put only what your going to print for the webair stuff in the curly brackets echo'<b>hello</b><table>html</table>' and your header, button,..etc outside, since the its a LOOP Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 If you have a HTML table for the Flight INFO put it in the curly brackets sure, but not your entire layout. Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 sorry i lost internet for a bit! Okay say i had this: would i put layout here like this: echo "<html>" echo "<head>" layout stuff butons other general page stuff etc etc then the while statement while($row = mysql_fetch_array($result)) { echo $row['flight_num']; echo $row['flight_route']; echo $row['arrival_time']; } }else{ echo 'Sorry, couldn\'t find any flights'; } and this would give that layout to both the generated code and the "sorry could not find..." page also... plus is there a quicker way to insert my tempalte rather than going echo ".." echo ".." thanks alot sorry about the length of my questions Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 Your template doesn't go inside the curly brackets... only things that loop lol. you can use this for html <?php $html=<<<HTML <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> HTML; ?> Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 Your template doesn't go inside the curly brackets... only things that loop lol. you can use this for html <?php $html=<<<HTML <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> HTML; ?> great thanks ill give that a whirl! Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 You can put html in those curly bracks. If your info goes into a HTML table, then put that in the curly brackets, but your HEADER, NAV, and other things goes outside of the PHP script. no problem bro:D Quote Link to comment Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 This topic is really getting long. You're better of trying what phpSensei suggested and posting a new thread with a specific answer. Not trying to be rude, but I know I wouldn't sit here and read through all that. Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 This topic is really getting long. You're better of trying what phpSensei suggested and posting a new thread with a specific answer. Not trying to be rude, but I know I wouldn't sit here and read through all that. yeah this is getting off topic anyways ill mark this as solved good idea mate Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 Oh my god, I didn't notice it got this long lol Quote Link to comment Share on other sites More sharing options...
Maq Posted December 11, 2008 Share Posted December 11, 2008 Oh my god, I didn't notice it got this long lol Hehe. I looked at it and saw 83 replies... I had to see what in the world you guys were talking about. Quote Link to comment 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.