Jump to content

MySql Array


JustinMs66@hotmail.com

Recommended Posts

ok so i want to get certain text from a mysql database.
so far i have done this with this code:
[code]<?php
//this file includes my passwords...etc. used for connecting.
include(config.php);

$db = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

//select "Cmessage" and "csubject" from the list, 2 tables that include data
$query  = "SELECT csubject, cmessage FROM list";
$result = mysql_query($query) or die('Error, query failed ##1');

while($row = mysql_fetch_row($result))
{
    $Subject    = $row[0];
    $Message = $row[1];

// define table codes for the subject place for before and after the text
    $htmlsubbefore="<div class=\"ts hazardrow\"><div class=\"coltitle_dark tlarge\">";
    $htmlsubafter="</div><div style=\"clear:both\"></div></div>";

//define table codes for the message body place before and after the text
    $htmlbodbefore="<table width=\"50%\"><tr class=\"hazardrow\"><td width=\"50%\">";
    $htmlbodafter="</td></tr>";

and then display it with the html before + the row + the HTML after
    echo $htmlsubbefore . $row[0] . $htmlsubafter.
        $htmlbodbefore . $row[1] . $htmlbodafter;

}
?>[/code]

now i'l be honest i'm not that good with MySql sync with php but i  am pretty good with PHP.
i followed a tutorial that got me this far.

anyway, now onto the question. here is what i want to do:
i am basically making a blog. i want to:
1) see how many entries their are
2) set that as the array end
3) keep displaying the different blog entries until there are no more

i hope i explained that in a way you can get. but right now it only displays 1 entry. their are more in the database. how can i keep displaying them with the html tables too? and i don't want it to be a set number because i don't know how many their are going to be
Link to comment
https://forums.phpfreaks.com/topic/28773-mysql-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.