LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-11-2008, 05:41 AM   #1
ajeetraina
Member
 
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292

Rep: Reputation: 30
PHP Script for Database retrieval??


Hello Guys,

May Be I am wrong to this space but I need yur little help in this regard.I tried running this PHP script but need to modify as per my requirement:
Code:
<?php

$con = mysql_connect("localhost","root","mysql123");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }mysql_select_db("petp", $con);





$query= "select * from task where Project='" . $_POST['Project'] . "'";

//echo $query;



$result= mysql_query($query);

$num_results = mysql_num_rows($result);



for ($i=0; $i <$num_results; $i++)

{

$row = mysql_fetch_array($result);

echo "Project: ", $row['Project'], ": ",$row['Project'];

echo "List of Task: ", $row['List'], ": ",$row['List'];

echo "Assigned To: ", $row['Assigned'], ": ",$row['Assigned'];

echo "Start Date: ", $row['Start'], ": ",$row['Start'];

echo "End Date: ", $row['End'], ": ",$row['End'];

echo "Completion Percent: ", $row['Completion'], ": ",$row['Completion'];
}
?>
This displays the following output on Web Broswer:

Project: gice: giceList of Task: : Assigned To: Select: SelectStart Date: 0000-00-00: 0000-00-00End Date: 0000-00-00: 0000-00-00Completion Percent: : Project: gice: giceList of Task: : Assigned To: Select: SelectStart Date: 0000-00-00: 0000-00-00End Date: 0000-00-00: 0000-00-00Completion Percent:

It is throwing the following way but I want to be displayed in the tables in rows and columns.

Pls Help.
 
Old 03-11-2008, 09:49 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
It fits better in the programming section

Question: what do you know about html? Read up on the table, tr and td tags

Code:
echo "<table>\n";
for ($i=0; $i <$num_results; $i++)
{
    $row = mysql_fetch_array($result) ;
    echo "<tr><td>Project: ", $row['Project'], ": ",$row['Project'];

    // all your other columns go here

    echo "</td></tr>\n";
}
echo "</table>\n";
Not tested
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Backing up your MySQL database using your web browser and a PHP script LXer Syndicated Linux News 0 04-21-2007 10:16 PM
LXer: How to script songs lyrics retrieval LXer Syndicated Linux News 0 04-04-2007 10:01 AM
MySQL Database Retrieval chantman Linux - Server 1 02-21-2007 12:15 PM
PHP Script for Importing vCards into a MySQL Database? amocjr Linux - Software 1 01-20-2007 03:54 PM
LXer: Title: PHP/MySQL Classifieds Script AddAsset1.php Script Insertion LXer Syndicated Linux News 0 07-02-2006 06:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration