Jump to content

Recommended Posts

I want to be able to print from my database and output into php file, I need help with the code I have tried to create in php to read from this database, the whole code will work the same as worldpress.org. where it displays images and text , than they click on the title of the event and it takes them to a secondary page....

 

CREATE TABLE events (

  id integer unsigned auto_increment primary key,

  title varchar(200) not null,

  `date` DATE not null,

  content longtext not null,

  image varchar(40) default null

)

 

 

and this is the code of my php doc.

 

<?php echo 'title-' . $link .'-'. strtolower($row['title]) .'.php'; ?>" width="60" height="50"></a></td>

                                <td width="344" valign="top"><span class="style20"><span class="style22"><?php echo $row['biz_type']; ?></span><br>

<?php echo 'image-' . $link .'-'. strtolower($row['image]) .'.php'; ?>"><img src="images/" width="60" height="50"></a></td>

                                <td width="344" valign="top"><span class="style20"><span class="style22"><?php echo $row['biz_type']; ?></span><br>

                                  <?php echo substr($row['description'], 0 ,100); ?>.. <br>

                                <span class="style21"><a href="<?php echo 'description-' . $link .'-'. strtolower($row['reference']) .'.php'; ?>"><u>Find out more.. </u></span></a></td>

                              </tr>

 

                          <?php } ?>

 

I am sure this php doc needs to be fixed in order to display correctly from datasbe, please suggest some alter in code.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/49396-php-read-from-database-correctly/
Share on other sites

It will need your database settings, as well as the connect code.

 

<?php

// Connect to the database
$host = "DB_HOST"; // db host
$user = "DB_USERNAME"; // db username
$pass = "DB_PASSWORD"; // db password
$db = "DB_NAME"; // db name

$connection = mysql_connect ($host, $user, $pass) or die ("Unable to connect"); 
mysql_select_db ($db) or die ("Unable to select database"); 
?>

 

Make sure to replace the capitalized letters with your correct settings.

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.