Page 1 of 1

how do i display data as required

Posted: Thu Nov 12, 2009 11:48 am
by chris_s_22
not exactly sure if this should even be in php section but i will ask anyways
I finally got my search page working however the result are then displayed on this blank page.

what im trying to achieve is to display the results on my searchindex.php
i can do a
include 'searchindex.php';
just before the
do
statement and the results would be displayed on that page. However i use css to display ever asspect of my page. and the results wouldnt be positioned correctly. i can add whats needed to my style.css however this page being fully php how do i wrap a div class around it
so when result is shown it will dispaly on the right page in the right position

Code: Select all

 
<?php
include 'Connect.php';
 
if(!isset($_GET[submit])) 
{
     // Show the form
     include 'searchindex.php';
     exit;
}
else
{
$result = mysql_query ("SELECT * FROM members WHERE username LIKE '%$searchone%' "); 
 
PRINT "<b>You searched for:</b> ";
PRINT "$searchone";
print ("<br>");
 
if ($row = mysql_fetch_array($result)) 
{ 
do 
{ 
PRINT "<b>User Name: </b> "; 
print $row["username"]; 
print (" "); 
print ("<br>"); 
PRINT "<b>Location: </b> "; 
print $row["location"]; 
print ("<p>"); 
PRINT "<b>Date of Birth: </b> "; 
print $row["dob"]; 
print ("<p>");
} 
while($row = mysql_fetch_array($result)); 
} 
else {print "Sorry, no records were found!";} 
}
?>
 

Re: how do i display data as required

Posted: Thu Nov 12, 2009 12:28 pm
by califdon
Just print (or echo) the tags you want. If you want a <div> tag, just:
print "<div>";
Print and echo merely send whatever follows to the browser.

You're already doing that with <b> and </b> tags, <div> is no different. By the way, <b> tags are deprecated. You should be using <strong> and </strong>. One of these days, the new browsers will not recognize deprecated syntax and your page will not render correctly.

Re: how do i display data as required

Posted: Thu Nov 12, 2009 1:05 pm
by chris_s_22

Code: Select all

PRINT ("<div class"searchresult">")
PRINT ("</div>")
include 'searchindex.php';
where would i put the above lines in the code if i do put
include 'searchindex.php';
that seems to be fine just before the "do" statement

ive tried putting the div tags in various positions but come up with the error

Code: Select all

Parse error: syntax error, unexpected T_STRING on line 22
also am i suposed to call the style sheet on this page as well? i do in the page i want to display the results on searchindex.php

i would of thought this would of been fine

Code: Select all

 
<?php
include 'Connect.php';
 
if(!isset($_GET[submit])) 
{
     // Show the form
     include 'searchindex.php';
     exit;
}
else
{
$result = mysql_query ("SELECT * FROM members WHERE username LIKE '%$searchone%' "); 
 
PRINT "<strong>You searched for:</strong> ";
PRINT "$searchone";
print ("<br>");
 
if ($row = mysql_fetch_array($result)) 
{ 
include 'searchindex.php';
PRINT ("<div class"searchresult">");
do 
{ 
PRINT "<strong>User Name:</strong> "; 
print $row["username"]; 
print (" "); 
print ("<br>"); 
PRINT "<strong>Location:</strong> "; 
print $row["location"]; 
print ("<p>"); 
PRINT "<strong>Date of Birth:</strong> "; 
print $row["dob"]; 
print ("<p>");
} 
PRINT "</div>";
while($row = mysql_fetch_array($result)); 
} 
else {print "Sorry, no records were found!";} 
}
?>
 

Re: how do i display data as required

Posted: Thu Nov 12, 2009 2:35 pm
by jackpf
Need to escape quotes.

Re: how do i display data as required

Posted: Thu Nov 12, 2009 4:25 pm
by chris_s_22
oh yeah i see what your getting at

PRINT ("<div class = searchresult>");
instead of using \ i found out just taking the quotes out works

this kinda works it positions perfect but thats when i put them inside the "do" statement. But as you can imagine because it loops it writes each result over the top of each other

ive tried a few places putting the print div tags outside but im getting errors or it mess the rest of page any id where the correct position should be?

Re: how do i display data as required

Posted: Fri Nov 13, 2009 4:18 am
by jackpf
I dont understand...are you using absolute positioning or something?

Re: how do i display data as required

Posted: Fri Nov 13, 2009 5:20 am
by chris_s_22
yes im using something similar to this in style sheet
is this the problem what would be the work around?
position: absolute;

Re: how do i display data as required

Posted: Fri Nov 13, 2009 5:27 am
by jackpf
Yeah, just don't use absolute positioning.

Re: how do i display data as required

Posted: Fri Nov 13, 2009 5:36 am
by timWebUK
califdon wrote: By the way, <b> tags are deprecated. You should be using <strong> and </strong>. One of these days, the new browsers will not recognize deprecated syntax and your page will not render correctly.
I'm pretty sure <b> isn't deprecated... can't see it anywhere on the w3c specification. And also, if it was, I'm sure a style sheet using 'font-weight' would be a recommendation and not <strong>?