sql - Re-sizing a webpage -
i'm computer science student , given assignment create whole website based on given subject do. meant create website google glass , meant make website re-sizable can open on mobile phones display on other computer screens other own. looking on re-sizing of site i'm stuck re-sizing sql code, appreciated if show me example of it.
<html>help
<li><a href="contact.html">contact</a></li> <li><a href="about.html">about</a></li> <li><a href="help.php">help</a></li> <li><a href="careers.html">careers</a></li> <li><a href="purchase.html">purchase</a></li> <li><a href="index.html">home</a></li>
//define variables: $db_hostname = 'localhost'; $db_username='root'; $db_password=''; $db_database='glass';
//connect mysql $db_server = mysql_connect($db_hostname, $db_username, $db_password );
//check there no error connecting if (!$db_server) die("unable connect mysql: " . mysql_error());
//…next step is… 2. select database! mysql_select_db($db_database) or die("unable connect mysql: " . mysql_error());
//create sql query $query = "select * help";
//run query $result = mysql_query($query); if (!$result) die ("unable run query" . mysql_error());
//step 5: output results. /count number of rows returned query , assign variable/ $number_rows = mysql_num_rows($result); //run loop output data rows echo '
'; ($i=0; $i'; echo ''; echo '' . mysql_result($result, $i, 'headline') . '
'; //step 6: close connection mysql mysql_close();
'; echo ''; } echo '?>
copyright 2012. ©
your asking 2 questions. im not gonna assignment, push in right direction :)
firstly, theres no such thing "re-sizing sql code", unless mean making code more efficient eliminating lines. also, code youve posted mysql, (deprecated unfortunately). use mysqli. example found here.
the bottomline using php connect sql database:
<?php //connect $link = mysqli_connect("localhost", "my_user", "my_password", "world"); //execute query $query = "select * mytable"; $result = mysqli_query($link, $query); //loop through results while ($row = mysqli_fetch_array($result, mysqli_assoc)){ echo $row['mycolumn']; } //disconnect mysqli_close($link); ?> secondly, webpage layout viewable on different resolutions called "fluid" or "responsive" layout. below example of fluid - means specify width of elements in %, instead of px:
<style> .header{ height:120px; width:100%; } .content{ margin:auto; width:80%; } </style> <body> <div class="header"> <div class="logo"></div> </div> <div class="content"> </div> </body> in future, please make effort attempt solution, instead of asking stackoverflow give assignments, cheers :)
Comments
Post a Comment