Jump to content

uswege

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by uswege

  1. I am trying to output from mysql database, the code i have, which is just before the opening html tag, is this below <?php include('connecting_file.php'); $catid=$_GET['cat']; $subid=$_GET['subcat']; if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_name, $pmo); $query_cat = "select * from subcat where catid='$catid'and subid='$subid'"; $cat = mysql_query($query_cat, $pmo) or die(mysql_error()); $row_cat = mysql_fetch_assoc($cat); $totalRows_cat = mysql_num_rows($cat); ?> Then i use this one to output the content from the table by just adding this code to where i want content to appear <?php echo $row_cat['content']; ?> but all i get is Notice: Undefined index: cat in C:\wamp\www\mysite\aboutus.php on line 2 Notice: Undefined index: subcat in C:\wamp\www\mysite\aboutus.php on line 3 Can someone please help me out
  2. thanx the182guy and ignace, i've been out for nearly 40 hrs but hope someone will help I have corrected the missing ' and changed $query1 to $sql, then it displayed, in boxes heading Currency, Buying and Selling, then realised that i was echo'ing them, so i further made some changes, the full code now is, after changes am getting blank page <?php include('connect_file.php'); // user has submitted 3 dropdown menus for the day, month, year $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; // add validation and clean the input for SQL $fulldate = $year . '-' . $month . '-' . $day; // $fulldate now looks like 2010-04-25 // find all records where the date matches the inputted date $sql = "SELECT * FROM exchange WHERE DATE_FORMAT(`date`, '%Y-%m-%d') = '$fulldate'"; $result=mysql_query($sql) or die(mysql_error()); ?> <style type="text/css"> <!-- .tdmido { border: 1px none #000066; text-align: center; line-height: 22px; background-color: #FFFFFF; } --> </style> <?php while($row=mysql_fetch_array($result)){ echo "</td><td>"; echo $row['Currency']; echo "</td><td>"; echo $row['Buying']; echo "</td><td>"; echo $row['Selling']; echo "</td></tr>"; } echo "</table>"; while($row=mysql_fetch_array($result)) echo $row['Update']; ?> </style>
  3. think am almost there! here is my complete code <?php include('Connections/pmo.php'); // user has submitted 3 dropdown menus for the day, month, year $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; // add validation and clean the input for SQL $fulldate = $year . '-' . $month . '-' . $day; // $fulldate now looks like 2010-04-25 // find all records where the date matches the inputted date $sql = "SELECT * FROM exchange WHERE DATE_FORMAT(`date`, '%Y-%m-%d) = '$fulldate'"; $result=mysql_query($quey1) or die(mysql_error()); ?> <style type="text/css"> <!-- .tdmido { border: 1px none #000066; text-align: center; line-height: 22px; background-color: #FFFFFF; } --> </style> <table width="100%" align="center" border="1" bordercolor="#BDD7FC" cellpadding="1" cellspacing="0" style="background-color:#FFFFFF; "class="tdmido" > <tr class="tdmido"> <th>Currency</th> <th>Buying</th> <th>Selling</th> </tr> <?php while($row=mysql_fetch_array($result)){ echo "</td><td>"; echo $row['CurrencyName']; echo "</td><td>"; echo $row['Buying']; echo "</td><td>"; echo $row['Selling']; echo "</td></tr>"; } echo "</table>"; while($row=mysql_fetch_array($result)) echo $row['Update']; ?> </style> Its says 'Query was empty' which i understand is not an error but a message that the request data is not there? but was this not suppossed to bring a drop down dates instead?
  4. i saw that it won't but thought it'll at least bring the drop down dates :-), alright let me try to get other mysql query and see how it works
  5. just changed it to the new code you''ve given, i am still getting a blank page, what might i getting wrong? just read read somewhere that 'date' is a reserved field name for mysql, can it be a reason?
  6. hello the182guy, the page i am working on is http://www.azaniabank.co.tz/currency.php i am trying to get something similar to http://www.nbctz.com/exchange-rates (look the last part of the page where user can choose date and month then click go to retrieve forex rates of the selected date) I have put the code you've given just below the code i already have (of course in a separate div), but it is blank. any idea?
  7. hello the182guy, the date field in mysql is of DATETIME type and Yes date is stored in MySQL format will try the codes you've given me and post the output right here.. . . just a moment! Thanx for reply!
  8. hello guys, PM me if you can help me get this work, will give out some dollars for this!
  9. hello guys, i have a table called 'exchange' with the following fields [id,Currency,Buying,Selling,date] I want to create an archive page using a drop down date, ie three boxes, one fo date, another for month and the last one for year, when a user specifies the date/month/year he will click 'go' then be taken to the exchange rates page of the date he chooses. I have the script to put data into the database, it is working fine, but i can't make one to pull data from the database in a way i want it to. The current code i have just pulls the whole data. I want to get something similar to http://www.nbctz.com/exchange-rates The code i have now is THIS BEFORE THE OPENING HTML TAG <? php include 'connection_file.php'; ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_exc = 100; $pageNum_exc = 0; if (isset($_GET['pageNum_exc'])) { $pageNum_exc = $_GET['pageNum_exc']; } $startRow_exc = $pageNum_exc * $maxRows_exc; mysql_select_db($database_pmo, $pmo); $query_exc = "SELECT * FROM exchange order by `date` desc"; $query_limit_exc = sprintf("%s LIMIT %d, %d", $query_exc, $startRow_exc, $maxRows_exc); $exc = mysql_query($query_limit_exc, $pmo) or die(mysql_error()); $row_exc = mysql_fetch_assoc($exc); if (isset($_GET['totalRows_exc'])) { $totalRows_exc = $_GET['totalRows_exc']; } else { $all_exc = mysql_query($query_exc); $totalRows_exc = mysql_num_rows($all_exc); } $totalPages_exc = ceil($totalRows_exc/$maxRows_exc)-1; ?> THEN THIS IN THE BODY SECTION <?php do { ?> <tr> <td height="17" align="center" bgcolor="#EAEAEA"><?php echo $row_exc ['Currency']; ?></td> <td height="17" align="center" bgcolor="#EAEAEA"><?php echo $row_exc ['Buying']; ?></td> <td height="17" align="center" bgcolor="#EAEAEA"><?php echo $row_exc ['Selling']; ?></td> </tr> <?php } while ($row_exc = mysql_fetch_assoc($exc)); ?> will appreciate your help
  10. I have a code that pulls data from mysql. The codes pulls the first 321 characters. (including spaces). It however cuts words, can any one help me to tune it in way that it will not cut words and will eliminated white spaces. Below is the code, your help will highly be appreciated! <?php include 'connect.php'; $query="SELECT * FROM main WHERE main.category='1' ORDER BY id DESC LIMIT 1"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $content=mysql_result($result,$i,"content"); echo substr($content, 0, 321); $i++; } ?>
  11. May be it is something that has to do with the structure of my db. i have two tables 1. main with fields id,category,content,updatetime,updateby 2.category with fields id,CategoryName The category field in the main table is linked to the category table (because i want the category field in the main table to be dynamic) i want to display the content field of a selected category field. can any one help?
  12. Thanks guys. . i think i am one step ahead. I have removed mysql_close(); and changed mysql_numrows => mysql_num_rows before doing changes, the page could't open (the browser was just hanging and bringing an error msg), now the page opens but not data, the connection is Successful only the data is not displayed. The current script is <?php include 'connect.php'; $query="SELECT * FROM main WHERE category='Home' ORDER BY 'id' DESC Limit 1"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $content=mysql_result($result,$i,"content"); echo "$content"; $i++; } ?> Also the DB address and login info is http://www.tib.co.tz/db Username: test Password: test
  13. I have just created a database for site created by someone else. The address to the database is http://www.tib.co.tz/db Use the following login details to get in Username: test Password: test The Challenge is, i am trying to output data from the database (mysql databe) into a webpage using php script, but the script is just not working, where am getting it wrong? below is the output script i am using <?php include 'connect.php'; $query="SELECT * FROM main WHERE Category='Home' ORDER BY 'id' DESC Limit 1"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $content=mysql_result($result,$i,"content"); echo "$content"; $i++; } ?>
  14. Originally I thought of putting every page´s head in that area, may i should go back to my original plan. Thanx for mentioning I´ve removed all the three links at the top. Left links i think they are needed otherwise i put too much stuff in one page, they aren´t repeating.
  15. I am 27. Not married but soon will. Born and live in Tanzania, East Africa. I speak swahili, English is second language here, you´ll have to excuse any grammatical errors. work in bank, computers is kinda of a hobby, the only time i look at codes is weekends but sometimes after office hours. after html, css, php and mysql, am currently learning java
  16. 1. Perfect Color Combination 2. a chat in another applet not embedded in the main page or at least not that top (b´se is the fist thing a person sees when he open the site) 3. Not sure if the small animated gifs in the main box looks nice. i´d go something still (a fixed pic)
  17. Perfect Color Combination Too much space right after (Please register first if you want to chat. Don't press the shout button without registering or typing something, something bad may happen.) Not sure if the small animated gifs in the main box looks nice.
  18. hello guys, www.alesytravel.net is another site i´ve just uploaded, what are your opinions?
  19. after going through your posts also speaking to my client (also a friend) we decided to dump the whole thing out. www.eshocare.org is now changed (old version not included). In my new layout i've considered a CSS hover menu - think is cross browser and doesnt need java enabled browser. i also have added a database to make updating of the web little easier. you guys can login using login name "eshotest" password "eshotest" What are you guys saying abut the new layout? your critique plz!
  20. 1. I've changed font style, think arial is more eye friendly, also changed font size from fixed points to em , users should say what size suites them best. 2. Yes, i think for such a simple menu, using javas wasn't a clever move. thanx for pointing out. will surely go for CSS 3. color scheme. originally i did pull the colors from the head but then my client thought its too greenish and green is not her favourite. may be will have to redo the head. 4. Does it look cut-off in 1024*768? i actually used that size to create a layout image. 5. Code cluttered? i used fireworks for layout, sliced and exported html to dreamweaver, that fireworks is clever enough to produce clean codes
  21. hello guys, http://www.eshocare.org is a site for an NGO, the first page (home page of course) is done but few things. your critique on the general layout, the colors and suggestions on areas to improve is very welkAm.
  22. thanks guys, it worked perfectly well but still running in my local server. in the nxt few days will post the address under (web critique section) for your review.
  23. Thanx Kathas, wonder if i got u right or not, i've used the query below to create a table and thereafter phpmaker to create php scripts. CREATE TABLE main ( id int NOT NULL auto_increment, street_children text, orphans text, handicapped_children text, hiv_aids text, child_labor text, christian_denomination text, category varchar (20), PRIMARY KEY (id) ); The problem is, is if i want to input (add or edit) all comes in one page (as if all info are for one item). To be specific, (1) Did i get the table structure right? (2) If i got it right how am i supposed to go about getting the functionality i want (i.e be able to edit/update a category)
  24. I am creating a website for my client the address is http://www.gcntcommunitycaretz.org/ (the site under construction) I want main part of the site to get its contents from the database. from http://www.gcntcommunitycaretz.org/ i have six headings, 1. STREET CHILDREN 2. ORPHANS 3. HANDICAPPED CHILDREN 4. HIV/AIDS 5. DOMESTIC CHILD LABOUR 6. HIV/AIDS IN CHRISTIAN DENOMINATIONS I want all the six headings to get its contents from the DB, i will display for example the first five lines on the main page, if the reader wants to read more s/he clicks the link (will will be provided) My question is, need i have six different tables for each heading? is there a way to put all this in one table? if yes, how will i have to about it.
  25. viewed using ie 1024 x 768 resolution. need lots of scrolling, think its too wide, what about using % ?
×
×
  • 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.