PDA

View Full Version : Alright, something in PHP with asps case and urls..?



NineTwoZero
05-06-2007, 08:56 AM
Id wanna know if there's sumthing in php that matchees asps
<&#37;If Case "Ok" %>
<!-- Just a remark, the url would be like file.php?id=0 or 1 -->
TEXT HERE
<% If Case Else %>
OTHER TEXT HERE


so i dont really remember the whole thing, long time since i last used ASP..

so is the thing i wrote possible? Coz i was thinking like putting some pictures beside eachother. then when u click one, the "text" loads underneath or sumthing, and when u click the othher one, the new text loads. :D

Twey
05-06-2007, 09:26 AM
I don't know any ASP, but there's not nearly enough information in that code for it to actually work. Thus, I've no idea what you're trying to do.

NineTwoZero
05-06-2007, 09:43 AM
ill try to explain what i wanna do..

Im fixing my clan website and I was thinking of putting a picture of all the members (until we get bigger i suppose) and when u click a certain picture, its gonna load a page, preferably team.php?id=0 etc. that "page" will have information about the member with id 0. I've already set up the database with the fields that's required and I thought that this would be a good idea. sorry for such messy text, aint a good writer :p

edit: and about the ASP code, i dont really remember the code, just those parts..

Twey
05-06-2007, 10:54 AM
Well, you'd use the ID to construct the query:
<?php
if(!(
is_numerical(@$_GET['id']) &&
$row = mysql_fetch_array(mysql_query(sprintf('select * from members where id=&#37;d limit 1', $_GET['id'])))
))
die('Error, bad ID!');
else {
?>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php print $row['id']; ?></td>
<td><?php print $row['name']; ?></td>
<td><?php print $row['email']; ?></td>
</tr>
</tbody>
</table>
<?php } ?>

NineTwoZero
05-06-2007, 07:06 PM
i dont really get how i connect this to a picture. since its using GET, i need a submit right? ;O

thetestingsite
05-06-2007, 07:10 PM
Just place the code that Twey posted in a new php file (make sure it has the extension .php), then just link the picture to that file like so:



<a href="page.php?id=2"><img src=".....


Change the two to the member id you want to view (or link to).
Hope this helps.

//EDIT: If you were getting the list of pictures dynamically, simply replace the part in red (in the above code) with the variable for that row's "id".

NineTwoZero
05-06-2007, 07:21 PM
is there no easier way? hehe.

i found my asp file, feel free to check it out, it'd be like that only with the cases involving the pictures.. ah, check it out, wont help if i keep on babblin ;p :cool:

Twey
05-06-2007, 08:48 PM
The PHP equivalent is:
<?php
switch($_GET['page']) {
case 'news':
?>
<br /><?php include('news.inc'); ?>
<?php break; case 'bios': ?>
<br />This is the bios page.
<?php break; case 'guestbook': ?>
There will be a guestbook here shortly.
<?php break; case 'links': ?>
LINKS
<?php break; case default: ?>
<br />This is the homepage.
<?php } ?>

NineTwoZero
05-06-2007, 08:53 PM
The PHP equivalent is:
<?php
switch($_GET['page']) {
case 'news':
?>
<br /><?php include('news.inc'); ?>
<?php break; case 'bios': ?>
<br />This is the bios page.
<?php break; case 'guestbook': ?>
There will be a guestbook here shortly.
<?php break; case 'links': ?>
LINKS
<?php break; case default: ?>
<br />This is the homepage.
<?php } ?>

thanks! :D ima try it out, just one last question i guess, how do i get the script to work with the pictures? do i use Thetestingsites advice? :D

cr0w
05-06-2007, 09:04 PM
Simply put all the images in one static directory(www.example.com/pics/). Then, on the page where you display the member's picture/info, use something like:

<?php
function fix_results($s){
return htmlentities(stripslashes($s));
}
$getMember=mysql_query("SELECT * FROM members WHERE id = '".$_GET['id']."'") or die(mysql_error());
$showMember=mysql_fetch_assoc($getMember);
echo '<img src="/pics/'.fix_results($showMember['image']).'" />';
?>

NineTwoZero
05-06-2007, 09:08 PM
Simply put all the images in one static directory(www.example.com/pics/). Then, on the page where you display the member's picture/info, use something like:

<?php
function fix_results($s){
return htmlentities(stripslashes($s));
}
$getMember=mysql_query("SELECT * FROM members WHERE id = '".$_GET['id']."'") or die(mysql_error());
$showMember=mysql_fetch_assoc($getMember);
echo '<img src="/pics/'.fix_results($showMember['image']).'" />';
?>
alright, will try it out tomorrow =D thanks a bunch!:cool:

cr0w
05-07-2007, 01:34 AM
alright, will try it out tomorrow =D thanks a bunch!:cool:

No problem. :)