PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 1st, 2002, 09:29 PM
flying23x flying23x is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 flying23x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
php mysql help

I was wondering if any one could help me. I am have a database with php and mysql, and it outputs the information on a search. How can I get it to output a link to that specific page of the search results. SO, if you search for cars, it would make a link to that page. http://www.test.com/cars.php

Reply With Quote
  #2  
Old March 1st, 2002, 09:37 PM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 7
RE: php mysql help

You are going to need to be a little for specific. Do you already have the info in your database? How is it stored? Are you saying that you already have a functioning search, but it only shows the data and you want it to have a link instead?


Reply With Quote
  #3  
Old March 8th, 2002, 10:35 PM
webxdevelopment webxdevelopment is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 webxdevelopment User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Hey flying what about somthing like this (without any details it is very hard to help)

$result= mysql_query("select * from cars");
if (!$result) {
echo("</TABLE>");
echo("<P>Error retrieving cars from database!<BR>".
"Error: " . mysql_error());
exit();
}
echo "<center><table>n";
while ($r = mysql_fetch_array($result)) {

if ($bgcolor == "bgcolor = #C0C0C0") {
$bgcolor = "bgcolor = #FFFFFF";
} else {
$bgcolor = "bgcolor = #C0C0C0";
}
echo("<TR>n");
$Car_link = $r["Car_link"];

$Car_name = $r["Car_name"];

echo("<td $bgcolor><center><font color=#0033af><a href='" . $r["Car_link"] . "'>" . $r["Car_name"] ."</td>n");
echo("</tr>n");
}
echo "</center></table>n";

Reply With Quote
  #4  
Old April 10th, 2002, 08:47 AM
Gore Gore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 Gore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Hey guys, Im new to this place AND php. I have a similar question. I have set up a page to put data from mySQL in to tables (got the info from this site). I want the data in "item_num" to be a link going to a page with the corresponding item_num.html.

Example Output:

2314 | Ring | Gold Ring

I want the "2314" to link to a page 2314.html. Here is what I have so far....

<?PHP
$db = mysql_connect("localhost","$login","$password") or die("Problem connecting");
mysql_select_db("jewelryboxnw_com") or die("Problem selecting database");
$query = "SELECT * FROM inventory ORDER BY item_num";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
?>

<html>

<head><title></title></head>

<body>

<?PHP
echo "<TABLE BORDER="0">n";
echo "<TR bgcolor="lightblue"><TD>Item#</TD><TD>Price</TD><TD>Item</TD><TD>Description</TD></TR>n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor="#FFFFCC">n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor="white">n";
}
echo "<TD>".$row['item_num']."</TD><TD>".$row['price']."</TD><TD>".$row['item']."</TD><TD>".$row['desc']."</TD>n";
echo "</TR>n";
}
//now let's close the table and be done with it
echo "</TABLE>n";
?>

</body>

</html>


....the code here probably looks crappy and I am open to ANY suggestions!

Thanks!

Reply With Quote
  #5  
Old April 10th, 2002, 10:57 AM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 7
RE: php mysql help

All you need to do is take this one line :

echo "<TD>".$row['item_num']."</TD><TD>".$row['price']."</TD><TD>".$row['item']."</TD><TD>".$row['desc']."</TD>n";


and change it to something like this : (I have made it two seperate line now just because I find it easier to read):

echo "<TD><a href="".$row['item_num'].".html">".$row['item_num']."</a></TD>";
echo "<TD>".$row['price']."</TD><TD>".$row['item']."</TD><TD>".$row['desc']."</TD>n";

Hope that helps...

Reply With Quote
  #6  
Old April 11th, 2002, 03:38 AM
Gore Gore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 Gore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Thanks Matt! That helps a lot. I'll try it out tonight.

Reply With Quote
  #7  
Old April 11th, 2002, 03:47 AM
Gore Gore is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 Gore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: php mysql help

Woohoo! It works perfect! Thank you!

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php mysql help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek