You are here: Multiple queries in one script « PHP Programming Language « IT news, forums, messages
Multiple queries in one script

Posted by Bob Sanderson on 10/13/55 11:39

I am relatively new to PHP and MySQL. This is the first time I've tried
to use multiple queries in a single script.

I have the following PHP script which gets a Job Number from a search
form and generates a web page which displays the record for that job:

$username="root";
$password="";
$database="foobar";

$Searchterm = $_GET['JobNumber'];

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="select * from jobs where JobNumber like $Searchterm";

$result=mysql_query($query);
$num_results=mysql_num_rows($result);
$JobNumber=mysql_result($result,$i,"JobNumber");
$NSN=mysql_result($result,$i,"NSN");

echo various fields here

This part works fine.

----------------------------------

I now want to list other jobs which use the same NSN on the same page
under that display. This is the script I'm using:

$query2="select * from jobs where NSN like $NSN";
$result=mysql_query($query2);
$num_results=mysql_num_rows($result);
$JobNumber=mysql_result($result,$i,"JobNumber");

echo query2; (returns the correct query, including the NSN)
echo $num_results (returns nothing)

$i=0;
while ($i < $num) {

echo various fields here (returns nothing)

$i++;
}

Can anyone tell me what I'm missing?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация