Jump to content

uswege

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

uswege's Achievements

Member

Member (2/5)

0

Reputation

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