Jump to content

Labels and values not appearing on the same line.


aquatradehub

Recommended Posts

Hi, I have this script which gets the info from the database and displays it in the page. It works fine apart from the Label and the result appearing on separate lines as if a <br /> tag was placed after the label. 

 

Here is the code

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);  

	include 'core/init.php';
	include 'includes/overall/header.php';
?>

<?php
$connect_error = 'Sorry, we are currently experiencing database issues. We are working to resolve this and should be up and running again shortly.';
$con=mysqli_connect('localhost', 'username', 'password', 'equatics_tropics');

if (isset($_GET['commonName']))
{
    $sCommonName = mysql_real_escape_string($_GET['commonName']);
    $sQry = "SELECT * FROM species WHERE commonName = '$sCommonName'"; 
    if ($qry = mysql_query($sQry))
    {
        while ($row = mysql_fetch_assoc($qry))
        {

vprintf('
<section id="content">
  <article id="index">
    <section class="index">
        <fieldset title="e-quatics.com">
        <legend></legend>
        <p><img src="../_images/tropical.png" height="250" width="250">Common Name: %s<br>
        Scientific Name: %s<br>
        Synonym: %s<br>
        Origin: %s<br>
        Size: %s<br>
        Environment: %s<br>
        Water Chemistry: %s<br>
        Temperature: %s<br>
        Feeding: %s<br>
        Sexing: %s<br>
        Compatability: %s<br>
        Temperament: %s<br>
        Breeding: %s<br>
        Comments: %s</p>
    </fieldset>            
</form>
    </section>
  </article>', $row);


			}
    }
}  
?>

And here is how it displays the information in the page

 

 

 

Common Name: 
Asian Arowana
Scientific Name: 
Scleropages formosus
Synonym: 
steoglossum formosum
Origin: 
Size: 16cm
Environment:
rivers

 

Instead of displaying it on the same line

eg. Common Name: Asian Arowana

Does anyone know how to fix this?

Thanks

Link to comment
Share on other sites

Hi guys, thanks for your replies.  Firstly no, I am not using any divs with width restrictions and secondly, I changed the code to this

vprintf('
<section id="content">
  <article id="index">
    <section class="index">
        <fieldset title="e-quatics.com">
        <legend></legend>
        <p><img src="../_images/tropical.png" height="250" width="250">Common Name: %s
        Scientific Name: %s
        Synonym: %s
        Origin: %s
        Size: %s
        Environment: %s
        Water Chemistry: %s
        Temperature: %s
        Feeding: %s
        Sexing: %s
        Compatability: %s
        Temperament: %s
        Breeding: %s
        Comments: %s</p>
    </fieldset>            
</form>
    </section>
  </article>', $row[]."<br>");

and all I get is a Server Error :(

Link to comment
Share on other sites

I have no idea, I was in discussion with another member and he suggested this. I dont understand the difference. What do I need to do to correct this?

 

Thanks

 

There are two different libraries.

 

Go to php.net and check out how to use mysqli or pdo. Stop using mysql!

Link to comment
Share on other sites

Change:

$con=mysqli_connect('localhost', 'username', 'password', 'equatics_tropics');

to 

$con=mysql_connect('localhost', 'username', 'password') or die(mysql_error());

mysql_select_db('equatics_tropics') or die(mysql_error());

PS: Don't remove anything from your vsprintf function.

Just check how many arguments it takes, that's all I think.

Edited by jazzman1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.