Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

PHP&MySQL left/substring etc problem
Hello,
I need your help about PHP (ver 4.3.1) and MySQL (ver 3.23) database.
I am struggling to customise a database (using left command etc), and am
stuck now.
Please have a brief look at my scripts below.

What I do like to do is to get first 3 letters from "loc1" column from
openart_table (MySQL).
And show the data in the follwoing part...
<td><? echo $row["loc1"]; ?><br></td>

but also I would like to make hyperlinks to jpg files to images/"the first 3
letters from loc1".jpg
So it will be something like this...
<td>
<a href="/image/<? echo $row["loc1"]; ?>.jpg"><? echo $row["loc1"];
?></a><br>
</td>

But when I tried, "select left (loc1,3) from openart_table where......"
doesnt work properly.
I do not want to destroy anything for the rest of the table.
I need all data from "tit1", "pub1", "id1", and "ref1" in each column.

Could you help me, please?

---------------------------------------------PHP script from here
<html>
<body>
<table border="1" bordercolor="black" cellspacing="0" align="center"
BGCOLOR="#CCFFFF" width="900">
<tr bgcolor="#ffcc66">
<td align="center"><b>ID No</b><br></td>
<td align="center" BGCOLOR="#CC3366"><b>Book Title</b><br></td>
<td align="center"><b>Publisher</b><br></td>
<td align="center"><b>ID</b><br></td>
<td align="center"><b>Reference</b><br></td>
<td align="center" width="10%"><b>Location</b><br></td>
</tr>

<?
mysql_connect(localhost,root,cheers);
mysql_select_db(openart);
if($tit == "" &&
$res == "" &&
$pub == "" &&
$date == "" &&
$id == "" &&
$ref == "" &&
$loc == "" &&
$type == "" &&
$vol == "" &&
$fre == "" &&
$note == "")
{
echo 'Type something';
}

elseif($tit == "%" || $res == "%" || $pub == "%" || $date == "%" || $id ==
"%" ||
$ref == "%" || $loc == "%" || $type == "%" || $vol == "%" || $fre ==
"%" || $note == "%"){
echo 'Not Valid';
}

else{
if($tit == ""){
$tit = '%';
}
if($res == ""){
$res = '%';
}
if($pub == ""){
$pub = '%';
}
if($date == ""){
$date = '%';
}
if($id == ""){
$id = '%';
}
if($ref == ""){
$ref = '%';
}
if($loc == ""){
$loc = '%';
}
if($type == ""){
$type = '%';
}
if($vol == ""){
$vol = '%';
}
if($fre == ""){
$fre = '%';
}
if($note == ""){
$note = '%';
}
$result = mysql_query("select * from openart_table
where tit1   like '%$tit%'
and res1   like '%$res%'
and pub1  like '%$pub%'
and date1  like '%$date%'
and id1   like '%$id%'
and ref1  like '%$ref%'
and loc1  like '%$loc%'
and type1   like '%$type%'
and vol1  like '%$vol%'
and fre1  like '%$fre%'
and note1   like '%$note%' order by tit1");

$rows = mysql_num_rows($result);
echo $rows,"Records Found <p>";
while($row = mysql_fetch_array($result)){
?>
<tr>
<td><a href = "openart_detail.php ?iden=<? echo $row["openart_id"] ?>"><?
echo $row["openart_id"]; ?></a><br></td>
<td><? echo $row["tit1"]; ?><br></td>
<td><? echo $row["pub1"]; ?><br></td>
<td><? echo $row["id1"]; ?><br></td>
<td><? echo $row["ref1"]; ?><br></td>
<td><? echo $row["loc1"]; ?><br></td>
</tr>
<?
}
}
?>
</table>
</body>
</html>

----------------------------------------------------end of script

Report this thread to moderator Post Follow-up to this message
Old Post
Sugimoto
04-19-05 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP DB archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.