JustinMs66@hotmail.com Posted November 28, 2006 Share Posted November 28, 2006 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 are2) set that as the array end3) keep displaying the different blog entries until there are no morei 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 Quote Link to comment Share on other sites More sharing options...
Jocka Posted November 28, 2006 Share Posted November 28, 2006 change this:while($row = mysql_fetch_row($result)){ $Subject = $row[0]; $Message = $row[1];to this:while($row = mysql_fetch_array($result)){ $Subject = $row['csubject']; $Message = $row['cmessage'];that should get what u want. Quote Link to comment Share on other sites More sharing options...
Jocka Posted November 28, 2006 Share Posted November 28, 2006 oh and for future reference. you can use " mysql_num_rows($result) " for row count. Quote Link to comment 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.