Lee1007 Posted March 26, 2011 Share Posted March 26, 2011 Hi there, I have the following code: <?php include 'config.php'; include 'opendb.php'; $query = "SELECT shop_name, street_name, town, postcode, contact_number, web_address, user_email FROM user_info"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $shop_name = $row[0]; $street_name = $row[1]; $town = $row[2]; $postcode = $row[3]; $contact_number = $row[4]; $web_address = $row[5]; $user_email = $row[6]; echo "<h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; } include 'closedb.php'; ?> But i want to make the echo return in a box which is created by the div in the css? How do i do this? Please Help!!! Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/ Share on other sites More sharing options...
monkeytooth Posted March 26, 2011 Share Posted March 26, 2011 You want all results contained within one master div? Is that what I am understanding? Before: <?php include 'config.php'; include 'opendb.php'; $query = "SELECT shop_name, street_name, town, postcode, contact_number, web_address, user_email FROM user_info"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $shop_name = $row[0]; $street_name = $row[1]; $town = $row[2]; $postcode = $row[3]; $contact_number = $row[4]; $web_address = $row[5]; $user_email = $row[6]; echo "<h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; } include 'closedb.php'; ?> After: <div class="resultWrapper"> <?php include 'config.php'; include 'opendb.php'; $query = "SELECT shop_name, street_name, town, postcode, contact_number, web_address, user_email FROM user_info"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $shop_name = $row[0]; $street_name = $row[1]; $town = $row[2]; $postcode = $row[3]; $contact_number = $row[4]; $web_address = $row[5]; $user_email = $row[6]; echo "<h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; } include 'closedb.php'; ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192496 Share on other sites More sharing options...
Lee1007 Posted March 26, 2011 Author Share Posted March 26, 2011 Yea there are multiple results that come back in the echo though but only one div is showed in the result? I cant understand how to have each echo result in a separate div when showed on the webpage? Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192502 Share on other sites More sharing options...
floridaflatlander Posted March 26, 2011 Share Posted March 26, 2011 I don't know if you're asking a php ? or an html ? Soooooooooo 1. I echo monkeytooth & 2 "<h5>Name:</h5>$shop_name <br>" . <------------unless you style h5 narrow and set a margin or float you have two lines here and two different fonts(?) "<h5>Address</h5>$street_name <br>" . <------------unless you style h5 narrow and set a margin or float you have two lines here and two different fonts "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . <------------unless you style h5 narrow and set a margin or float you have two lines here and two different fonts "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; Also do you need some escapes \" ? Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192503 Share on other sites More sharing options...
monkeytooth Posted March 26, 2011 Share Posted March 26, 2011 "<h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; thats your key bit.. this is where you would either change the html to something you want be it a single div rather than all the h5 tags, or whatever. The thing you need to concern yourself with ultimately when changing the html in this for however you want to style it is preserve the pieces that are $...... example: <?php echo "<div> $shop_name<br /> $street_name<br /> $town. $postcode<br /><br /> $contact_number<br /><br /> $web_address<br><br /> $user_email<br><br /> </div>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192510 Share on other sites More sharing options...
Lee1007 Posted March 26, 2011 Author Share Posted March 26, 2011 I probably havent explained this too good - I have the results of: echo "<h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; } but on the web page i want the results to be displayed in horizontal blocks of 3 - and the php will not accept the div within it to create this - is it even possible to change the layout of the results? Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192514 Share on other sites More sharing options...
Russia Posted March 26, 2011 Share Posted March 26, 2011 if you can make a simple picture with paint, in what you mean il be able to show you how to do it. Just draw a table or w/e your trying to accomplish. Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192519 Share on other sites More sharing options...
Lee1007 Posted March 26, 2011 Author Share Posted March 26, 2011 Thank you I am hoping to accomplish what is attached in the image [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192523 Share on other sites More sharing options...
Russia Posted March 26, 2011 Share Posted March 26, 2011 Okay, il be able to do that, is it stored inside a database? post the sql with the create table and a few example rows, and the script u want to make it look like the picture, il work on it on my server. and return it in about 20 minutes. Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192525 Share on other sites More sharing options...
Lee1007 Posted March 26, 2011 Author Share Posted March 26, 2011 Yea it is stored in a database. The script I want to style is: <?php include 'config.php'; include 'opendb.php'; $query = "SELECT shop_name, street_name, town, postcode, contact_number, web_address, user_email FROM user_info"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $shop_name = $row[0]; $street_name = $row[1]; $town = $row[2]; $postcode = $row[3]; $contact_number = $row[4]; $web_address = $row[5]; $user_email = $row[6]; echo "<h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>"; } include 'closedb.php'; ?> </div> The SQL is: <?php if (isset($_REQUEST['Submit'])) { # THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE $sql = "INSERT INTO $db_table(shop_name,street_name,town,postcode,contact_number,web_address,user_email) values ('".mysql_real_escape_string(stripslashes($_REQUEST['shop_name']))."','".mysql_real_escape_string(stripslashes($_REQUEST['street_name']))."','".mysql_real_escape_string(stripslashes($_REQUEST['town']))."','".mysql_real_escape_string(stripslashes($_REQUEST['postcode']))."','".mysql_real_escape_string(stripslashes($_REQUEST['contact_number']))."','".mysql_real_escape_string(stripslashes($_REQUEST['web_address']))."','".mysql_real_escape_string(stripslashes($_REQUEST['user_email']))."')"; if($result = mysql_query($sql ,$db)) { echo '<h1>Thank you</h1>Your information has been entered into our database<br><br>'; } else { echo "ERROR: ".mysql_error(); } } else { ?> Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192528 Share on other sites More sharing options...
Russia Posted March 26, 2011 Share Posted March 26, 2011 Post a dump of your sql so I can work on it on my localhost. Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192529 Share on other sites More sharing options...
mattal999 Posted March 26, 2011 Share Posted March 26, 2011 <?php include 'config.php'; include 'opendb.php'; $query = "SELECT shop_name, street_name, town, postcode, contact_number, web_address, user_email FROM user_info"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $shop_name = $row[0]; $street_name = $row[1]; $town = $row[2]; $postcode = $row[3]; $contact_number = $row[4]; $web_address = $row[5]; $user_email = $row[6]; echo "<div style=\"float:left;width:300px;margin-right:20px;\">" . " <h5>Name:</h5>$shop_name <br>" . "<h5>Address</h5>$street_name <br>" . "$town <br>" . "$postcode <br>" . "<h5>Contact Details</h5>Phone Number:$contact_number <br>" . "Web Address: $web_address <br>" . "Email : $user_email <br><br>" . "</div>"; } include 'closedb.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/231773-how-do-i-style-this-php/#findComment-1192537 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.